ls -l
and chmod
Back to CS16 topics
When we type ls -l
we get strings that correspond to the octal numbers used in chmod commands. For example:
This output in ls -l | could be set with this chmod command: |
-rw-r--r-- | chmod 644 filename |
drwxr-xr-x | chmod 755 dirname |
-rw------- | chmod 600 filename |
The meanings are:
octal digit |
binary equivalent |
rwx format |
meaning |
0 |
000 |
--- |
no permission |
1 |
001 |
--x |
execute |
2 |
010 |
-w- |
write |
3 |
011 |
-wx |
write and execute |
4 |
100 |
r-- |
read only |
5 |
101 |
r-x |
read and execute |
6 |
110 |
rw- |
read and write |
7 |
111 |
rwx |
read write and execute |
The three digits in an octal number have different meanings depending on their positions (text borrowed from Wikipedia).
This web page gives you an opportunity to practice with converting between the format used in ls -l output, and the octal numbers used in chmod.
We will ignore the first character in the ls -l
output (which is a -
for regular files, and a d
for directories).
Each time you click the "make new quiz" button, you'll get a different randomly generated quiz.