LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 01-26-2005, 04:17 AM   #1
Xzanron
LQ Newbie
 
Registered: Dec 2004
Location: London, UK
Distribution: Mandriva 2005 LE
Posts: 11

Rep: Reputation: 0
How to selectively change permissions


I'm wondering how to selectively change permissions.

After creating a new user, i suddenly found that a lot of things in /dev had changed owners to the new user... important things like /dev/hdc etc.

I want to change the permissions of all those files that have changed back to root, without changing all files to root.

basically... i want to execute the following command on all files in the directory.

if user==user1 then chgrp root file

hope that makes sense.

Is there a quick way to do this... or should I start puzzling out shell scripts?

Thanks a lot
 
Old 01-26-2005, 04:23 AM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
Before you go do all of that, verify that the permission changes aren't intentional. Some distributions will automatically change the owners of device files when a user logs in to allow that user to mount the device (like /dev/fd0, or cdrom drives, etc.). If you see the "owner" keyword in /etc/fstab for those devices, this is probably what's happening.

So log out with the new user, and log in with another, and check the ownerships of the devices. If they change to the current user logged in, then it'd be best to just leave them be; it's all being taken care of for you. If the deivices are still owned by the new user, then I can help you with a find command that will revert them back to root.
 
Old 01-26-2005, 07:38 AM   #3
Xzanron
LQ Newbie
 
Registered: Dec 2004
Location: London, UK
Distribution: Mandriva 2005 LE
Posts: 11

Original Poster
Rep: Reputation: 0
What happens if you have two users logged in at once then? I thought the whole point of groups was so that you didn't have to do something as silly as that.

And if you assign it to a different user each time they log in why not just give permissions to all users?

I'll check my fstab.. but if that is really happening then i think I'll need to change it.
 
Old 01-26-2005, 07:40 AM   #4
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 61
I see the same thing happening in /dev on my PC, and I totally agree with Xzanron: this is silly, and needs to be changed.
 
Old 01-26-2005, 12:39 PM   #5
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
Well, chances are slim you will have two users logged into the machine directly. I mean, there's only one keyboard, one mouse, one monitor... Users logged in from another location (via ssh, ftp, etc.) don't have physical access to the machine. It wouldn't make sense to give them mount capability for devices. The only way you could have two users logged in locally to the same system is through virtual terminals. I honestly don't know how that would be handled. It may be first-come-first-served... dunno.

I'm not saying I agree with this methodology, but there is logic behind it.

As for changing it, I'm not sure. My first guess would be to look for a file in /etc. Something like:
Code:
grep -lr "chown" /etc/*
Whatever it is that's changing ownership has to run after login, which means it's not a startup script (unless it's being run as a daemon). So that command may not turn up anything unless a shell script is used, or the configuration file is extremely straightforward.

Other than that, I'd check your distros website/faq/whatever. It might be addressed there.
 
Old 01-26-2005, 01:20 PM   #6
LasseW
Member
 
Registered: Oct 2004
Distribution: Fedora 7, OpenSuse 10.2
Posts: 108

Rep: Reputation: 15
No need for a script, you can do it with one command:

find . -user user1 -exec chgrp root {} \;

This will affect everyting in the default directory and its subdirectories recursively. There are numerous ways to add more selection criteria for the find command. Do 'man find' for details.
 
Old 01-26-2005, 01:42 PM   #7
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
Actually, it would need to be:
Code:
find . -user user1 -exec chown root {} \;
However, like was mentioned, if the device file ownerships are being changed at login, then that command will only last until someone else logs in. It's addressing the symptoms; not the cause.
 
Old 01-26-2005, 06:30 PM   #8
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
I haven't found an answer but did come across a decent lead. I noticed Xzanron and theYinYeti show Mandrake 10 as their distribution.

I went to Mandrake's site to poke around. The FAQ didn't look like it would even come close to answering the question. Then, in the command-line documentation, there was a reference that Mandrake uses DevFS, and a link to an outside doc.
Mandrake Document
DevFS FAQ

There is a section named "Permissions persistence across reboots" and talks about a devfs configuration file. It sounds like it might be what you want, but I don't have devfs, and can't tinker with it to know for sure.

Like I said, it may not be the answer, but it's a decent place to start looking.
 
Old 01-31-2005, 09:59 AM   #9
Xzanron
LQ Newbie
 
Registered: Dec 2004
Location: London, UK
Distribution: Mandriva 2005 LE
Posts: 11

Original Poster
Rep: Reputation: 0
Thanks a lot for all your help.

I really like the find command. Didn't realise it could do searches by username as well. Learn something new each day.
 
  


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
Can you untar selectively? stefaandk Linux - Newbie 1 06-14-2005 11:15 PM
Selectively 'waiting' in a shell script subu_s Programming 2 12-20-2004 06:57 AM
How to change permissions? SonoranFun Linux - Newbie 4 11-02-2004 11:10 AM
cd rom drive selectively seeing CD's mat_uk111 Linux - Newbie 4 10-29-2004 11:11 AM
Program that can selectively download email? oot Linux - Software 2 01-03-2004 12:47 AM


All times are GMT -5. The time now is 06:04 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration