Based on the Linux Master 2 exam syllabusReport an error
chown is root only, while chmod can also be done by the owner.df is the file system, du is the path. umount has no n. chmod 4 7 5 5 file
│ │ │ │
│ │ │ └── other r-x
│ │ └───── group r-x
│ └──────── user rwx
└─────────── special SetUID
4 SetUID · 2 SetGID · 1 Sticky
-rws r-x r-x
│└┬┘ └┬┘ └┬┘
│ │ │ └── other
│ │ └────── group
│ └────────── owner (the s in the x slot = SetUID)
└──────────── file type umask calculation
file 666 - umask
directory 777 - umask
022 → file 644 · directory 755 (default)
077 → file 600 · directory 700 (strict)
000 → file 666 · directory 777 (a file is not 777!)| Digit | Notation | Digit | Notation |
|---|---|---|---|
| 7 | rwx | 3 | -wx |
| 6 | rw- | 2 | -w- |
| 5 | r-x | 1 | --x |
| 4 | r-- | 0 | --- |
| Permission value | Notation | Where it's used |
|---|---|---|
| 644 | rw-r--r-- | Regular files |
| 755 | rwxr-xr-x | Directories and executables |
| 600 | rw------- | Private keys |
| 1777 | rwxrwxrwt | /tmp |
| 4755 | rwsr-xr-x | /usr/bin/passwd |
| Comparison | A | B | Deciding criterion |
|---|---|---|---|
x on a file vs x on a directory | Execute | Enter (cd) | What the target is |
r on a file vs r on a directory | Read contents | View listing | Same as above |
chmod 755 vs chmod u+x | Overwrites everything | Adds to the current state | Preserving existing permissions |
chown vs chgrp | Owner | Group | What gets changed |
chown vs chmod | Root only | Owner can too | Who can do it |
| SetUID vs SetGID | Owner's privileges | Group's privileges / group inheritance | Which slot the s is in |
| SetGID (file) vs SetGID (directory) | Run with group privileges | Pass the group down | What the target is |
Sticky vs plain w | Delete only your own | Delete others' too | Whether deletion is restricted |
s vs S | x permission present | No x permission | Case |
df vs du | File system capacity | Usage per path | What it counts |
/bin vs /sbin | Regular commands | Administrator commands | Who uses them |
/ vs /root | Top level | root's home | Location |
/mnt vs /media | Manual mounts | Removable media | Whether automatic |
x on a directory is execute → It is enter. Without x, cd doesn't work.w, not the file. What prevents this is the Sticky bit.chown is possible for root only.unmount → It is umount. No n.fsck while mounted → There's a risk of damage. Always do it after unmounting.x that the file never had.df /var/log is the size of that directory → It is the capacity of the entire file system that directory belongs to. The directory size is du -sh.chmod -r for subdirectories → Recursion is uppercase -R. The same for chown and chgrp.In the exam room, you have to convert on the spot with no calculator. Let's follow one of each type.
rwxr-x--x → (4+2+1)(4+0+1)(0+0+1) → 751
rw-rw---- → (4+2+0)(4+2+0)(0+0+0) → 660
640 → 6=rw- 4=r-- 0=--- → rw-r-----
711 → 7=rwx 1=--x 1=--x → rwx--x--xx. 6, 4, 2, and 0 can't execute; 7, 5, 3, and 1 can.Start from rw-r--r-- (644) and apply them in order.
| Command | Result | Value |
|---|---|---|
chmod u+x | rwxr--r-- | 744 |
chmod go-r | rwx------ | 700 |
chmod a+r | rwxr--r-- | 744 |
chmod g=rw | rwxrw-r-- | 764 |
chmod o= | rwxrw---- | 760 |
+ and - change only what's written, and = replaces all three slots of that target. g=rw erases the permissions the group had and rewrites it as rw-.| umask | Directory (from 777) | File (from 666) |
|---|---|---|
| 022 | 755 | 644 |
| 002 | 775 | 664 |
| 027 | 750 | 640 |
| 077 | 700 | 600 |
| 033 | 744 | 644 |
| 000 | 777 | 666 |
x from it gives the file value.| Notation | Value | What is set |
|---|---|---|
-rwsr-xr-x | 4755 | SetUID |
-rwxr-sr-x | 2755 | SetGID |
drwxrwxrwt | 1777 | Sticky bit |
drwxrws--- | 2770 | SetGID (collaboration directory) |
-rwsr-sr-x | 6755 | SetUID + SetGID |
-rwSr--r-- | 4644 | SetUID but no execute permission |
s in the first three slots is SetUID, an s in the middle three slots is SetGID, and a t at the very end is Sticky.The key to permission questions is sorting out "who gets which slot." alice and bob are in the dev group, and carol is not.
drwxrwx--T 2 root dev /project
-rw-r----- 1 alice dev /project/plan.txt| Question | Answer | Reason |
|---|---|---|
Can bob read plan.txt | O | dev group → the file's group slot r-- |
Can bob modify plan.txt | X | The group slot has no w |
Can bob delete plan.txt | X | The directory has w, but the Sticky bit is set so only the owner can delete |
Can bob create a new file in /project | O | The directory's group slot rwx |
Can carol enter /project | X | The directory's other slot has no x (the T is uppercase) |
Can alice change plan.txt's owner to bob | X | chown is root only |
Can alice change plan.txt's permissions | O | chmod can be done by the owner too |
| Command | What it does | Options you must remember |
|---|---|---|
chmod | Change permissions | -R recursive |
chown | Change owner (and group) | -R, owner:group format |
chgrp | Change group | -R |
umask | View/set the default permission mask | -S view in symbols |
mount | Attach a file system | -t type, -o options, -a all of fstab |
umount | Detach | Device name or mount point |
df | Capacity per file system | -h, -T type, -i inode |
du | Usage per path | -h, -s total |
fsck | Check/repair a file system | -y yes to all, run after unmounting |
find -perm | Find by permissions | -perm -4000 includes SetUID |
stat | Shows octal and symbolic permissions together | |
ls -ld | Permissions of the directory itself |
| File | What |
|---|---|
/etc/fstab | The list to mount at boot (6 fields) |
/etc/mtab, /proc/mounts | The list currently mounted |
/etc/profile, /etc/bashrc | System-wide umask setting |
~/.bashrc | Per-user umask setting |
| Directory | One line | Directory | One line |
|---|---|---|---|
/bin | Basic commands | /sbin | Administrator commands |
/etc | Configuration files | /var | Changing things like logs and spool |
/home | User homes | /root | root's home |
/dev | Device files | /proc | Kernel and process info (virtual) |
/boot | Kernel and bootloader | /lib | Shared libraries |
/usr | Applications | /opt | Additional packages |
/tmp | Temporary files (1777) | /mnt, /media | Mount points |
| Value | What |
|---|---|
| 4 / 2 / 1 | r / w / x, and also SetUID / SetGID / Sticky |
| 022 | The typical default umask |
| 666 / 777 | Base values for the umask calculation (file / directory) |
| 644 / 755 | Result of umask 022 |
| 1777 | Permission of /tmp |
| 4755 | Permission of /usr/bin/passwd |
s / t | Display characters for SetUID·SetGID / Sticky bit |
Next week covers the program that receives and interprets commands — the shell. Environment variables, redirection, and aliases come up.
df -i.Click a choice to reveal the answer and explanation.
Question 1
Which of the following is the special permission set by the command chmod 1777 /shared?
Question 2
When the umask value is 000, which of the following is the permission of a newly created regular file?
Question 3
Which of the following is the condition that allows you to delete a file even if you don't have write permission on the file itself?
Question 4
Which of the following is the directory where administrator commands are mainly stored?
Question 5
Which of the following states does the permission notation -rwxr-sr-x represent?
Question 6
Which of the following commands checks the total capacity taken up by a specific directory as a sum?