Linux file System and Naming Convention Explained

This tutorial explains the Linux file system (Linux directory structure) and the naming convention in detail. Learn how Linux organizes the file system.

What is the Linux file system?

A file is a method of storing data in modern operating systems. A file may contain any meaningful data. For example, a file may store a compiled software program, a script, a letter, a user database, a picture, a video, an audio clip, etc.

Generally, computers and servers use hard disks to store data. Hard disks are usually divided into many blocks. These blocks are used to store files. Depending on the amount of data in the file, a file may use one or more blocks. When files are created and deleted, blocks are used and freed, respectively.

The kernel of Linux includes a program that allows users and other programs to create, modify, retrieve, delete, and manipulate files. This program is known as the file storage system or simply the file system.

Almost every bit of data and programming that is needed to boot a Linux system and keep it working is saved in the file system. For example, the operating system itself, compilers, application programs, shared libraries, network servers, documentation, system administration and configuration files, log files, media mount points, temporary scratch areas, user database files, and so on.

The File System Standard (FSSTND)

The Linux kernel is freely available to all. Anyone can make and distribute his own Linux. Due to this, several flavors of Linux exist. These flavors are known as distributions. Normally all distributions follow the FSSTND (File System Standard) in organizing the file system hierarchy.

The File System Standard (FSSTND) sets standard locations for important system files. This feature not only allows users to find important system files at the same location in the file system of any Linux flavor but also makes it easy for users to work on any Linux system.

The FSSTND organizes all important files in directories. It starts the Linux file system hierarchy with a directory known as the root (/) directory. All files and directories are created and managed under this (root) directory.

Since the root directory stands on the top of the file system, it has no parent directory. Besides the root directory, every directory has a parent directory. Linux allows us to create as many files and directories as we want. We can create files under the existing directories or may create new directories.

System Directories

System directories contain files, software, applications, and scripts that are required to run and maintain the Linux. System directories are automatically created during the installation. The following figure illustrates some important system directories with their location in LFS (Linux file system).

Linux file system

Linux Directory Structure (File System Structure)

The following table lists the important system directories and their role in the Linux file system.

Directory Description
/ This is the first directory in the Linux file system. It is also known as the root directory or the main directory. All files and directories are created and managed under this directory.
/home This is the default directory for user data. Whenever we add a new user, Linux automatically creates a home directory matching with his username in this directory. Linux puts the user in his home directory just after the login.
/root This is the home directory of the root user. The root user is the superuser in Linux. For security reasons, Linux creates a separate home directory for the root user.
/bin This directory contains standard command files. Commands stored in this directory are available for all users and usually do not require any special permission to run.
/sbin This directory contains system administration commands files. Commands stored in this directory are available only for super users and usually require special privileges to run.
/usr This directory contains user application software files, third party software and scripts, document files, and libraries for programming languages.
/var This directory stores variable data files such as printing jobs, and mailbox.
/etc This directory contains system configuration files.
/boot This directory contains Linux boot loader files.
/mnt This directory is used to mount the remote file system and temporary devices such as CD, DVD, and USB.
/dev This directory contains device files. Usually, files in this directory are dynamically generated and should be never edited.
/tmp This directory provides a temporary location for applications.

Linux File Naming Convention

Unlike Windows, Linux is not strict with the naming convention. We can use any number or letter in a file name. We can also use an underscore, space, period, and comma. Some special characters such as a question mark, asterisk, and slash are not allowed in a file name. These characters are reserved for shell functions. Just like Windows, we can use a dot to create a file extension. Although file extensions are not compulsory in Linux, still they should be used wherever possible as they provide a good way to manage files.

Key points
  • A file name can contain any character or number.
  • The maximum length for a file name is 256 characters.
  • A file name can use a space, underscore, minus, period, and comma.
  • A file name cannot use a question mark, asterisk, and slash.
  • A file extension is not compulsory. A file can be created with or without an extension.
  • A file whose name starts with a period (.) is treated as a hidden file.
  • If a file name contains a white space, it needs to be quoted before it can be accessed at the command prompt.

That's all for this tutorial. If you like this tutorial, please don't forget to share it with friends through your favorite social network.

ComputerNetworkingNotes Linux Tutorials Linux file System and Naming Convention Explained