File Permission

The permissions consist of three groupings: what the owner of the file can do to it, what someone in a group can do to the file, and finally, what anyone (sometimes referred to as other) can do.

chown

Change the owner of file.
user:group

chmod

Change file permission
chmod permissions filename
There are 2 ways to use the command –

  1. Absolute mode
  2. Symbolic mode

Use mask to get the result. Maximum is 111, the left-most bit is read, middle bit is write, right-most bit is execute.

  • The read bit adds 4 to its total (in binary 100),
  • The write bit adds 2 to its total (in binary 010), and
  • The execute bit adds 1 to its total (in binary 001).

Sudo Group

# Adding User to the sudo Group
usermod -aG sudo username

SetUID

  • SUID Let user execute a file with the permissions of the file’s owner.
sudo chmod 4755 mycat
sudo chmod u+s mycat

Permission Leak

Use a leaked fd (with permission when opened) and forget to close(fd)