Types of Permission

  1. Read: The right/power to read or see contents of file
  2. Write: The right/power to edit the file
  3. Execute: The right/power to run script file.

ls -l : It is used to see the file and folder permissions.

NOTE: The ls can traverse the directory only if the directory has execute permission.

Understanding output of ls -l

$ ls -l /etc/passwd

- rwx rw- r--   1 root root 1641 May  4 23:42 /etc/passwd
- --- --- ---   |  |    |    |   |__________|
|  |   |   |    |  |    |    |        |_ Date
|  |   |   |    |  |    |    |__________ File Size
|  |   |   |    |  |    |_______________ Group
|  |   |   |    |  |____________________ User
|  |   |   |    |_______________________ Number of hard links
|  |   |   |_ Permission of others (read)
|  |   |_____ Permissions of the group (read, write)
|  |_________ Permissions of the owner (read, write, execute)
|____________ File type (- = File, d = Directory, l = Link, ... )

Changing the permission

To change the permission of a file we need to use the command chmod .

Permission group references (u: Owner, g: Group, o: Others, a: all user) either a [+] or a [-] to add remove the designated permissions

$ ls -l shell

-rwxr-x--x   1 cry0l1t3 htbteam 0 May  4 22:12 shell

$ chmod a+r shell && ls -l shell

-rwxr-xr-x   1 cry0l1t3 htbteam 0 May  4 22:12 shell

In the above command read permission is given to all users.