Solved

DOH - screwed up / with bad chmod command - how to recover?

Posted on 2007-03-23
6
1,178 Views
Last Modified: 2013-12-04
DOHHHH!

Logged in as root and from the following directory:

/home/test/transfers

I made the following stupid:

chmod -R 660 /

.... I ctrl-c this as soon as I noticed it was taking a few seconds but now I am wandering what the repercussions I might expect would be. Already I get an error sshing in and am unable to open an sftp session! /sbin/consoletype: Permission denied (fixed that with 777 for now)

Yes I know what 660 permissions are but not sure the effect on / is going to be and what default permissions should be what the best way to recover from this screwup is.  OS is CentOS 4.4


Thanks!

0
Comment
Question by:techwhore
  • 4
  • 2
6 Comments
 

Author Comment

by:techwhore
ID: 18783676
I've been manually going through and trying to correct permissions and trying to compare based on another installation... mostly 755's.

What would help is:

a) Is there a way to reinstall/repair CentOS without losing any of my settings (extra packages installed, /etc/)

b) What command can I use to find all files with 660? I believe find with -perm but I can't get it right.

Thanks
0
 

Author Comment

by:techwhore
ID: 18783732
Also if I build another drive with Centos 4.4 can I just copy all the dirs over? If I do this what do I have to watch out for?
0
 

Author Comment

by:techwhore
ID: 18784450
I guess I am about to find out if I can make things even wors by restoring an ACL dump of the entire filesystem.
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 19

Expert Comment

by:Gabriel Orozco
ID: 18786046
I will try to assemble something. I do not warranty it will work or that there is no other better way (MUST BE THERE) but for this quick purpose I'll try to assemble something:


do not disconnect from your system.

now, go to the other system with centos and use it as a base.
you need to see which files are there and their permissions
find . > files    #see what files are there
# add their right permissions:
while read file; do
   echo `stat -c%a $file` $file
done < files > files_perm

#now files_perm has all the files and their permissions. copy that file to your damaged system and now try to set correct permissions based on that other file:
while read file; do
    perm=`echo $file | awk '{print $1}'`
    name=`echo $file | awk '{print $2}'`
    echo chmod $perm $name
    chmod $perm $name
done < files_perm

some files will be missing, some others will show you an error but this should be of help.

you can run this against /etc and /dev directories at least.

good look
0
 

Author Comment

by:techwhore
ID: 18786726
Thanks Redi.

What I was thinking instead is dumping with getacl the clean system and setalc on the one messed up. Anything wrong with that?

Also if you install Centos 4.4 over itself will it pickup the existing install, run ans an upgrade and fix everything leaving settings in place?

0
 
LVL 19

Accepted Solution

by:
Gabriel Orozco earned 500 total points
ID: 18786883
Great, getacl is a wonderful tool. and copies much more data than what I made.

A reinstall will correct permissions, but I'm not sure what would happen to your current configuration.
I cannot help with the upgrade, neither...

0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

No security measures warrant 100% as a "silver bullet". The truth is we also cannot assume anything but a defensive and vigilance posture. Adopt no trust by default and reveal in assumption. Only assume anonymity or invisibility in the reverse. Safe…
Security measures require Windows be logged in using Standard User login (not Administrator).  Yet, sometimes an application has to be run “As Administrator” from a Standard User login.  This paper describes how to create a shortcut icon to launch a…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question