Manage Files on Linux


Linux uses a unified directory tree, meaning every partition, removable disk, network file share, other storage device is accessible as a directory in a single directory tree (or filesystem).

  • this filesystem is structured
    • some directories have a specific purpose
  • all starts at the root directory /

User Files vs. System Files

System files are files that control how the computer operates.

  • includes:
    • system startup scripts
    • program files
      • both binary files and scripts
    • program support files
      • e.g., fonts and icons
    • configuration files
      • define how the system works
    • configuration files for server services and other daemons
    • data storage for system programs
    • system log files
  • system files are normally owned by root
    • to restrict ordinary users from accessing

Filesystem Hierarchy Standard (FHS)

Filesystem Hierarchy Standard (FHS) is a system of standardization for Linux system files.

  • some Unix-like OSs also follow FHS
  • FHS distinguishes two kinds of files:
    • Sharable files
      • are files that may be reasonable shared between computers
      • e.g., user data files and program binary files
    • Unsharable files
      • contain system-specific information
      • e.g., configuration files
  • FHS also distinguishes between:
    • Static files
      • doesn’t change except through direct intervention by the system administrator
      • e.g., program executables
    • Variable files
      • files that may change without direct intervention by system administrator
      • may change by:
        • users
        • automated scripts
        • servers
      • e.g., home directories
ShareableUnshareable
Static/usr, /opt/etc, /root
Variable/home, /var/mail/var/run, /var/lock
  • Find FHS web page at linuxfoundation.org/collaborate/workgroups/lsb/fhs

Important Directories

DirectoryKindPurpose
/SystemRoot directory. All files appear in this directory or subdirectories of it.
/etcSystemHolds system configuration files
/bootSystemHolds important boot files (e.g., Linux kernel, initial RAM disk, boot loader config files)
/binSystemHolds program files that are critical for normal operation and that ordinary users may run.
/sbinSystemHolds program files that are critical for normal operation and that ordinary users seldom run.
/libSystemHolds libraries—code used by many other programs—that are critical for basic system operation.
/usrSystemHolds programs and data used in normal system operation but that are not critical for a bare bones boot of the system. Split into subdirectories that mirror part of the root organization (i.e., /user/bin, /usr/sbin, /usr/lib, etc.)
/homeUserHold’s users’ home directories.
/rootSystemThe root user’s home directory.
/varSystemHolds miscellaneous transient files (e.g., log files, print spool files).
/var/tmp holds temporary files, but they should not be deleted upon computer reboot.
/tmpUserHolds temporary files. May be deleted when the computer reboots.
/mntUserThe traditional mount point for removable media; sometimes split into subdirectories for each mounted filesystem.
/mediaUserThe new mount point for removable media; typically split into subdirectories for each mounted filesystem.
/devSystemHolds device files, which provide low-level access to hardware.
/runSystemInformation about the running system.