Things Everyone Should know about Linux Filesystem Hierarchy

      Comments Off on Things Everyone Should know about Linux Filesystem Hierarchy

Linux Filesystem Hierarchy

Linux filesystem is the partition which contains every directories, files and mounted devices. / is the symbol which provided to root file system which is the parent directory of all other directories in Linux.

  • Directories are nothing but folders in windows.
  • File is the collections of data
  • Folder is the collections of file

Directories present inside Root Filesystem:

/bin : This is Binary executable Filesystem, It usually contains the shells like bash, sh, csh etc and all commonly used commands

/sbin: This is standard subdirectory of the root directory in Linux operating system which contains Superbinary commands. Most of this commands can only run with administrator privilege, Most of them are administrative tools.

/boot: Booting file is the starting file which used to run the system. /boot contains booting files which contains the boot information which shows when we boot the system.

/root: Home directory of root user

/home: User’s home directory. example, /home/ubuntu

/media: Auto mount point of the system, when we connect any external storage devices like pen drive to the system it will be mounted in this media directory automatically.
Mount will happen by generating a UID by the kernel. If your system does not have this media directory, external devices which we are connecting will not be mounted automatically, for that we should create one media directory inside root[/].

/mnt: mnt is Administrative mount point, when there is no media folder we can mount our devices in /mnt by using mount command,

# mount /dev/sdb1 /mnt
# umount /dev/sdb1

/dev: This /dev all device files, all devices will detect here including our hard disk. It contains block devices, character files, pipelines, communication ports, and every peripherals.

/tmp: temporary filesystem where we can keep our temporary files which is not needed after a certain period of time, everyuser in the system has access to the /tmp file but no one can delete otherusers files because of stickybit permission.
Files inside this directory will be cleaned /etc/init/mounted-tmp.conf this upstart script, this script will delete all the old files and empty directories after $TMPTIME days, we can set the dates in /etc/default/rcS file and if you want to disable set value -1 to $TMPTIME inside this file.

/proc: /proc is a virtual filesystem, it contains runtime system information. it includes a directory for each running process, including kernel processes, in directories named /proc/PID, where PID is the process number. Each directory contains information about one process, including: /proc/PID/cmdline, the command that originally started the process.
It also contains information about the drivers, physical terminal, system and etc.

/etc: /etc contains many system configuration files. In this directory all of the files are text files which used to change configuration of specific services.

/usr: /usr contains all the user binaries, their documentation, libraries, header files, etc

/opt: /opt is the optional package directory. This directory is reserved for all the software and add-on packages that are not part of the default installation. For example, StarOffice, Kylix, Netscape Communicator and WordPerfect packages are normally found here.
/opt is a directory for installing unbundled packages, install each package in its own subdirectory. They are already built whole packages provided by an independent third party software distributor. This is not like /usr/local, these packages follow the directory conventions. For example, our custom app will be installed in /opt/app, with one of its command being /opt/app/bin/cmd, its configuration file would be in /etc/opt/app/cmd.conf, and its log files in /var/opt/app/logs/cmd.access.

/srv: Service link variable, /srv/ directory contains site-specific data served by your RHEL system. /srv will give the location of data files for particular services to the user.

/sys: /sys is also a virtual filesystem. It contains the kernel provides information about the physical and virtual devices.

/var: /var is an variable filesystem which contains the files which are vary in size everytime, it contains many log files, mails, cron and at jobs, ftp and http files.

/lib: It is library filesystem, The /lib directory contains those shared library images needed to boot the system and run the commands in the root filesystem, ie. by binaries in /bin and /sbin. You can find one useful conversation here

/lib64: This is also Library filesystem but it contains 64bits objects, There may be one or more variants of the /lib directory on systems which support more than one binary format requiring separate libraries. This is seperated from lib to avoid service crashes.

/selinux: Security-Enhanced Linux (SELinux), which is responsible for the policies and security of Linux permissions, configuration, etc.

/lost+found: You can find one useful conversation here

Linux Filesystem Hierarchy is one of the main things every beginners should know.

Sharing is caring!

About Dinesh Sobitharaj C

An IT professional having multiple years of experience in IT Infrastructure planning, System integrations, Project implementation and delivery. Devops Enthusiast skilled with broad ranges of technology adoption. Well versed with Cloud Computing and Application Service Offerings such as SaaS/PaaS/IaaS. Expert in aligning business goals, mission and process to architect innovative solutions and strategies.