Format: drwxr-xr-x
dβ Directory (or-for file).rwx(User/Owner) β Read, Write, Execute.r-x(Group) β Read, Execute.r-x(Others) β Read, Execute.
4= Read (r)2= Write (w)1= Execute (x)
Common Examples:
777(rwxrwxrwx) β Full access for everyone (Dangerous!).755(rwxr-xr-x) β Owner can do everything, others can read/execute (Standard for scripts/directories).644(rw-r--r--) β Owner can read/write, others can read (Standard for files).600(rw-------) β Owner read/write only (Private keys/passwords).
chmod <mode> <file>β Change file mode bits.chmod 755 script.shchmod +x script.sh(Add execute permission).chmod u+w file.txt(Add write permission for user).
chown <user>:<group> <file>β Change file owner and group.chown root:root /etc/filechown -R user:user /var/www(Recursive).
chgrp <group> <file>β Change group ownership.
umaskβ Sets default permissions for new files/directories (e.g.,022results in755dirs and644files).sudoβ Run command as superuser (root).