Filesystem hierarchy standard is maintained by the Linux Foundation, which defines the structure and contents of directories in various distributions of Linux.

img

Linux File System on CentOS 7 Distribution

File System Hierarchy

File System Hierarchy

Let's look at what each of these directories means and what types of files are suitable for each of them.

bin

Soft link of /usr/bin directory, those are users’ executable binary files.

More…

boot

Here are the files that the Linux system uses during its booting period.

More…

dev

The files mapped from the hardware device are stored here.

More…

etc

The configuration files for almost all programs are placed in this directory.

More…

home

The home directory of the users, this directory contains information about each user, such as startup parameters, and so on.

More…

lib

Soft link of /usr/lib, stores library, contains kernel module files, static and dynamic libraries.

More…

lib64

Soft link of /usr/lib64, stores 64-bits libraries.

More…

media

Mount point directory, contains portable devices.

More…

media

Mount point directory, contains extra temporary file systems.

More…

opt

Optional directory, contains third-party programs.

More…

proc

Mapping files of kernel details.

More…

root

Root user’s home directory

More…

sbin

Soft link of /usr/sbin, stores administrator’s executable binary files.

More…

sys

A pseudo file system, contains hardware details mapped files

More…

tmp

It is usually to store some newly downloaded installation packages that will be deleted immediately after the installation has been completed.

More…

var

This directory is used to store files whose contents change frequently, and the program logs are generally stored here because the program often needs to read and write the record at the run time so that administrators can quickly locate the problem.

More…

File Types

When you use the “ll” command to list all files in a directory, the first letter of each line is the type of file. Linux has 7 file types that can be classified into these 3 categories:

  • Regular file types
  • Directory file types
  • Special file types

File Types

Let's look at each of the 7 file types.

d (Directory file types category)

Each line of information printed by command “ll” begins with letter d is a directory file type.

More…

- (Regular file types category)

Each line of information printed by command “ll” begins with symbol - is a regular file type.

More…

l (Special file types category)

Each line of information printed by command “ll” begins with letter l is a symbolic link file type.

More…

c (Special file types category)

Each line of information printed by command “ll” begins with letter c is a character device file type.

More…

s (Special file types category)

Each line of information printed by command “ll” begins with letter s is a socket file type.

More…

b (Special file types category)

Each line of information printed by command “ll” begins with letter b is a block file type.

More…

p (Special file types category)

Each line of information printed by command “ll” begins with letter p is a named pipe file type.

More…

File Naming Conventions

  • No more than 255 characters in length
  • The filename can’t contain slashes (/)
  • Filenames are case-sensitive

File Paths

  • Relative path: Starts from current directory, such as ./..
  • Absolute path: Starts from root directory, such as /..

References Filesystem Hierarchy Standard, FilesystemHierarchyStandard, File types In Linux/Unix explained in detail, File Naming Conventions in Linux

Buy me a coffeeBuy me a coffee