help with permissions


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers help with permissions
# 1  
Old 04-08-2003
Question help with permissions

Can anyone help explain the "s" in the below permissions example. I was reading about the "sticky bit" (t) but I am a little confused.

On file "test"

wolf% chmod 4777 test
wolf% ls -l
total 4
drwx------ 2 john staff 512 Mar 19 21:34 nsmail
-rwsrwxrwx 1 john staff 332 Apr 7 11:28 test

and/or

wolf% chmod 2777 test
wolf% ls -l
total 4
drwx------ 2 john staff 512 Mar 19 21:34 nsmail
-rwxrwsrwx 1 john staff 332 Apr 7 11:28 test


To Sum: please help explain the "#" in chmod (#)xxx file and it's affect.

Thanks.

Smilie
# 2  
Old 04-08-2003
Aside from read, write, and execute (rxw), Unix also understands three specialty permissions that allow us to fine-tune the default permissions.

From onlamp.com:
Quote:
Unix also understands three specialty permissions that allow us to fine-tune the default permissions. The first specialty permission is called the SUID, or set user id bit. If you do a long listing, and see either an s or an S instead of an x in the owner section of the permissions, this bit has been set.

The SUID bit allows a user to temporarily gain root access, usually in order to run a program. For example, only the root account is allowed to change the password information contained in the password database; however, any user can use the passwd utility to change their password. Let's do a long listing on the passwd command to see why:

whereis -b passwd
passwd: /usr/bin/passwd
ls -l /usr/bin/passwd
-r-sr-xr-x 2 root wheel 26260 Jul 26 23:12 /usr/bin/passwd
^
Because the SUID bit has been set on the passwd utility, it will become root in order to modify the password database, allowing the user to change their password.

If the SUID bit appears as an s, the file's owner also has execute permission to the file; if it appears as an S, the file's owner does not have execute permission.

The second specialty permission is the SGID, or set group id bit. It is similar to the SUID bit, except it can temporarily change group membership, usually to execute a program. The SGID bit is set if an s or an S appears in the group section of permissions. An example of a file with the SGID bit set is netstat:

ls -l /usr/bin/netstat
-r-xr-sr-x 1 root kmem 84448 Jul 26 23:12 /usr/bin/netstat
^
Since netstat's SGID bit is set with an s instead of an S, execute permission has also been set.

The third specialty permission is the directory sticky bit. This bit is essential if you have a directory that is used by more than one user. Remember the permissions for your home directory?

ls -la ~
drwxr-xr-x 12 genisis wheel 1024 Aug 15 11:34 .
The owner has full access to the directory, but all other users, including members of the owner's primary group, only have rx. Only the owner will be able to create and delete files from his home directory, which is a good thing.

However, these permissions aren't suitable for a shared directory where many users have to be able to create, modify, and possibly remove files from the directory. If you create a directory and give either a group or everyone write access to the directory, users will be able to create and modify files within the directory.

Unfortunately, write access to a directory also means that users can delete any file within the directory, even if they don't own the file. This is not nice, especially considering that once a file is deleted in Unix, it is gone forever.

This is where the directory sticky bit comes in. This bit is set if a t or a T appears instead of an x in the everyone section of permissions like so:

drwxrwxrwt
When the directory sticky bit is set, users will still be able to create and modify files within the directory, but they will only be able to delete files which they themselves created.
Here's a link that will explain more about these special permissions.
Quote:
Using the symbolic method we have:

chmod u+s - set the setuid bit.
chmod g+s - set the setgid bit.
chmod u+t - set the sticky bit or directories

or numerically:

chmod 4777 - setuid and read/write/execute for everyone.
chmod 2777 - setgid and read/write/execute for everyone.
chmod 1777 - set sticky bit and read/write/passthrough on a directory.

You can, of course, add the numbers up to combine permissions:

chmod 6777 - setuid/setgid and read/write/execute for everyone.
# 3  
Old 04-09-2003
Thank you very much!!......This board is great. ...........thanks for the help.

Thanks for the great link as well......
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Permissions

Hi guys, i write the below script to make the user get to the directory that interesting. Now what I am trying is to check the permissions of the directory and if the directory exists to check the reading options. echo "Please enter your desire folder directory ( \yourfolders) ?: \c" ... (9 Replies)
Discussion started by: mikerousse
9 Replies

2. UNIX for Dummies Questions & Answers

Permissions

Hi, I have noticed that on my Linux box there is a nice feature which make it impossible for specified member (owner, group or other) to have an given access if a member from which we would expect it more don't have that access. So it is impossible to read file by all if others have set read... (3 Replies)
Discussion started by: DavidMax
3 Replies

3. Shell Programming and Scripting

ksh; Change file permissions, update file, change permissions back?

Hi, I am creating a ksh script to search for a string of text inside files within a directory tree. Some of these file are going to be read/execute only. I know to use chmod to change the permissions of the file, but I want to preserve the original permissions after writing to the file. How can I... (3 Replies)
Discussion started by: right_coaster
3 Replies

4. Shell Programming and Scripting

permissions

My /tmp is set with the following permissions (777) and a 't' at the end. My umask is set to 022. When I create a directory under /tmp (tmp/xx) it gets created as 755 as expected. Yet when I create a file within that directory (/tmp/xx/yy) the permissions are not 755 they are 644. ... (1 Reply)
Discussion started by: BeefStu
1 Replies

5. HP-UX

To give the "unzip" permissions & "create" file permissions

Hi, I am a Unix Admin. I have to give the permissions to a user for creating new file in a directory in HP-Ux 11.11 system since he cannot able to create a new file in the directory. Thanks in advance. Mike (3 Replies)
Discussion started by: Mike1234
3 Replies

6. UNIX for Dummies Questions & Answers

permissions

to prohibit 'others' from deleting files, what should we omit: write or execute? thx (9 Replies)
Discussion started by: melanie_pfefer
9 Replies

7. HP-UX

Permissions

Hey, We've got quite a strange problem on our hands here. We are running an HP 9000/800 B.11.00. I've just created a new group in /etc/group which i called, let's say newgroup . Then I added 4 users to the group, namely user1, user2, user3, user4 . The command grpchk shows no strange things... (4 Replies)
Discussion started by: chrizz
4 Replies

8. UNIX for Dummies Questions & Answers

permissions

I saved a perl code in xemacs. I used an xterminal to execute it but unix said that I don't have permission. I saved the files in my home directory. How do I change the permission. This is hat unix said: -ksh: ./names.pl: cannot execute (5 Replies)
Discussion started by: lnatz
5 Replies

9. UNIX for Dummies Questions & Answers

Permissions

Hi everyone, I'm looking for some information concerning Unix permissions. I am new to Unix and am doing research for a graduate class. Given the permissions below, can anyone give me five unique exploits that would be available to a hacker/cracker given this configuaration? -rw-rw-rw- 1... (1 Reply)
Discussion started by: skeeter
1 Replies

10. UNIX for Dummies Questions & Answers

permissions

with permission set to d-wx--x--x directoryname Why can't I do a long-listing on this directory? Is read access necessary? (1 Reply)
Discussion started by: mma_buc_98
1 Replies
Login or Register to Ask a Question