Linux/Filesystems permissions

File system permissions controls the ability of the users to view, change, navigate, and execute the contents of the file system.

ObjetivesEdit

  • Understand and format file systems
  • Understand file systems permissions
  • Understand setuid and setgid bits
  • Learn chmod commands: chmod ug+s


SetuidEdit

setuid and setgid (short for "set user ID" and "set group ID")[1] are Unix access rights flags that allow users to run an executable with the permissions of the executable's owner or group respectively and to change behaviour in directories. The setuid and setgid flags only have effect on binary executable files. Set these bits on scripts, like bash, perl or python do not have any effect.[1]

chmod examplesEdit

chmod ug+s file.txt

Before:
ls -la file.txt
-rwxr-xr-x   1 root         root    31 Nov 27 11:34 file.txt

stat file.txt
  File: file.txt
  Size: 31        	Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d	Inode: 13          Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2019-11-27 11:34:54.610196393 +0400
Modify: 2019-11-27 11:34:49.662193415 +0400
Change: 2019-11-27 11:34:49.666193418 +0400
 Birth: -

chmod ug+s file.txt

After:
ls -la file.txt
-rwsr-sr-x 1 root root 31 Nov 27 11:34 file.txt

stat file.txt
  File: file.txt
  Size: 31        	Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d	Inode: 13          Links: 1
Access: (6755/-rwsr-sr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2019-11-27 11:34:54.610196393 +0400
Modify: 2019-11-27 11:34:49.662193415 +0400
Change: 2019-11-27 12:11:20.637362248 +0400
 Birth: -

Hidden and system attributesEdit

Linux does not regard file systems' hidden and system attributes like Windows does. Instead, file and directory entry names starting with a dot (.) are considered hidden, and can optionally be set to be revealed in file managers and command line tools.

See alsoEdit

  1. https://books.google.ae/books?id=aOh1DwAAQBAJ&pg=PA250&lpg=PA250&dq=Setuid+has+no+effect+on+bash&source=bl&ots=s1hrhguPH6&sig=ACfU3U1F6LEF5JpVIsE71yL8jRHJFbeEvg&hl=en&sa=X&ved=2ahUKEwiYgvj8_YnmAhUOyYUKHXm8AqwQ6AEwBnoECAoQAQ#v=onepage&q=will%20have%20absolutely%20no%20effect&f=false