Home / File system

The file system

Everything starts at /.

Diagram of Linux file system above a desk with Agenda VR3.
FolderContains
/homeUsers' personal files
/etcSystem configuration files
/varVariable data such as logs and caches
/usrInstalled programs and libraries
/tmpTemporary files
/devDevice files
/proc and /sysLive information from the kernel

Disk space

df -h shows free space per file system; du -sh * shows how much each item in the current folder uses.

Paths, hidden files and links

Linux uses one directory tree, and the path you give decides exactly what you mean. An absolute path starts with /, so /etc/hosts means the same file no matter where you are. A relative path does not start with /; notes/todo.txt is looked up from your current directory. Two special names appear everywhere: . means “here” and .. means “the parent directory”. That matters when copying, moving or removing files, because rm ../file and rm ./file are not the same command.

A lot of personal configuration is kept in “hidden” files and directories whose names begin with a dot, such as .profile or .config. A plain ls will not show them. Use ls -la when a folder looks emptier than you expect, especially in home directories. If you are trying to back up settings, those dotfiles are often what you need.

Another thing you will see often is a symbolic link. A symlink is a small entry that points to another path. ls -l shows it with an arrow. Symlinks are useful when you want one directory to appear in another place, or when a program expects a file at a fixed path. If the target is moved or deleted, the link still exists but no longer works.

Directories also have permissions of their own. To enter a directory you need execute permission on it; to list its contents you need read permission as well. That is why you can sometimes open a file by its full path but cannot browse the folder normally. If any of that feels abstract, Command line covers the basic tools, and Users & permissions explains the permission rules in more detail.

Mount points, removable media and /etc/fstab

A disk, partition, USB stick or memory card does not appear as a separate drive letter on Linux. Instead, it is attached to the existing directory tree at a mount point. That mount point is just an ordinary directory. Once mounted, the contents of the device appear there.

For a quick overview, lsblk -f shows devices, filesystem types and labels. findmnt shows what is mounted and where. Removable media is often mounted under /media, while /mnt is commonly used for manual, temporary mounts.

A simple manual mount looks like this:

  • create a mount point, for example sudo mkdir -p /mnt/usb
  • mount the filesystem with sudo mount /dev/sdb1 /mnt/usb
  • check it with findmnt /mnt/usb or df -h /mnt/usb

Before unplugging the device, unmount it with sudo umount /mnt/usb. The command is umount, not unmount. If Linux says the filesystem is busy, you are probably still in that directory in a shell, or a program has a file open there.

For permanent mounts, Linux reads /etc/fstab at boot. A typical entry names the device, the mount point, the filesystem type and the mount options. Using a UUID is safer than relying on names like /dev/sdb1, because device names can change between boots. That matters even more on small systems discussed in Embedded Linux, where internal flash and removable storage may both be present.

Finding big files and full filesystems safely

When space runs low, the first question is whether the problem is the whole filesystem or one directory inside it. df -h answers the first part. For the second, use du with a limited depth so the output stays readable. For example, du -xh --max-depth=1 /var | sort -h shows the largest subdirectories in /var without crossing onto other mounted filesystems.

In home directories, hidden files are easy to miss. du -sh .[!.]* * 2>/dev/null gives a quick size summary that includes dotfiles and dot-directories. Large browser caches, downloads, mail stores and old project trees often show up here.

To look for unusually large individual files, try find /var -xdev -type f -size +100M -ls. Common places to inspect are log files in /var/log, application caches and old backup archives. Be careful with system files: deleting random items from system directories can break installed software. If the space belongs to package caches or old package versions, clean them with the package tools rather than with rm.

Two less obvious checks save time. First, if df says a filesystem is full but du cannot account for the missing space, a deleted file may still be held open by a running process. sudo lsof +L1 can reveal that. Restarting the relevant service or program usually frees the space. Second, run df -i as well as df -h. A filesystem can run out of inodes before it runs out of bytes, which is common when a program creates huge numbers of tiny files. If you are still stuck, move on to the checks in Troubleshooting.