Linux: Files and Permissions
Read rwx, convert it to numbers, and change it with chmod.
Permissions decide who can read, change, or run every file. Misconfigured permissions are one of the most common ways attackers escalate privileges.
1
Reading permissions
ls -lshows permissions as ten characters:-rwxr-xr-- 1 alice staff 1024 Nov 28 10:00 deploy.sh- The first character is the type:
-file,ddirectory,llink. - Then three groups of three: owner, group, others.
rread,wwrite,xexecute. A-means the permission is missing.
So
deploy.sh: the owner (alice) can read, write, and run it; the group can read and run; everyone else can only read.On a directory,
xmeans you're allowed to enter it (cdinto it).- The first character is the type:
2
Octal notation and chmod
Each permission has a value: r = 4, w = 2, x = 1. Add them up per group:
Symbolic Octal rwx7 r-x5 r--4 rw-6 So
rwxr-xr-xis 755, andrw-------is 600.Change permissions with
chmod:chmod 600 id_rsa # only the owner can read and write chmod +x script.sh # add execute for everyoneSSH refuses to use a private key that others can read, so
chmod 600on keys is a habit worth having.
โ Report a problem with this room
Log in to report a problem.