LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-17-2005, 12:17 PM   #1
Mike Gibson
LQ Newbie
 
Registered: Feb 2005
Posts: 6

Rep: Reputation: 0
I have messed up system directory ownerships


I have done something rather foolish - albeit by accident damn the chown command.

I have managed to change the ownership on all files and directories under / to root:root - i.e. owned by root user and root group.

I have restored ownership of user files, i.e. stuff under /home to their rightful owners/groups and the same for but ...

I believe that some system directories/files (/usr, /dev, ...) whilst perhaps owned by the root user are "owned" by system groups other than root - e.g. bin, disk etc.

This is listing of my / directory:

$ ls -al /
total 233
drwxr-xr-x 22 root root 4096 Feb 15 18:56 .
drwxr-xr-x 22 root root 4096 Feb 15 18:56 ..
-rw-r--r-- 1 root root 0 Feb 15 18:56 .autofsck
drwxr-xr-x 2 root root 4096 Aug 26 21:43 bin
drwxr-xr-x 4 root root 1024 Feb 15 16:33 boot
drwxr-xr-x 4 root root 4096 Feb 15 10:26 data1
drwxr-xr-x 3 root root 4096 Aug 26 21:40 data2
drwxr-xr-x 22 root root 118784 Feb 15 18:59 dev
drwxr-xr-x 63 root root 8192 Feb 17 14:09 etc
-rw-r--r-- 1 root root 51 Aug 26 22:06 .fonts.cache-1
drwxr-xr-x 6 root root 4096 Feb 17 13:42 home
drwxr-xr-x 2 root root 4096 Jan 24 2003 initrd
drwxr-xr-x 11 root root 4096 Aug 26 21:49 lib
-rw-r--r-- 1 root root 9598 Feb 8 14:49 log
drwx------ 2 root root 16384 Aug 26 21:39 lost+found
drwxr-xr-x 2 root root 4096 Nov 11 18:16 misc
drwxr-xr-x 3 root root 4096 Aug 26 22:05 mnt
drwxr-xr-x 6 root root 4096 Feb 16 18:47 opt
dr-xr-xr-x 86 root root 0 Feb 15 18:55 proc
drwxr-x--- 16 root root 4096 Feb 17 14:09 root
drwxr-xr-x 2 root root 8192 Feb 8 14:45 sbin
drwxrwxrwt 17 root root 4096 Feb 17 17:41 tmp
drwxr-xr-x 15 root root 4096 Feb 8 14:45 usr
drwxr-xr-x 24 root root 4096 Feb 4 14:53 var
drwxr-xr-x 2 root root 4096 Feb 8 14:45 view
$

Whilst the system seems to be stable now, I am concerned that on reboot it will fall appart.

Does anyone have a listing of the ownerships of the system dircetories and contents so that I can put the proper (original default) ownerships back in place? or, is the fact that these are owned by root sufficient that this will not be an issue?

Thanks
 
Old 02-17-2005, 12:46 PM   #2
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
It'll probably be an issue at some point, though I don't think it will cause MASSIVE problems. Certain apps may cease to function (cd writing, etc.) if you use devfs or udev, I believe your /dev permissions will be restored automagically upon reboot.

So long as no chmod errors were involved, you should be ok.
 
Old 02-17-2005, 12:53 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Hi Mike, and welcome to LQ!

Depending on your distro there may be a reasonably
easy way to restore the perms to their original settings.
Which distro are you using?


Cheers,
Tink
 
Old 02-17-2005, 01:19 PM   #4
Mike Gibson
LQ Newbie
 
Registered: Feb 2005
Posts: 6

Original Poster
Rep: Reputation: 0
I am running Red Hat Enterprise 3 ES Update 4 if that is what you mean - sorry lots of new terminology for me!

Mike
 
Old 02-17-2005, 01:58 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
That is indeed what I meant :)

Look here



Cheers,
Tink
 
Old 02-17-2005, 02:45 PM   #6
Mike Gibson
LQ Newbie
 
Registered: Feb 2005
Posts: 6

Original Poster
Rep: Reputation: 0
I think what this script does is reset permissions on the files to the original permissions defined in the rpm package. My problem isn't permissions but ownership. I guess that I could use this script as the basis for doing the same thing but doing a chown rather than chmod?

Mike
 
Old 02-17-2005, 04:29 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Heh, sorry ... and you're right!

Took me a while to half-way understand spawny's
script ... have a look at the output of this one on
your machine. I don't have an rpm-based installation
so have a bit of difficulty to see what it does. ;)

Code:
#!/bin/bash
# Purpose: Restore filesystem ownerships from RPM database
#            distro's that don't do package management suck major.
#            *Make sure yer RPM database is sane...
# Args: none or package name
# Deps: Bash, GNU utils, rpm
# Run from: manual, emergency only

case "$#" in
0) rpmopt="a"; unset pkg;;
*) unset rpmopt; pkg="$1";;
esac

rpm -q${rpmopt} --dump ${pkg}|while read t; do
        t=( ${t} );
        echo "${t[5]:0:7}:${t[6]:0:7} ${t[0]}";
done
The bits in red are definitely untested (I just installed
ONE test rpm, all files owned by root and it displayed
something that made sense to me ...

Code:
:~/tmp4]$ ./rpm-perms 
root:root /usr/include/bibtex.h
root:root /usr/lib/libbibtex.a
root:root /usr/lib/libbibtex.la
root:root /usr/lib/libbibtex.so
Now running something like:
Code:
/tmp/rpm-perms|while read owners file; do chown ${owners} ${file}; done
should work as it would for the perms ...


Cheers,
Tink

Last edited by Tinkster; 02-18-2005 at 12:14 PM.
 
Old 02-18-2005, 03:07 AM   #8
Mike Gibson
LQ Newbie
 
Registered: Feb 2005
Posts: 6

Original Poster
Rep: Reputation: 0
Many thanks I will give it a try.
 
Old 02-21-2005, 07:12 PM   #9
danieljames
Member
 
Registered: Jan 2005
Location: New South Wales, Australia
Distribution: SuSE and Ubuntu
Posts: 31
Blog Entries: 2

Rep: Reputation: 15
g'day Mike

I am hoping you can help me. How did you use chown to change ownership to all files at once. I made a mistake to . . . somehow I changed the ownership of everything in my personal home to another user when I was in root mode. I want to change all ownerships back but it is tedious chaging each one individually, what did you do to chage everything in a directory at once?
 
Old 02-21-2005, 07:19 PM   #10
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
Shell wildcards ... chown user * will change every file in the directory, add -R to make it recursive (does subdirectories too). Be carefull -- as this thread indicates, you can do bad things to your system by misusing these.
 
Old 02-21-2005, 10:13 PM   #11
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
And if it's more or less all in your users home...

chown -R user /home/user


Cheers,
Tink
 
Old 02-22-2005, 12:42 PM   #12
Mike Gibson
LQ Newbie
 
Registered: Feb 2005
Posts: 6

Original Poster
Rep: Reputation: 0
I certainly echo the "be careful". I hit the problem of "unexpected" results because there are a large number of "hidden" files and directories in your yome with names the begin with a dot (.).

Without thinking I did - chown -R * ...... no problem, followed by
chown -R .* ..... sadly this includes ".." ... my problems began!
 
Old 02-22-2005, 12:46 PM   #13
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Did the modfied script work for you, btw?


Cheers,
Tink
 
Old 02-23-2005, 11:10 AM   #14
Mike Gibson
LQ Newbie
 
Registered: Feb 2005
Posts: 6

Original Poster
Rep: Reputation: 0
Yes indeed thanks. It is now safely stored away for future use - I hope not!
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
file system messed up, help! eaglegst Debian 3 08-31-2005 06:14 PM
I messed up my mysql file ownerships whatnoname Linux - Software 2 06-07-2005 07:33 AM
Unix ownerships got messed(very urgent please).. mahamkali Linux - Security 1 01-02-2005 01:50 AM
Perl has messed up my system..Can anyone help? midgcool Linux - Software 2 12-05-2004 10:34 AM
Help! I messed up my system with a kernel compile chris26 Slackware 6 11-28-2003 04:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:02 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