LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 05-30-2011, 12:22 AM   #1
Soji Antony
Member
 
Registered: Jul 2010
Posts: 54

Rep: Reputation: 1
suid & sgid on directories


Hi

I'm having a bit of a problem with the suid and sgid feature in a directory. I read somewhere that

Quote:
When [the suid bit is] set on a directory, all the files and directories created within this directory will have the same owner as the SUID-directory itself, no matter who created the file.
But it does not seem to be working
Code:
arun~]$mkdir /tmp/abc
chmod u+s /tmp/abc
ls -ld /tmp/abc 
drwsrwxrwx 2 arun arun  4096 May 29 20:14 /tmp/abc
But when a user 'tom' go to the directory /tmp/abc, and create a file.
Code:
cd /tmp/abc
touch 1.txt
ls -l 1.txt
-rw_rw_r__ 1 tom tom 0 May 29 20.24 1.txt
As you can see, the new file is owned by tom instead of arun. Please help ...

Last edited by Soji Antony; 05-30-2011 at 12:27 AM.
 
Old 05-30-2011, 01:02 AM   #2
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hello,

The SUID bit is set on files, mainly scripts, to make them run as the user who is the owner of the script rather than the one who started the script.

The same applies for the SGID bit. If the SGID on a file is set then it will run with the privileges of the files group owner, instead of the privileges of the user executing it. You can also set SGID to directories so that any files created by any users in this directory will inherit the group permissions.

So basically setting a SUID on a directory has no effect for as far as file creation is concerned whereas SGID does what you need.

If you want to use SGID, then create a special group and make the necessary users member of that group.

Kind regards,

Eric
 
1 members found this post helpful.
Old 05-30-2011, 01:12 AM   #3
Soji Antony
Member
 
Registered: Jul 2010
Posts: 54

Original Poster
Rep: Reputation: 1
Hi Eric

Thank you so much for your reply.....
 
Old 05-30-2011, 01:24 AM   #4
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hi,

You're welcome! Have fun with Linux.

Kind regards,

Eric
 
  


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
SGID and SUID Paris Heng Linux - General 2 11-08-2008 09:45 PM
which suid sgid to unset? hank43 Linux - Security 1 10-09-2006 01:46 AM
Eliminating SUID & SGID? ridertech Linux - Security 4 07-08-2004 05:58 PM
shell variables &suid&sgid alaios Linux - General 6 05-23-2003 04:03 PM
SGID and SUID on Directories mikeyt_333 Linux - General 1 03-26-2002 02:41 PM

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

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