chmod Revisited: Octal Notation Flashcards
The chmod command can use an…?
alternate octal syntax.
The octal syntax is often…?
quicker and more exacting.
[student@station student]$ chmod og-r diary
This syntax has some advantages, but also some disadvantages. Because the…?
syntax is very readable, the intent of the command is fairly evident: the student does not want other users reading the diary. What are the resulting permissions on the file diary? A drawback of the syntax is that, knowing that this command was run, you cannot say! Is the file writable to group members? others? Without knowing the original permissions, you do not known.
chmod 600 diary….?
gives the permissions rw——-. As an added benefit, once learned, the octal system tends to be quicker to use.
Where did the 600 come from…?
Recall that a file has 3 different types of permissions ((r)ead, (w)rite, and e(x)ecute) for three classes of user acces ((u)ser owner, (g)roup owner, and (o)ther). With the octal notation, each access gets a digit: the “hundreds” place for (u(ser, the “tens” palce for (g)roup, and the “ones place for (o)ther. Each permission type gets a vale: (r)ead gets 5, (w)rite gets 2, and e(x)ecute gets 1. The digits in the octal notation are just the sum of the allowed permissions for that class of access.
755 = ???
rwxr-xr-x
7 = 4 + 2 + 1 = rwx for (u)ser 5 = 4 + 0 + 1 = r-x for (g)roup 5 = 4 + 0 + 1 = r-x for (o)ther
640 = ???
rw-r—–
6 = 4 + 2 + 0 = rw- for (u)ser 4 = 4 + 0 + 0 = r-- for (g)roup 0 = 0 + 0 + 0 = --- for (o)ther
701 = ???
rwx—–x
7 = 4 + 2 + 1 = rwx for (u)ser 0 = 0 + 0 + 0 = --- for (g)roup 1 = 0 + 0 + 1 = --x for (o)ther
The notation is called an….?
“octal” notation, because each digit has 8 possible values (0 through 7).
Once learned, the octal notation provides a quick way to refer to…?
the permissions on a file. For example, experienced Unix administrators will often refer to a file having “644” permissions, or a directory having permissions of “755”. In Unix, the state of a file’s permissions is often referred to as the mode of the file. In particular, this term is used to refer to a file’s permissions in octal notation. For example, a system administrator might say “Directories are created with a default mode of 775”
chgrp -R tells chgrp to …?
recourse through a directory (and all it’s subdirectories. chmod, chgrp, and chown all have this command line switch.
Directories and regular files have different “reasonable” permissions. Namely, directories should have…?
the e(x)ecute permission set, while regular files generally should not. Unfortunately, chmod -R does not distinguish between the file and directories.