Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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?
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 ...
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?
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.
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!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.