LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 12-12-2006, 10:44 PM   #1
Andriy
Member
 
Registered: Dec 2005
Distribution: Slackware, SLAX, Redhat, Fedora
Posts: 133

Rep: Reputation: 15
Thumbs up 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.
 
Old 12-12-2006, 10:54 PM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
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.
 
Old 12-12-2006, 11:00 PM   #3
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
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
 
Old 12-12-2006, 11:02 PM   #4
Andriy
Member
 
Registered: Dec 2005
Distribution: Slackware, SLAX, Redhat, Fedora
Posts: 133

Original Poster
Rep: Reputation: 15
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.
 
Old 12-12-2006, 11:07 PM   #5
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Yep, I think they wanted you to chown the directory which you where in ( . ) and not /
 
Old 12-12-2006, 11:10 PM   #6
Andriy
Member
 
Registered: Dec 2005
Distribution: Slackware, SLAX, Redhat, Fedora
Posts: 133

Original Poster
Rep: Reputation: 15
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.
 
Old 12-12-2006, 11:16 PM   #7
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Which distro is it?
 
Old 12-12-2006, 11:18 PM   #8
Andriy
Member
 
Registered: Dec 2005
Distribution: Slackware, SLAX, Redhat, Fedora
Posts: 133

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by matthewg42
Which distro is it?
Slackware.
 
Old 12-12-2006, 11:21 PM   #9
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
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
 
Old 12-12-2006, 11:35 PM   #10
Andriy
Member
 
Registered: Dec 2005
Distribution: Slackware, SLAX, Redhat, Fedora
Posts: 133

Original Poster
Rep: Reputation: 15
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?
 
Old 12-13-2006, 12:43 AM   #11
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,398

Rep: Reputation: 2778Reputation: 2778Reputation: 2778Reputation: 2778Reputation: 2778Reputation: 2778Reputation: 2778Reputation: 2778Reputation: 2778Reputation: 2778Reputation: 2778
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.
 
Old 12-13-2006, 03:03 AM   #12
Andriy
Member
 
Registered: Dec 2005
Distribution: Slackware, SLAX, Redhat, Fedora
Posts: 133

Original Poster
Rep: Reputation: 15
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.
 
Old 12-13-2006, 09:35 AM   #13
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
firewall exceptions Murdock1979 Linux - Networking 3 05-05-2006 07:42 AM
Exceptions bianchi Programming 1 11-17-2005 08:36 PM
Regarding Exceptions eshwar_ind Programming 1 05-03-2005 12:23 PM
squidGuard exceptions? twistedpair Linux - Software 1 09-02-2004 04:49 PM
exceptions of Python~ black Programming 2 09-09-2002 05:15 AM

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

All times are GMT -5. The time now is 03:26 AM.

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