Bookmark this page

Chapter 2. Navigating File Systems

Abstract

Goal Copy, move, create, delete, and organize files while working from the Bash shell.
Objectives
  • Describe how Linux organizes files, and the purposes of various directories in the file-system hierarchy.

  • Create, copy, move, and remove files and directories.

  • Make multiple file names reference the same file using hard links and symbolic (or "soft") links.

Sections
  • Describing Linux File-system Hierarchy Concepts (and Quiz)

  • Managing Files Using Command-line Tools (and Guided Exercise)

  • Making Links Between Files (and Guided Exercise)

Describing Linux File System Hierarchy Concepts

Objectives

After completing this section, you should be able to describe how Linux organizes files, and the purposes of various directories in the file-system hierarchy.

The File-system Hierarchy

All files on a Linux system are stored on file systems, which are organized into a single inverted tree of directories, known as a file-system hierarchy. This tree is inverted because the root of the tree is said to be at the top of the hierarchy, and the branches of directories and subdirectories stretch below the root.

Figure 2.1: Significant file-system directories in Red Hat Enterprise Linux 8

The / directory is the root directory at the top of the file-system hierarchy. The / character is also used as a directory separator in file names. For example, if etc is a subdirectory of the / directory, you could refer to that directory as /etc. Likewise, if the /etc directory contained a file named issue, you could refer to that file as /etc/issue.

Subdirectories of / are used for standardized purposes to organize files by type and purpose. This makes it easier to find files. For example, in the root directory, the subdirectory /boot is used for storing files needed to boot the system.

Note

The following terms help to describe file-system directory contents:

  • static content remains unchanged until explicitly edited or reconfigured.

  • dynamic or variable content may be modified or appended by active processes.

  • persistent content remains after a reboot, like configuration settings.

  • runtime content is process- or system-specific content that is deleted by a reboot.

The following table lists some of the most important directories on the system by name and purpose.

Table 2.1. Important Red Hat Enterprise Linux Directories

LocationPurpose
/usr Installed software, shared libraries, include files, and read-only program data. Important subdirectories include:
  • /usr/bin: User commands.

  • /usr/sbin: System administration commands.

  • /usr/local: Locally customized software.

/etc Configuration files specific to this system.
/var Variable data specific to this system that should persist between boots. Files that dynamically change, such as databases, cache directories, log files, printer-spooled documents, and website content may be found under /var.
/run Runtime data for processes started since the last boot. This includes process ID files and lock files, among other things. The contents of this directory are recreated on reboot. This directory consolidates /var/run and /var/lock from earlier versions of Red Hat Enterprise Linux.
/home Home directories are where regular users store their personal data and configuration files.
/root Home directory for the administrative superuser, root.
/tmp A world-writable space for temporary files. Files which have not been accessed, changed, or modified for 10 days are deleted from this directory automatically. Another temporary directory exists, /var/tmp, in which files that have not been accessed, changed, or modified in more than 30 days are deleted automatically.
/boot Files needed in order to start the boot process.
/dev Contains special device files that are used by the system to access hardware.

Important

In Red Hat Enterprise Linux 7 and later, four older directories in / have identical contents to their counterparts located in /usr:

  • /bin and /usr/bin

  • /sbin and /usr/sbin

  • /lib and /usr/lib

  • /lib64 and /usr/lib64

In earlier versions of Red Hat Enterprise Linux, these were distinct directories containing different sets of files.

In Red Hat Enterprise Linux 7 and later, the directories in / are symbolic links to the matching directories in /usr.

References

hier(7) man page

The UsrMove feature page from Fedora 17

Revision: rh199-8.2-3beeb12