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 |
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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
|
12-12-2006, 10:44 PM
|
#1
|
Member
Registered: Dec 2005
Distribution: Slackware, SLAX, Redhat, Fedora
Posts: 133
Rep:
|
How to chown with exceptions?
Ok. So I was trying to learn mysql and the book I was reading requires me to do a: 'chown -R root .' apparently upon doing that, I realized that the configurations for the current user that i was logged into shows a few erratic behaviour, particularly with the desktop background being lost and areas unaccessible etc. etc. Of course I knew right away that it was a permission problem. Now what I did was to chown -R [user] again to revert temporarily ( I know it's not the best solution but I'll get back to that later). Now I want to correct it but I don't know what syntax should be used with 'chown' that excludes the /home/user when changing the root directory to 'root'. i have browsed through the man pages and i can't find such syntax. or am i just confused? i hope anyone can help. thank you very much.
|
|
|
12-12-2006, 10:54 PM
|
#2
|
Senior Member
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530
Rep:
|
The -R option to chown is recursive from where you executed it, and you can't omit directories by name AFAIK (see --from info below). If the argument is ".", as you said, it depends which directory you executed it from because "." means "the current working directory".
There is the option --from=CURRENT_OWNER:CURRENT_GROUP, which only changes ownership where the old owner and group are as specified, which might help.
Other than that, you could use the find command to list all the file you want, and then use xargs to change the ownership. Find gives excellent possibilities to make complex rules about what you want to include/omit.
|
|
|
12-12-2006, 11:00 PM
|
#3
|
Senior Member
Registered: Oct 2003
Posts: 3,057
Rep:
|
I never felt a need to chown / or did you mean /root ?
You could go ahead with the chown for root , then run chown for the user's directory...
chown -R root:root /
chown -R fred:fred /home/fred
|
|
|
12-12-2006, 11:02 PM
|
#4
|
Member
Registered: Dec 2005
Distribution: Slackware, SLAX, Redhat, Fedora
Posts: 133
Original Poster
Rep:
|
Ok. I guess I misunderstood what the '.' means. I thought it was root directory and its subfolders. I'll keep that answer at bay just in case it came in handy. For the meantime, I'll resume my mysql studies. Thank you very much.
|
|
|
12-12-2006, 11:07 PM
|
#5
|
Senior Member
Registered: Oct 2003
Posts: 3,057
Rep:
|
Yep, I think they wanted you to chown the directory which you where in ( . ) and not /
|
|
|
12-12-2006, 11:10 PM
|
#6
|
Member
Registered: Dec 2005
Distribution: Slackware, SLAX, Redhat, Fedora
Posts: 133
Original Poster
Rep:
|
hmm. what's the default permission settings for most of the common (or shared if you wish) locations such as /tmp which is used by most users. I think i did a mistake by entering chown -R root . on the root directory. Now, i am reverting it back to its original permissions.
Last edited by Andriy; 12-12-2006 at 11:13 PM.
|
|
|
12-12-2006, 11:16 PM
|
#7
|
Senior Member
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530
Rep:
|
Which distro is it?
|
|
|
12-12-2006, 11:18 PM
|
#8
|
Member
Registered: Dec 2005
Distribution: Slackware, SLAX, Redhat, Fedora
Posts: 133
Original Poster
Rep:
|
Quote:
Originally Posted by matthewg42
Which distro is it?
|
Slackware.
|
|
|
12-12-2006, 11:21 PM
|
#9
|
Senior Member
Registered: Oct 2003
Posts: 3,057
Rep:
|
I wouldn't worry about /tmp too much as that can be emptied in runlevel 1 .
The directory /var might give you some trouble...
Code:
cd /var
# ls -al
total 172
drwxr-xr-x 21 root root 4096 Oct 27 08:02 .
drwxr-xr-x 24 root root 4096 Dec 12 17:55 ..
drwxr-xr-x 2 root root 4096 Oct 27 07:59 account
drwxr-xr-x 9 root root 4096 Oct 27 08:08 cache
drwxr-xr-x 3 root root 4096 Oct 27 07:59 db
drwxr-xr-x 3 root root 4096 Oct 27 07:59 empty
drwxr-xr-x 2 root root 4096 Oct 10 18:06 games
drwxrwx--T 2 root gdm 4096 Dec 12 18:20 gdm
drwxr-xr-x 20 root root 4096 Dec 8 23:13 lib
drwxr-xr-x 2 root root 4096 Oct 10 18:06 local
drwxrwxr-x 5 root lock 4096 Dec 12 17:55 lock
drwxr-xr-x 7 root root 4096 Dec 12 17:55 log
lrwxrwxrwx 1 root root 10 Oct 27 07:56 mail -> spool/mail
drwxr-x--- 5 root named 4096 Dec 8 23:15 named
drwxr-xr-x 2 root root 4096 Oct 10 18:06 nis
drwxr-xr-x 2 root root 4096 Oct 10 18:06 opt
drwxr-xr-x 2 root root 4096 Oct 10 18:06 preserve
drwxr-xr-x 2 root root 4096 Oct 1 16:23 racoon
drwxr-xr-x 15 root root 4096 Dec 12 23:55 run
drwxr-xr-x 8 root root 4096 Oct 27 21:19 spool
drwxrwxrwt 4 root root 4096 Dec 12 19:19 tmp
drwxr-xr-x 3 root root 4096 Dec 1 16:07 yp
|
|
|
12-12-2006, 11:35 PM
|
#10
|
Member
Registered: Dec 2005
Distribution: Slackware, SLAX, Redhat, Fedora
Posts: 133
Original Poster
Rep:
|
hmmm...as far can i can see and compare with your /var, my only problem is the /var/lock and /var/named that is in the group root. how do i revert them back to group lock and named?
|
|
|
12-13-2006, 12:43 AM
|
#11
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,398
|
Use
chown root:lock lock
when you are in /var, and similarly for named.
HOWEVER, if you did that original chown -R from the system root dir ie '/', then to be honest, I'd seriously consider a re-install, because you will have changed hundreds if not thousands of dirs/files (ie the entire system) and it's not worth trying to straighten it out manually.
There'll always be one you missed and strange failures will occur.
It's your choice of course.
|
|
|
12-13-2006, 03:03 AM
|
#12
|
Member
Registered: Dec 2005
Distribution: Slackware, SLAX, Redhat, Fedora
Posts: 133
Original Poster
Rep:
|
I guess a reinstallation would be alright. I have separate partitions ready in case something bad happened like this. Thank you very much for the help.
|
|
|
12-13-2006, 09:35 AM
|
#13
|
Senior Member
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530
Rep:
|
There may be some tool for re-setting ownership of all the system files/directories. I vague remember something like that with SuSE ages and ages ago which would set the permissions and ownership according to some security policy (there was a strict one, and a relaxed one). I don't remember the name though.
Tracking it down and working out how to run it may well be more of a pain than just re-installing though.
|
|
|
All times are GMT -5. The time now is 03:26 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|