Based on the Linux Master 1 exam syllabusReport an error
022 → 644 / 755./tmp=1777, passwd=4755./dev/sdb and mounting it on /data.# [Step 0] Confirm the disk is recognized
fdisk -l # list all disks and partitions
lsblk # view block devices as a tree
# [Step 1] Create a partition (fdisk or parted)
fdisk /dev/sdb
# Interactive: n (new partition) → p (primary) → number → size → w (write)
# [Step 2] Create a filesystem (format)
mkfs -t ext4 /dev/sdb1 # format as ext4
mkfs.ext4 /dev/sdb1 # same as above
mkfs -t xfs /dev/sdb1 # format as xfs
mkfs.xfs /dev/sdb1 # same as above
# [Step 3] Create a mount point and mount
mkdir /data
mount /dev/sdb1 /data # temporary mount (lost on reboot)
mount -t ext4 /dev/sdb1 /data # specify the type
# [Step 4] Register in fstab (persistent mount)
# Add to /etc/fstab:
# /dev/sdb1 /data ext4 defaults 0 2
mount -a # re-mount everything in fstab (also validates syntax)
df -h # check the mount result| Step | Command | Purpose |
|---|---|---|
| 1 Partition | fdisk /dev/sdb | Divide the disk into partitions |
| 2 Format | mkfs -t ext4 /dev/sdb1 | Create a filesystem |
| 3 Mount | mount /dev/sdb1 /data | Attach to a directory |
| 4 Make persistent | Register in /etc/fstab + mount -a | Auto-mount at boot |
The "add a disk and mount it" task always follows the order partition → format (mkfs) → mount (mount) → register in fstab. If any one of these four steps is missing, the task is incomplete. In particular, if the requirement says "persists after reboot", you must go all the way to the fstab registration.
⚠️ Trap: You format the partition (
/dev/sdb1), not the whole disk (/dev/sdb). Also,mountalone is lost on reboot - a persistent mount requires registration in/etc/fstab.mount -are-mounts every entry in fstab, so use it to verify after writing fstab.
# Create a swap partition/file
mkswap /dev/sdb2 # create the swap area
swapon /dev/sdb2 # activate swap
swapon -s # list active swap
free -h # memory and swap usage
# fstab: /dev/sdb2 none swap sw 0 0To check mount information, use mount (current mount list), df -h (capacity and usage), lsblk (device tree), and blkid (UUID and type). To mount by UUID, find the UUID with blkid and write it in fstab in the form UUID=.... Device names (/dev/sdb1) can change when disks are added, so UUIDs are safer.
# [Step 1] Create physical volumes (PV) - initialize disks/partitions for LVM
pvcreate /dev/sdb /dev/sdc
pvscan # PV list
pvdisplay # PV details
# [Step 2] Create a volume group (VG) - combine the PVs into one
vgcreate vg_data /dev/sdb /dev/sdc
vgscan
vgdisplay # VG details (check free space)
# [Step 3] Create a logical volume (LV) - carve it out of the VG
lvcreate -L 10G -n lv_app vg_data # create a 10GB lv_app
lvcreate -l 100%FREE -n lv_all vg_data # all remaining space
lvscan
lvdisplay # LV details, path is /dev/vg_data/lv_app
# [Step 4] Create a filesystem + mount
mkfs -t ext4 /dev/vg_data/lv_app
mkdir /app
mount /dev/vg_data/lv_app /app
# fstab: /dev/vg_data/lv_app /app ext4 defaults 0 2| Layer | Create command | Display command | Meaning |
|---|---|---|---|
| PV | pvcreate | pvdisplay | Initialize a disk for LVM |
| VG | vgcreate | vgdisplay | Storage pool combining PVs |
| LV | lvcreate | lvdisplay | Logical disk carved out of a VG |
The LVM creation order is pvcreate → vgcreate → lvcreate. The command prefixes pv, vg, and lv indicate the layer. Create from top to bottom (PV→VG→LV), and remove in reverse (LV→VG→PV).
# Add a new disk (PV) to the VG
pvcreate /dev/sdd
vgextend vg_data /dev/sdd # add the PV to the VG (expand capacity)
# Grow the LV
lvextend -L +5G /dev/vg_data/lv_app # add 5GB
lvextend -L 20G /dev/vg_data/lv_app # make it 20GB total
lvextend -l +100%FREE /dev/vg_data/lv_app # all remaining space
# ★ After growing the LV, you must also grow the filesystem for the capacity to actually increase
resize2fs /dev/vg_data/lv_app # for ext2/3/4
xfs_growfs /app # for xfs (specify the mount point)
# In one step: the lvextend -r option (automatic resize)
lvextend -L +5G -r /dev/vg_data/lv_appThe command to extend an LV is lvextend. However, growing only the LV leaves the filesystem unchanged, so you must also grow the filesystem - resize2fs for ext family, xfs_growfs for xfs - for the capacity to actually show up. Missing this "two-step" process is the classic mistake. Using lvextend -r handles the resize automatically.
⚠️ Trap: Extending a VG is
vgextend(adding a PV), and extending an LV islvextend. The names are similar, which causes confusion.vgextendgrows the pool, andlvextendgrows the logical disk. Another trap is that xfs cannot be shrunk (no shrinking) and can only be grown.
umask specifies the bits to remove from the permissions of newly created files and directories.umask # print the current umask (e.g. 0022)
umask 022 # set umask
umask 027 # stricter
# Calculation: subtract umask from the file default 666 and directory default 777
# umask 022 → file 644 (rw-r--r--), directory 755 (rwxr-xr-x)
# umask 077 → file 600 (rw-------), directory 700 (rwx------)| umask | New file permission | New directory permission |
|---|---|---|
| 022 | 644 | 755 |
| 027 | 640 | 750 |
| 077 | 600 | 700 |
| 002 | 664 | 775 |
umask is a "mask that is subtracted from the default permissions". For files, subtract the umask from 666; for directories, from 777. With umask 022, a file becomes 666-022=644 and a directory 777-022=755. The reason files don't get the execute bit (x) by default is that the starting value is 666.
# SetUID (4000) - runs with the file owner's privileges when executed
chmod 4755 /path/program # rwsr-xr-x
chmod u+s /path/program # symbolic form
# e.g. /usr/bin/passwd (lets regular users modify shadow)
# SetGID (2000) - runs with group privileges / on a directory, inherits the group
chmod 2755 /path/program # rwxr-sr-x
chmod g+s /shared_dir # directory: new files inherit the group
# e.g. keep the team group in a shared directory
# Sticky bit (1000) - directory: only the owner can delete their own files
chmod 1777 /tmp # rwxrwxrwt
chmod +t /shared_dir # symbolic form
# e.g. /tmp (anyone can write, but cannot delete others' files)| Special permission | Octal | Symbolic | Shown at | Effect |
|---|---|---|---|---|
| SetUID | 4000 | u+s | s in owner x position | Runs with owner's privileges |
| SetGID | 2000 | g+s | s in group x position | Runs with group privileges / group inheritance |
| Sticky | 1000 | +t | t in others x position | Delete only your own files |
ls -l, you tell them apart by the permission characters.-rwsr-xr-x → SetUID (s in the owner x position)-rwxr-sr-x → SetGID (s in the group x position)drwxrwxrwt → Sticky bit (t in the others x position)The special-permission octal adds one more digit in front of the regular permissions. In chmod 4755, the leading 4 is SetUID, 2 is SetGID, and 1 is the Sticky bit. /tmp is 1777 (Sticky), and /usr/bin/passwd is 4755 (SetUID).
If you see an uppercase S/T (e.g. rwSr--r--), it means the special bit is set at that position without the execute permission (x), which is usually an unintended setting. A lowercase s/t is the normal state where the execute permission is also present.
# Check disk status (safe query commands)
lsblk
df -h
blkid
mount | column -t
# Check LVM status (on an environment with LVM installed)
pvscan; vgscan; lvscan
vgdisplay 2>/dev/null
# umask experiment
umask # check the current value
mkdir testdir && touch testfile
ls -ld testdir testfile # check permissions
umask 077
mkdir testdir2 && touch testfile2
ls -ld testdir2 testfile2 # check the stricter permissions
# Check special permissions
ls -l /usr/bin/passwd # rwsr-xr-x (SetUID)
ls -ld /tmp # rwxrwxrwt (Sticky)| Scenario | Command order |
|---|---|
| Mount a new disk | fdisk → mkfs -t ext4 → mount → register in fstab |
| Guarantee a persistent mount | Add to /etc/fstab, then mount -a |
| Add swap | mkswap → swapon |
| Create LVM | pvcreate → vgcreate → lvcreate |
| Expand LVM capacity | vgextend (add PV) → lvextend → resize2fs/xfs_growfs |
| Default permission 644 for new files | umask 022 |
| Run with the owner's privileges | chmod 4755 (SetUID) |
| Group inheritance in a shared directory | chmod g+s (SetGID) |
| Safe sharing like /tmp | chmod 1777 (Sticky) |
Don't skip the command prefixes (pv/vg/lv) or the finishing steps (fstab, resize2fs) of each stage. Tomorrow we fill in the other half of system administration with process, scheduling, and systemd task questions.
n (create) → w (write) in that order./etc/fstab. Use it to validate syntax after editing fstab.pvcreate.vgcreate and grown with vgextend.lvcreate and grown with lvextend.passwd command is the classic example./tmp is the classic example.Click a choice to reveal the answer and explanation.
Question 1
Which command correctly formats the new partition /dev/sdb1 as ext4?
Question 2
Which file must be edited to permanently register a disk so that it is mounted automatically at boot?
Question 3
When building LVM, which command first initializes a disk for LVM?
Question 4
After extending the logical volume lv_app by 5GB, which command should be run after lvextend to actually grow the ext4 filesystem as well?
Question 5
What is the permission of a newly created regular file when the umask value is 022?
Question 6
Which special permission and octal representation make a program like /usr/bin/passwd run with the file owner's (root's) privileges?
Question 7
Which command sets the special permission so that, as in /tmp, anyone can create files but can delete only their own files?