| by Arround The Web | No comments

What is a Filesystem in Linux

Linux is widely known for its robust filesystem. This hierarchical structure stores and organizes all kinds of data, including files and directories. It offers disk fragmentations, symbolic linking, journaling, file permission management, and more. Hence, a beginner must understand the basics of Linux’s filesystem to navigate and manage the system efficiently. In this article, you will get to know about the fundamentals of the filesystem and explore its various types. We have also included the directory structure and the commands essential for you to get started. 

Types of Filesystems

You’re not bound to use only the default filesystem when using Linux. It supports a few filesystems which you can install on your devices:

  1. Fourth Extended Filesystem(ext4): This is the default and the most widely used filesystem in many Linux distributions.
  2. X Filesystem(XFS): This file system is commonly used in enterprises. Its most prominent features are its scalability and performance.
  3. B-Tree Filesystem(Btrfs): This is the latest and most modern filesystem, which lets you take snapshots, create subvolumes, and more. It can be used in systems where you want advanced functionalities.

Basic Directory Structure

Regardless of their types, every filesystem in Linux follows a hierarchical tree-like structure that forms its backbone. It lays the foundation for many concepts, like navigation and management of files. Furthermore, the root directory is usually represented by ‘/,’ and all other directories branch from the root itself. Following is a list of other essential directories that you should know:

/bin: Bin is binary and contains all binary executables required for system boot and repair. It is the storage house of standard system utilities like mv, rm, ls, etc. Moreover, anything stored in this directory is accessible to all the users.

/tmp: This is a temporary storage location for files that are not significant beyond the current session. Your system clears all these files upon reboot.

/boot: During boot, operating systems refer to some files such as Kernel images, bootloader configuration files, and initial RAM disk files. The /boot directory holds those files and is crucial for kernel upgrades.

/etc: This directory comprises the configuration files for system-wide applications and settings. For example, /etc/passwd stores user password information, and /etc/hosts stores network configurations. You can modify these files to customize system behavior.

/home: When multiple users use a single system, most get their home directories for their personal space. The subdirectories within the /home directory correspond to users who have read, write, and execute permission in their respective directories.  

/sbin: Like binaries, the sbin directory consists of essential system binaries. On the contrary, you must have the root privileges for execution. For example, it stores utilities like fdisk, ifconfig, and iptables.

/var: It stores variable data, such as log files and spool directories, that changes while you operate the system. Administrators can monitor and manage its contents to ensure proper system functioning and resource utilization.

Common Commands

The cd command lets you change your current directory.

cd /path

Put your desired path in place of /path, and it will move you to that path. The ls command displays the contents of a directory, for example:

ls

The mv command helps move and rename files.

mv file_name.txt target_location

Here, replace file_name.txt with the name of the file you want to relocate and mention the intended new path in place of target_location. You can copy files or directories to a specific path using the cp command. For instance:

cp file_name.txt /path

With the rm command, you can delete any file. However, you should do it carefully, as the deleted files won’t be recoverable. For example:

rm file.txt

A Quick Wrap-up

Understanding the filesystem is essential for any Linux user, whether a beginner or an experienced professional. Hence, this guide explores its various aspects, starting from different types of filesystems. We also looked at the directory structure and discussed using various prebuilt directories. At last, we explained the common commands you would need while navigating your systems.

Share Button

Source: linuxhint.com

Leave a Reply