Permision
File type
-, Normal file
d, Subdirectory
p, Named pipe
s, Socket
l, Symbolic link
c, Character device
b, Block device
File permission
chmod u=rwx,g=rx,o=r filename
- u, user
- g, group
- o, other
chmod 754 filename
Directory permission
write allows creating new files inside of it
read allows you to list the files inside of it
execute allows you to enter it and access files (or other directories) inside
chmod -R ugo+rw /DATA/SHARE, modifies the permission of the specific folder and its child objects recursively
readme (755), temp (750)
user2 is not able to access readme file inside temp folder of user1 since temp of user2 is not assible for user1
Set Default Permission
For directories, the base permissions are (rwxrwxrwx) 0777 and for files they are 0666 (rw-rw-rw)
umask 022, default directory permissions are 755 and default file permissions are 644
SBIT
SUID (Set owner User ID up on execution), 4
- Normally in Linux/Unix when a program runs, it inherit’s access permissions from the logged in user
- SUID is defined as giving temporary permissions to a user to run a program/file with the permissions of the file owner rather that the user who runs it
- users will get file owner’s permissions as well as owner UID and GID when executing a file/program/command
- chmod u+s fileName or chmod 4750 fileName, 'x' for user permission is changed to 's'
SGID, 2
- When SGID permission is set on a directory, files created in the directory belong to the group of which the directory is a member
- chmod g+s directoryName or chmod 2770 directoryName, create a shared folder
SBIT, 1
- The sticky bit is primarily used on shared directories
- users can create files, read and execute files owned by other users, but are not allowed to remove files owned by other users
- chmod +t directoryName or chmod 1777 directoryName, create a shared directory
Attributes
lsattr, list file attributes
chattr, change file attributes
- chattr +i fileName, add i option to the file, not able to modify file
- chattr +i directoryName, add i option to the directory, not able to add or remove files from the directory
Availabe attributes
- a: append only
- c: compressed
- d: no dump
- e: extent format
- i: immutable
- j: data journalling
- s: secure deletion
- t: no tail-merging
- u: undeletable
- A: no atime updates
- C: no copy on write
- D: synchronous directory updates
- S: synchronous updates
- T: top of directory hierarchy
Reference