An Outline of Linux File System

Aryan Singhal
4 min readNov 30, 2021

--

One of the first things you need to understand about GNU / Linux is the file system. The Linux file system follows UNIX rules and is very simple. However, if you are new to Linux, especially if you accustomed to Windows for a while, you still need some understanding.

In simple terms the Linux file system has a single tree structure. There is one root and all files and folder branch of it. Storage devices are connected as branches, like any other folder, rather than a separate tree structure (such as a separate Windows drive letter).

In Linux everything is a File

It may sound confusing, but it’s actually a very simple concept. All data files, devices, processes, etc. are treated as files and users can manipulate them that way, which makes the task much easier.
Suppose you want to clone a storage device. Just copy the file with the name of the device to the destination. You can also use the file as a storage device (virtual hard drive) without doing anything special. It’s as easy as that.

The Linux File System

Path

Path is the notation used to indicate the location of a file or folder in the Linux file system. There are two types of paths: absolute paths and relative paths.
Absolute path is the entire path of the file from the root directory. Example: suppose a file named myFile.txt is being stored in the home directory under the ‘docs’ sub directory which is inside another directory called ‘my-docs’, then its absolute path would be:

/home/docs/my-docs/myFile.txt

Relative path are the paths of files or folders relative to the current directory in which the user is located. So if you are currently working in the /home/docs folder, the relative path to the above files would be:

my-docs/myFile.txt

Mount

Mount is a Linux way to open a storage device for access.

Mounting a device

Suppose you want to open a pen drive on a Linux computer. Two steps are required.
First, connect the USB stick to one of the USB ports. An entry indicating the USB stick (probably / dev / sdb1 etc.) is created in the / dev directory. However, the files contained therein are not yet accessible. To do this, the following steps are required.
Next, mount the device (/ dev / sdb1) in the selected folder. You can mount your device in virtually any folder, including non-empty folders. At this point, you can access the files on your USB stick by simply opening the mounted folder.

For example you can mount the device to a folder named /mnt/pendrive.

On Linux, you can use the mount command to perform the mount. In the above example, the command is: -
mount / dev / sdb1 / mnt / pendrive
(Note that mounting the device requires user authentication, which will be explained later)
Now if the device is a Linux filesystem, / You can see its contents by opening the mnt / pendrive folder.

Permissions

Perhaps the best thing about Linux filesystems is file permissions. Every file and folder has strict rules that specify which users on your system can view or modify it.
Linux is a multi-user operating system. Root is a top user of Linux systems that can do absolutely anything. This usually means that it is not safe to use the system as the root, as it can accidentally modify system files and run malicious programs. For this reason, users typically log on to the system as a non-root user, and if they need to execute privileged commands, prefix the sudo command to increase access levels. —

sudo mount / dev / sdb1 / mnt / pendrive

Now every file in the Linux filesystem has two ownerships, user and group (group is a collection of users). That means there can be three types of people who might try to access a file —

  1. The user who owns the file
  2. The user group the file belongs to
  3. Anyone else who is not part of the group

In Linux Filesystem there can be three modes of file access —

  1. Read
  2. Write
  3. Execute

Therefore, there can be 3x3 equal to a total of 9 combinations. These combinations can be identified by nine consecutive letters. The first three letters are the user, the middle three letters are the group, and the last three letters are the other letters. For example, suppose the file has the following permissions: rwxr-x-x. That is, the owner of the file has all permissions on the file, the group can only read and execute the file, it cannot be modified, and other users can only execute the file.

Links

A link is a file that references another file. There are two types of links in the Linux file system.

Soft link: they are also known as a symbolic link. These refer to files in different locations. Symbolic links can span different drives.
Hardlinks: Hardlinks are like duplicate entries in the same file. Can only be used within the same drive.

Conclusion

The Linux file system is simple. However, it takes a little understanding to become fluent in Linux. This article provides some basics for understanding how Linux handles filesystems. Familiarity with the system requires effort and patience. Therefore, it’s a good idea to try some of the file operations yourself to get used to Linux machines.

--

--