Modifying special permissions for files

Setuid and setgid are two special permissions that are applied to executable files.

If setuid is applied to an executable file, it means that if that file is executed as a program, then it will run as the user of the file and not as the user who ran the program.

Similarly, when setgid is applied to the file, it runs as the group of the file and not as the group that ran the program.

The passwd command has setuid applied by default in Linux systems, as shown in the following screenshot:

The chmod command can be used to add setuid to a script file named myscript,as shown in the following command line:

$ ls -l myscript
$ chmod u+s myscript

or

$ chmod 4755 myscript
$ ls -l myscript

The chmod command can be used to add setgid on a script file named myscript as shown in the following command line:

$ ls -l myscript
$ chmod g+s myscript

or

$ chmod 2755 myscript
$ ls -l myscript
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.198.49