Skip to main content

Linux file permissions

File Permission

Command: ls -la

file permission

4 = Read
2 = Write
1 = Execute
0 = No Permission

Permission numbers are:

0 = ---
1 = --x
2 = -w-
3 = -wx
4 = r-
5 = r-x
6 = rw-
7 = rwx

stat - file permissions with number format

stat -c '%A %a %U %G %n' burpsuite.jar

Output: -rw-r--r-- 644 root root burpsuite.jar

%A file permissions
%a file permissions in number format
%U file owner
%G file group
%n file name

chmod

CommandDescription
chmod g+w filenameadd w (write) to group.
chmod g-wx filenameremove wr (write,read) to group.
chmod o+w filenameadd w to others.
chmod o-rwx foldernameremove rwx to others.
chmod ugo+rwx foldernameto give read, write, and execute to everyone.
chmod a=r foldernameto give only read permission for everyone.

chown

chown [OPTION]... [OWNER][:[GROUP]] FILE...
chown [OPTION]... --reference=RFILE FILE...

These commands will give ownership to someone, but all sub files and directories still belong to the original owner.

  • chown name filename

  • chown name foldername

    -R recursive You can also combine the group and ownership command by using:

    • chown -R owner:group /home/name/directoryname

chgrp

chgrp [OPTION]... GROUP FILE...
chgrp [OPTION]... --reference=RFILE FILE...
  • chgrp groupname filename
  • chgrp groupname foldername

Ref

Derek Rook - file permissions:
Linux file Permissions
Mastering Linux Permissions