DEV Community

Cover image for Linux and its way of storing files...
Dipanshu Torawane for Kubernetes Community Days Chennai

Posted on • Edited on

Linux and its way of storing files...

What is the Linux File System?

The file system is generally a built-in layer of a Linux operating system used to handle the data management of the storage. It helps to arrange the file on disk storage and manages the file name, file size, creation date, and much more information about a file.

The Linux file system is a structured collection of files on a disk drive or a partition. A partition is a segment of memory that contains some specific data. In our machine, there can be various partitions of memory. Generally, every partition contains a file system.

The files are stored in the hierarchical tree structure. Root folder comes first and then files are under root respectively. Whereas in windows, files are stored in folders on different data drives like C: D: E:

lfs.jpg

Linux File System Overview

Filesystem Hierarchy Structure (FHS) in Linux – TecAdmin

/ or /root => root user's home directory which is separate from other users

/home => contains the home directories of all non-root users.

/bin(stands for binaries) => executables for most essential user commands(all files are system-wide usable)

What is binary?

A binary is just a computer-readable format (a bunch of 0's & 1's)

/sbin(system binaries) => essential system binaries, programs that admin would use(need superuser privileges)

/lib, /lib32, /lib64, /libx32 => essential shared libraries that executables from /bin or /sbin use.

/usr(user) => this was used for user home or directories*(contains the same* /bin, /sbin, /lib folders).

Why do /usr contain these folders?

  • historic reasons(as UNIX also had those splits)

  • Because of storage limitations, it was split to root binary folders ad user binary folders.

NOTE: When we execute basic Linux commands they are executed from /usr/bin folder. In other distros, /bin or /sbin contains fewer commands and /usr/bin or /sbin contains all other commands.

Inside /usr, there is a folder /local that also contains the same files as /usr(/bin or /sbin or /lib).

/usr/local => programs that you install on the computer. Third-party applications like docker, minikube, etc go here. Programs installed here will be available for all users on the computer.

NOTE: If you want to install third-party applications and don't want to be accessed by all the other users then you install them on your own /home directory.

/boot(booting) => contains files required for booting.

/opt(optional) => third-party programs you install(all programs will be available system-wide).

Difference between /usr/local & /opt:-

  • /usr/local: programs that split into their components.

  • /opt: programs which not split into their components.

NOTE: Till now all folders are read-only folders.

/etc(et cetera) => a place where the configuration for system-wide applications is stored. Originally for etc*(means everything else goes there)*. It emerged into the main configuration location.

/dev(devices) => location of device files like webcam, keyboard, hard drives, etc. Apps and Drivers will access this, NOT the user.

/var(variable) => contains files to which the system writes data during the course of its operation.

/var/log => contains log files.

/var/cache => contains cached data from application programs.

/tmp(temporary) => temporary resources required for some processes kept here temporarily.

/media(removable media) => contains subdirectories where removable media devices inserted into the computer are mounted. For example, when you insert a CD, a directory will automatically be created and you can access the contents of the CD inside the directory.

/mnt(temporary mount points) => historically, sysadmins mounted temporary file systems there(or manually mounting folders).

Interacting with these folders

Usually, you are not interacting with these folders. Installing apps with a package manager is responsible to store the required files in the right corresponding folders.

Hidden Files

These are primarily used to help prevent important data from being accidentally deleted and are automatically generated by programs or operating system. The file name starts with .(dot). These are also called 'dotfiles'.

hide-folders-ubuntu-linux.webp

Top comments (0)