Solved

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

Posted on 2007-03-23
6
1,173 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 19

Expert Comment

by:Redimido
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:
Redimido 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Article by: btan
The intent is not to repeat what many has know about Ransomware but more to join its dots of what is it, who are the victims, why it exists, when and how we respond on infection. Lastly, sum up in a glance to share such information with more to help…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now