Linux Apache (6) Network (11) shell (12)
Exchange Links About this site Links to us 
|
How to set the setuid and setgid bit for files in Unix
2 comments. Current rating: (1 votes). Leave comments and/ or rate it.
Question: I need to set setuid and setgid bit for files.
Please show me how to. And what is the exact purpose of the uid bit?
Answer: In the shell just type the commands shown in the box below to set the uid or gid bits.
The purpose of the uid bit:
If you change an executable file to have the setuid bit set then when any other user runs this executable the effective user ID of the process will be switched to the user that owns the file.
The same way, if you set the gid bit, then the process will be executed under the group of the file. You have to be very careful with this feature as one can easily create a hard-to-spot security whole with it.
The purpose is usually to give the executable file the ability to write to a certain file - e.g. a log file - that the regular user cannot write to. When it runs under the owner's ID, it can write to that file.
Having the process execute under a different user id has some other side effects for example coredumps are disabled and the C runtime library ignores or deletes some environment variables.
 | |  | | chmod 4555 executable_file
chmod 2555 executable_file | |  | |  |
Comments:
|
anonymous from United Kingdom
|
 |
|
|
|
|
anonymous from India
|
|
|
|
very helpful
|
|