LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-11-2003, 05:49 PM   #1
fez
LQ Newbie
 
Registered: Nov 2003
Location: Bozone, Montuckey
Distribution: redhat 9
Posts: 3

Rep: Reputation: 0
I'm an idiot: chmod -R 755 * in / as root. Fix?


so, I guess the subject says it all.

I was trying to change the permissions of a folder but was one directory off from where i thought i was and ran:

chmod -R 755 *

in / as root. I seem to have fixed most of the related problems (ssh gets a bit snippy if you make your private keys public)

But have still encountered a couple problems that i can't quite trackdown. Mainly, i use eclipse (I'd post a link but it seems i'm just not cool enough for that yet) for programming and it works fine when i run it as root, but crashes when i run normal. this is the main problem i am trying to fix.

So, is there a quick and easy (perhaps as quick and easy as what caused the problem ?) fix to reset all my permissions back to default?

Dist: Redhat 9
Machine: Dell inspiron 2650

Thanks!


Last edited by fez; 11-11-2003 at 08:21 PM.
 
Old 11-11-2003, 08:03 PM   #2
michael@actrix
Member
 
Registered: Jul 2003
Location: New Zealand
Distribution: OpenSUSE Tumbleweed
Posts: 68
Blog Entries: 1

Rep: Reputation: 20
Perhaps you could use strace to see what it is trying to access.

man strace
 
Old 11-11-2003, 08:24 PM   #3
fyoder
Member
 
Registered: Nov 2003
Posts: 111

Rep: Reputation: 15
"So, is there a quick and easy (perhaps as quick and easy as what caused the problem ?) fix to reset all my permissions back to default?"

Nope. The command line can be quite lethal.

eg.
cd /
ls /tmp/*
(nope, nothing here I want to keep)
rm -rf *
(oops...)

At least you didn't do anything that bad.

I think your only hope is a complete restore from backup, or barring that perhaps a reinstall (ouch).
 
Old 11-12-2003, 07:28 AM   #4
fez
LQ Newbie
 
Registered: Nov 2003
Location: Bozone, Montuckey
Distribution: redhat 9
Posts: 3

Original Poster
Rep: Reputation: 0
yeah, i once did a rm -rfd * in the wrong directory. The sysadmin at school heard me yelling and told me about the backup directory that keeps a copy of every file we create on the school server. He looked at me funny when i tried to kiss him.
 
Old 11-12-2003, 07:57 AM   #5
dukeinlondon
Member
 
Registered: May 2003
Location: London
Distribution: kubuntu 8.10
Posts: 593
Blog Entries: 1

Rep: Reputation: 30
Linux conf checks a number of file permissions on exit. Maybe you should give it a go. Bastille also provides filesystem hardening, ie checks that the right permissions are set on the right things.

Granted, that won't be your defaults but should be good.
 
Old 11-18-2003, 12:10 PM   #6
mansonmuni
Newbie
 
Registered: Oct 2003
Distribution: Redhat 9
Posts: 16

Rep: Reputation: 0
This is an uneducated attempt to solve the same problem. I couldn't log in as root or any other user after an idiot chmod operation on my root directory as root. My redhat 9 install disk and went into rescue mode. Then I did a chroot /mnt/sysimage followed by an su, just to be sure I had root priveleges (I'm shaking now.) I ran rpm -qa to see if rpm was querying ok. Then I ran rpm -qa |xargs rpm --setperms. This took about ten minutes to complete. Then I logged into my system successfully. There were still some problems with perms on files in my /tmp directory. So I did another uneducated thing and deleted the contents of /tmp. (Well, it sounded better than reinstalling.) There seem to be a few problems with the configuration files in my home directory, but everything is working now and my configurations are mostly preserved. My only problem encountered so far is with my mailer, evolution which I'm in the process of reinstalling now. Looks pretty. healthy otherwise. So how stupid am I?

Glen
 
Old 11-18-2003, 12:45 PM   #7
fyoder
Member
 
Registered: Nov 2003
Posts: 111

Rep: Reputation: 15
"So how stupid am I?"

Not very, that sounds like a really smart recovery. That rpm --setperms trick is something I'll remember in case I ever need it. Thanks.
 
Old 11-23-2003, 12:04 AM   #8
mansonmuni
Newbie
 
Registered: Oct 2003
Distribution: Redhat 9
Posts: 16

Rep: Reputation: 0
Just as an update, I'd like to confirm that the process that I described seems to have been successful. To straighten out my home directory issues, I did the following:

chmod -R u+rwX myhomedirectory
chmod -R go-rwx myhomedirectory

I figured I don't have many executables there, but the few that need executable perms can be set individually if/when the need arises. The only other thing I did by hand was to remove any group or other priveleges from my /etc/ssh/*key* files (chmod go-rwx /etc/ssh/*) This made ssh happy and I'm back to normal as far as I can tell.

Criticisms are welcome. If there is anything I've overlooked please tell me.
 
Old 11-23-2003, 12:16 AM   #9
hazza
Member
 
Registered: Nov 2003
Location: Australia
Distribution: Mandrake, SUSE, Fedora
Posts: 122

Rep: Reputation: 15
Try this as root.

$ for p in `rpm -qa --qf "%{name}\n"`; do rpm --setperms $p; done

Never had to do this myself but it may work.

EDIT:
I didn't see rpm -setperms before I posted. Anyway this will cover anything that's owned by a package but not a lot of files which aren't.

Last edited by hazza; 11-23-2003 at 12:25 AM.
 
Old 11-23-2003, 01:19 AM   #10
hazza
Member
 
Registered: Nov 2003
Location: Australia
Distribution: Mandrake, SUSE, Fedora
Posts: 122

Rep: Reputation: 15
To find files that have the mode 755 on my RH9 system I did:

# rm -f ~/unowned-755-files.lst
# for f in `find / -xdev -type f -perm 755`; do rpm -qf $f >/dev/null 2>&1 || echo $f |tee -a ~/unowned-755-files.lst; done

For my RH9 system it only came up with 3 files in /etc excluding a whole lot of xml files in /etc/gconf/gconf.xml.defaults that shouldn't have this mode. If you try this then do the for loop for each mount point like /usr etc.

Once you have the list of files then you'll have to analyse it manually to see if anything sticks out as having the mode 755 that shouldn't. You'd expect files in the bin directories to be that mode and in the lib directories but not much elsewhere.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Root user unable to rm, mv or chmod Zoar Linux - Newbie 3 10-10-2019 03:12 PM
need to chmod lots o files, without logging in a root Seribicus Linux - Software 6 02-18-2005 12:29 PM
can't chmod under root Kanaflloric Linux - Newbie 10 08-13-2004 11:06 PM
chmod vs chown on some root files and yes apps ergo_sum Linux - Newbie 3 11-12-2003 10:49 AM
Cant access /dev/dsp as anything but root. What do I chmod? JoeLinux Linux - Hardware 4 10-07-2002 09:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration