CertNote/ Commute Study Notes
Roadmap
KOEN
CLF-C02 · FoundationalCloud Practitioner - Foundational
DVA-C02 · AssociateDeveloper - Associate
SAA-C03 · AssociateSolutions Architect - Associate
SOA-C02 · AssociateCloudOps Engineer - Associate
SAP-C02 · ProfessionalSolutions Architect - Professional
DOP-C02 · ProfessionalDevOps Engineer - Professional
Linux Master 2 · 2급KAIT Linux Master - Level 2
  • Week 1
    • 1.Operating Systems and the Kernel: What Linux Does
    • 2.The Birth of Linux: From Unix to Linus
    • 3.Free Software and Open Source: What a License Decides
    • 4.Distributions: The Unit That Bundles the Kernel and Tools for Sale
    • 5.Week 1 Review: The Identity Behind the Name Linux
  • Week 2
  • Week 3
  • Week 4
    • 1.The Structure of Permissions: rwx and Octal
    • 2.Ownership and umask
    • 3.Special Permissions: SetUID · SetGID · Sticky bit
    • 4.Directory Hierarchy and File System Management
    • 5.Week 4 Review: Permissions on One Page
  • Week 5
  • Week 6
  • Week 7
  • Week 8
  • Week 9
  • Week 10
  • Week 11
SCS-C03 · SpecialtySecurity - Specialty
Linux Master 1 · 1급KAIT Linux Master - Level 1
MLA-C01 · AssociateMachine Learning Engineer - Associate
AIF-C01 · FoundationalAI Practitioner - Foundational
DEA-C01 · AssociateData Engineer - Associate
MLS-C01 · SpecialtyMachine Learning - Specialty
SQLD · 개발자SQL Developer (SQLD)

© CertNote · 주간랩스

  • About
  • Changelog
  • Contact
  • Terms
  • Privacy
← Linux Master 2/Week 4/Day 4

Based on the Linux Master 2 exam syllabus·Report an error

Linux Master 2· AssociateWeek 4 · Day 4~20 min read

Day 4 - Directory Hierarchy and File System Management

📌 Key Takeaways

  • Linux has no drive letters. Everything is a single tree growing out of one root (/).
  • The names and roles of directories are fixed by a standard called FHS — /etc configuration, /var things that change, /bin commands.
  • /proc is not on disk. It is a virtual file system that the kernel builds in memory.
  • Attach with mount and detach with umount. A directory that is in use can't be detached.
  • df is file system capacity, and du is usage by path. Memorize them as a pair.

One Tree

                    /   (root)
      ┌────────┬────────┼────────┬────────┬────────┐
    /bin     /etc     /home    /var     /usr     /proc
  executables config   users    variable applications kernel info
                                data
  • There are no drive letters like Windows' C: and D:. A new disk is also attached somewhere in the tree to be used.
  • The root / is the top-level directory, and it is different from /root, the home of the root user.

FHS — What Is in Which Directory

DirectoryWhat it holds
/binBasic commands — ls, cp, cat
/sbinAdministrator commands — fdisk, shutdown
/etcConfiguration files — passwd, fstab, hosts
/homeHome directories of regular users
/rootroot's home directory
/varData that changes often — logs, mail, spool
/tmpTemporary files. Cleared on reboot
/usrApplications and libraries
/libShared libraries needed for boot and basic commands
/devDevice files — sda, tty, null
/procKernel and process info (virtual)
/bootKernel image and bootloader
/optAdditionally installed packages
/mnt, /mediaMount points (manual / removable)

Memorize the values that are asked as pairs together.

Confusing pairDeciding criterion
/bin vs /sbinFor regular users vs for administrators
/ vs /rootTop-level directory vs root's home
/mnt vs /mediaManual mounts vs automatic for removable media
/var vs /tmpThings that stay, like logs, vs things that get cleared
/lib vs /usr/libLibraries for boot and basic commands vs for applications
/dev vs /procDevice files vs kernel and process info

Paths one level further down also show up as answer choices.

PathWhat it holds
/usr/bin, /usr/sbinExecutables of applications / executables for administrators
/usr/localPrograms the administrator installed directly (distinguished from distribution packages)
/usr/share/manManual pages
/var/logLog files — messages, secure, etc.
/var/spoolJobs waiting to be processed — printing, mail, scheduled jobs
/var/tmpTemporary files that persist even after a reboot
/etc/fstabList of file systems to mount at boot
/lost+foundWhere file fragments recovered by fsck are collected (ext family)
  • Knowing where the names come from makes them less confusing — /etc is configuration, /var is variable (things that change), /opt is optional (additional packages), /sbin is system binaries, and /dev is devices. /usr is not a user's home. User homes are in /home.
  • Recent distributions often make /bin, /sbin, and /lib symbolic links to /usr/bin, /usr/sbin, and /usr/lib. Even so, the division of roles is still what gets tested.
  • When /tmp is cleared depends on the distribution's settings. Understand it as "a place for temporary files that you shouldn't expect to last long."

/proc — A File System That Isn't on Disk

cat /proc/cpuinfo      # CPU info
cat /proc/meminfo      # memory info
cat /proc/version      # kernel version
ls /proc/1             # info of the PID 1 process
  • The files in /proc are not stored on disk. The kernel builds and shows them the instant you read them. Often their size is shown as 0.
  • A similar virtual file system is /sys (device and kernel settings).
  • /dev is special too. It holds files that point to devices, not actual data.
File in /procContents
/proc/cpuinfoCPU model, core count
/proc/meminfoMemory and swap usage status
/proc/versionKernel version
/proc/partitionsRecognized disks and partitions
/proc/filesystemsFile system types the kernel supports
/proc/mountsFile systems currently mounted
/proc/swapsSwap areas in use
/proc/number/Info of the process with that PID
  • A numbered directory under /proc is a running process. When the process ends, the directory disappears too.

Attaching and Detaching — mount and umount

mount                          # the entire current mount state
mount /dev/sdb1 /data          # attach sdb1 at /data
mount -t ext4 /dev/sdb1 /data  # specifying the file system type
mount -o ro /dev/sdb1 /data    # read-only
umount /data                   # detach by mount point
umount /dev/sdb1               # detach by device name
mount -a                       # mount every entry in /etc/fstab
OptionMeaning
-t typeSpecify the file system type (ext4, xfs, iso9660)
-o ro / rwRead-only / read-write
-aEverything listed in /etc/fstab

Two pitfalls. ① It's umount, not unmount. There is no n. ② A file system in use can't be detached. If you are inside that directory or a process has a file open there, you get a device is busy error. Get out and try again, and if it still fails, check who is holding it with lsof or fuser.

  • If files originally existed at the mount point (/data), they are hidden. They don't disappear, and are visible again when you detach.
  • To attach automatically at boot, write it in /etc/fstab (covered in W2).

One Cycle of Mounting

$ sudo mkdir /data                       ← the mount point must exist beforehand
$ sudo mount /dev/sdb1 /data
$ mount | grep sdb1
/dev/sdb1 on /data type ext4 (rw,relatime)
$ cd /data
$ sudo umount /data
umount: /data: target is busy.
$ cd ~
$ sudo umount /data
  • The mount point must be an existing directory. mount doesn't create the directory for you.
  • The argument order of mount is device first, mount point after — mount [options] device directory.
  • umount accepts either the device name or the mount point.
  • The first umount above failed because the shell was inside /data. Once it stepped out, it detached.
Device/mediaCommon mount example
Partition on an additional diskmount /dev/sdb1 /data
CD/DVDmount -t iso9660 /dev/cdrom /media/cdrom
USB drivemount /dev/sdc1 /mnt/usb (the device name may differ each time you plug it in)
ISO image filemount -o loop image.iso /mnt/iso
-o optionMeaning
ro / rwRead-only / read-write
remountChange only the options and mount again without detaching (mount -o remount,rw /)
loopMount a file like a device (ISO image)
noexecForbid execution of executables on that file system
nosuidIgnore SetUID and SetGID
defaultsA bundle of default options (includes rw)
  • Write options joined with commas — -o ro,noexec. No spaces.

Three Places Where Mount Information Is Written

FileWhat it holdsWho writes it
/etc/fstabThe list to mount at bootAdministrator edits it directly
/etc/mtabThe list currently mountedUpdated automatically by the system
/proc/mountsThe list currently mounted (shown by the kernel)Kernel
# device         mount point type   options    dump  fsck order
/dev/sdb1        /data      ext4   defaults   0     2
  • /etc/fstab has 6 fields separated by whitespace — device, mount point, file system type, options, dump flag, fsck order.
  • Tell them apart this way: "planned" is fstab, "current" is mtab. What you see when you type mount with no arguments is the current list.
  • If it's in fstab, even giving just one side, as in mount /data, finds the rest from fstab and attaches it.

Viewing Capacity — df and du

CommandWhat it looks atUnit
dfTotal, used, and free capacity per file systemBased on what's mounted
duActual usage per pathBased on directories and files
df -h                   # in human-readable units (G, M)
df -T                   # including file system type
df -i                   # inode usage
du -h /var/log          # capacity per path
du -sh /var/log         # total only (summary)
du -sh * | sort -h      # biggest first, from the current location
  • -h is human-readable. It is used with the same meaning in both commands.
  • The -s in du -sh is summary — it gives only the total without listing each sub-item.
  • For the problem "the disk is full," find which file system with df -h, and narrow down which directory with du -sh.
$ df -hT
Filesystem     Type      Size  Used Avail Use% Mounted on
/dev/sda2      xfs        50G   12G   38G  24% /
/dev/sda1      xfs      1014M  180M  835M  18% /boot
/dev/sdb1      ext4       99G   89G  4.9G  95% /data
tmpfs          tmpfs     1.9G     0  1.9G   0% /dev/shm
ColumnMeaning
FilesystemDevice name
TypeFile system type (only when -T is given)
Size / Used / AvailTotal / used / remaining capacity
Use%Usage rate
Mounted onMount point
$ du -h /data/logs
1.2G    /data/logs/2026-08
3.4G    /data/logs/2026-09
4.6G    /data/logs
$ du -sh /data/logs
4.6G    /data/logs
  • With no options, du prints one line per subdirectory and gives the total at the end. -s leaves only that last line.
  • Even if you give a directory, as in df /data/logs, df shows the whole file system that directory belongs to. It doesn't tell you the size of a single directory.
Optiondfdu
-hReadable unitsReadable units
-k / -mIn KB / MBIn KB / MB
-TShow file system type—
-iinode usage—
-s—Total only
-aAll file systemsFiles too, one line each, not just directories
-c—Add a grand total line at the end

There are cases where capacity remains but files can't be created. The inodes have run out. It happens when there are very many small files. Check with df -i.

Checking — fsck

fsck /dev/sdb1          # check
fsck -y /dev/sdb1       # yes to every question
e2fsck -f /dev/sdb1     # ext family, forced check
  • It is a command that checks and repairs the integrity of a file system.
  • ⚠️ Always run it with the file system unmounted. Checking while mounted can damage the file system.
  • It sometimes runs automatically at boot after an abnormal shutdown. The 6th field of /etc/fstab decides the check order (1 for root, 2 for the rest, 0 for no check).
CommandRelationship
fsckA command that calls on your behalf the checker that suits the file system type
e2fsck (fsck.ext4)The checker dedicated to ext2, ext3, and ext4
xfs_repairThe repair program dedicated to XFS (don't use e2fsck for XFS)
OptionMeaning
fsck -yRepair while answering yes to every question
fsck -nCheck only, without fixing (no to every question)
fsck -ACheck everything listed in /etc/fstab
fsck -t typeSpecify the file system type
e2fsck -fCheck by force, even if it looks fine
e2fsck -pAuto-repair within a safe range, without asking
  • The correct order is umount → fsck → mount. File systems that can't be detached, like the root (/), are checked during the boot process or in recovery mode.
  • Give the argument to fsck as the device name (/dev/sdb1), not the mount point.
  • File fragments that couldn't be placed anywhere during repair are collected in that file system's lost+found directory.

Lookup Commands Used Alongside

CommandWhat it does
lsblkBlock devices in a tree form
blkidA device's UUID and file system type
mountThe current mount list
free -hMemory and swap usage

Tomorrow we bundle this week's permissions and file systems into one summary.

📖 Glossary

  • FHS : Filesystem Hierarchy Standard. The convention that fixes directory names and roles in Linux.
  • Root directory (/) : The very top of the whole file system. Different from /root, root's home.
  • Mount : Connecting a file system to a specific point in the directory tree.
  • Mount point : The directory where a file system is attached. Whatever was originally there is hidden.
  • Virtual file system : A file system like /proc and /sys that the kernel builds and shows, not a disk.
  • df : The command for viewing capacity per file system.
  • du : The command for viewing usage per path. -sh gives the total.
  • fsck : The command that checks and repairs file system integrity. Run it while unmounted.

📝 Practice Questions

Click a choice to reveal the answer and explanation.

Question 1

Which of the following is the directory where system configuration files are mainly stored?

Question 2

Which of the following is a virtual file system that holds kernel and process information and exists in memory rather than on disk?

Question 3

Which of the following commands detaches a mounted file system?

Question 4

Which of the following commands checks the total capacity and free space per file system?

Question 5

Which of the following must be observed when running the fsck command?

PreviousSpecial Permissions: SetUID · SetGID · Sticky bitWeek 4 · Day 3Next Week 4 Review: Permissions on One PageWeek 4 · Day 5

Official references

  • Linux Master 2 official exam syllabus(opens in a new tab)

On this page

  • Key Takeaways
  • One Tree
  • FHS — What Is in Which Directory
  • proc — A File System That Isn't on Disk
  • Attaching and Detaching — mount and umount
  • One Cycle of Mounting
  • Three Places Where Mount Information Is Written
  • Viewing Capacity — df and du
  • Checking — fsck
  • Lookup Commands Used Alongside
  • Glossary
  • Practice Questions