EXPLAIN: What is ‘Setuid’ or ‘SUID’?
Setuid or SUID is a permission bit that can be set on a file or directory. I’m going to refer to suid for the remainder of this entry, but both phrases are interchangeable.
Setting the suid bit on a file allows normal users to run that application with raised (usually superuser) priviledges. Remember that when a user launches an application, that application runs with the same permissions as that user. This is one of the fundamental differences between Windows and *nix systems. In a *nix system a normal user does not have access to system files and therefore neither does any application (or virus or malware) that they may have launched.
An example of a file that has the suid bit set in most cases is the /usr/bin/passwd application. You can see that the /usr/bin/passwd application has the suid bit set by the letter s in place of the user’s eXecutable bit.
-rwsr-xr-x 1 root root 26680 May 10 13:44 passwd
The passwd application allows users to change their own passwords. In order to do so, it has to write to the etc/passwd file which contains all of the accounts on a GNU/Linux system. However, if the suid bit was not set on the passwd application then the passwd application would only have the rights of the user and therefore could not make changes to the etc/passwd file. Setting the suid bit on the passwd application allows it to run as the superuser and it can therefore write the new password to the etc/passwd file.
How to set the suid bit?
Use the number 4 in front of a normal chmod string: chmod 4777 test will make test world r/w/x and set the suid bit.
Related Stories
POSTED IN: Explanation
7 opinions for EXPLAIN: What is ‘Setuid’ or ‘SUID’?
Neodymium
Nov 20, 2005 at 4:47 am
Aha, this was just what I was looking for. Thanks! :D
Jon
Nov 20, 2005 at 7:33 pm
Glad I could help :)
kk
Dec 12, 2005 at 2:19 am
I want to know about AIX based book
I’m new in AIX, how to learn about AIX
kk
Dec 12, 2005 at 2:54 am
I’m trying to run a shell script file but getting following errors
The file access permissions do not allow the specified action.
testdrop.sh[12]: /run.time: 0403-005 Cannot create the specified file.
The file access permissions do not allow the specified action.
testdrop.sh[13]: /DROP_TABLES_CPM_A1_01.bak: 0403-005 Cannot create the specified file.
The file access permissions do not allow the specified action.
testdrop.sh[55]: /DROP_TABLES_CPM_A1_01.err: 0403-005 Cannot create the specified file.
rm: /DROP_TABLES_CPM_A1_01.bak: A file or directory in the path name does not exist.
Pls Help Me
titikaka
Nov 2, 2006 at 3:58 pm
Very precise and good explanation. :)
pankaj
Nov 1, 2007 at 9:09 pm
Well explained!!but still a bit confused…
DMonter
Jul 6, 2008 at 5:03 am
I have these two files in my RHEL5 /home/user1
-rws—— 1 root root 18 Jul 6 19:42 test
-rwsrwxrwx 1 root root 36 Jul 6 19:44 test2
Both test and test2 are script files which contain…
test:
/bin/echo “Test1″
test2:
/bin/echo “Test2″
sh test
After I logged in as user1, why I cannot run test2 (# sh test2) with the following output??
# sh test2
Test2
Test1
but the following output…
# sh test2
Test2
sh: test: Permission denied
Pls kindly help me…
Have an opinion? Leave a comment: