DelphiFAQ Home Search:
General :: Linux :: shell
Linux shell programming/ scripting, shortcuts and general know-how.


This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

How to set the setuid and setgid bit for files in Unix


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?


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.

// setuid
 chmod 4555   executable_file
 // setgid
 chmod 2555   executable_file

Generated 8:00:37 on Apr 24, 2018