omnisecu.com free mcse ccna rhce linux java learning  
Home Knowldege Base FAQ Contact Us Sitemap
omnisecu.com free mcse ccna rhce linux java learning  
omnisecu.com free mcse ccna rhce linux java learning
Home » Knowledge Base » Linux » RedHat Certified Engineer (RHCE) » Linux setuid and setgid
 

Linux setuid and setgid

 

The Linux Files can be setuid or setgid. When a user executes a setuid file, the program runs with the effective user ID of the file’s owner, rather than that of the user. Similarly, when a user executes a setgid file, the program runs with the effective group ID of the file’s group owner, rather than that of the user.

Directories can also be setgid. When a user creates a file in a non-setgid directory, the group ownership of the file is set to the user’s group ID. However, when a user creates a file in a setgid directory, the group ownership of the file is set to the group owner of the directory.

To enable setuid you can use Linux chmod command as shown below.

chmod u+s file_name

Example:

[root@RHEL2 setuidtest]# ls -l
total 0
-rwxr--r-- 1 root root 0 Jul 6 07:34 setuidtest
[root@RHEL2 setuidtest]# chmod u+s setuidtest
[root@RHEL2 setuidtest]# ls -l
total 0
-rwsr--r-- 1 root root 0 Jul 6 07:34 setuidtest
[root@RHEL2 setuidtest]#

To disable setuid you can use Linux chmod command as shown below.

Example:

chmod u-s file_name

[root@RHEL2 setuidtest]# ls -l
total 0
-rwsr--r-- 1 root root 0 Jul 6 07:34 setuidtest
[root@RHEL2 setuidtest]# chmod u-s setuidtest
[root@RHEL2 setuidtest]# ls -l
total 0
-rwxr--r-- 1 root root 0 Jul 6 07:34 setuidtest
[root@RHEL2 setuidtest]#

To enable setgid you can use Linux chmod command as shown below.

chmod g+s file_name

Example:

[root@RHEL2 setgidtest]# ls -l
total 0
-rwxrwxr-- 1 root root 0 Jul 6 08:13 setgidtest
[root@RHEL2 setgidtest]# chmod g+s setgidtest
[root@RHEL2 setgidtest]# ls -l
total 0
-rwxrwsr-- 1 root root 0 Jul 6 08:13 setgidtest
[root@RHEL2 setgidtest]#

To enable setgid you can use Linux chmod command as shown below.

chmod g-s file_name

Example:

[root@RHEL2 setgidtest]# ls -l
total 0
-rwxrwsr-- 1 root root 0 Jul 6 08:13 setgidtest
[root@RHEL2 setgidtest]# chmod g-s setgidtest
[root@RHEL2 setgidtest]# ls -l
total 0
-rwxrwxr-- 1 root root 0 Jul 6 08:13 setgidtest
[root@RHEL2 setgidtest]#

Note: Also Octal values 4 and 2 can be used for setuid and setgid respectively.

 

Related Topics...

The Linux File Permissions

How to use chmod command to change Linux file permissions

How to use chgrp command to change Linux group ownership of a file

How to use chown command to change linux user ownership of a file

What is Linux umask?

 


eXTReMe Tracker

back
next
 
Disclaimer | Feed Back | Trademarks | Knowledge Base | FAQ | Sitemap | Downloads