A Quick Overview of Linux File System

One of the most frustrating things about mastering a new OS can be figuring out where it keep files. Instead of keeping all important system files in a single directory, such as C:\Windows directory in MS Windows, Linux follows the lead of its UNIX cousins and spreads things out a bit more. Although the Linux and Windows setups involve different methods, they are both logical.

Linux may be all by itself on your hard drive, or may be it’s sharing your hard drive with another OS, such MS Windows. All the hard drive space you allocated for Linux during the installation process is the majority of your Linux filesystem.

The root Directory

Everything in the Linux filesystem is relative to the root directory, which is referred to as / and is the file-system base, a doorway into all your files.

Also Read: Top 77 Linux Interview Questions to Ask Candidates

The root directory refers to the highest layer of the file system tree. Normally only directories (not files) are located here. When the system is booted, the partition on which this directory is located is the first one mounted.

Because the kernel cannot fulfill all the tasks of the operating system, all programs that are run at the system start must be available on this partition.

The following directories always have to be on the same partition as the root directory: /bin, /dev/, /etc/, /lib/, and /sbin/.

S.No. Directory Description
1 /bin Essential commands that everyone needs to use at any time.
2 /boot The information that boots the machine, including your kernel.
3 /dev The device drivers for all the hardware that your system needs to interface with.
4 /etc The configuration files for you system.
5 /home The home directories for each of your users.
6 /lib The libraries, or code that many programs (and the kernel) use.
7 /media A spot where you add temporary media, such as floppy disks and CD-ROMs; not all distributions have this directory.
8 /mnt A spot where you add extra file system components such as networked drives, items you aren’t permanently adding to your file system but that aren’t as temporary as CD-ROMs and floppies.
9 /opt The location that some people decide to use (and some programs want to use) for installing new software packages, such as word processors and office suites.
10 /proc Current setting for your kernel (operating system).
11 /root The superuser’s (root user’s) home directory.
12 /sbin The commands the system administrator needs access to.
13 /srv Data for your system’s services (the programs that run in the background).
14 /sys Kernel information about your hardware.
15 /tmp The place where everyone and everything stores temporary files.
16 /usr A complex hierarchy of additional programs and files.
17 /var The data that changes frequently, such as log files and your mail.

Essential Binaries

The directory /bin/ contains important executable programs that are required when no other file systems are mounted, such as all programs necessary for the system start.

These include the various shells, the most important commands for working with files, and several commands for system analysis and configuration.

The following table provides an overview of the contents of the /bin/ directory:

S.No. Directory Description
1 /bin/bash The bash shell
2 /bin/cat Displaying files
3 /bin/cp Copying files
4 /bin/dd Copying files byte-wise
5 /bin/gzip Compressing files
6 /bin/mount Mounting file systems
7 /bin/rm Deleting files
8 /bin/vi Vi editor

Configuration Files

This directory and its subdirectories contain system configuration files. Almost all these files are ASCII files, which can be processed with any editor.

Normal users can read nearly all of these files, but they cannot edit any of them. According to the FHS, no executable programs can be located here.

However, the subdirectories contain many shell scripts. Some important configuration files are listed in the following table:

S.No. Directory Description
1 /etc/SuSE-release Version number of the installed SUSE Linux Enterprise Server
2 /etc/inittab Configuration file for the init process
3 /etc/init.d/* Scripts for starting services
4 /etc/grub/conf Configuration file of GRUB
5 /etc/modules.conf Configuration file of the kernel modules
6 /etc/DIR_COLORS Specifies the colors for 1s.
7 /etc/X11/XF86config Configuration file of the X window System.
8 /etc/fstab Table of the file systems automatically mounted at the system start.
9 /etc/profile Login script of the shell.
10 /etc/passwd User database; all information except passwords.
11 /etc/shadow Encrypted passwords of users.
12 /etc/group Database of user groups.
13 /etc/cups/* Files for the CUPS printing system.
14 /etc/hosts Allocation of computer names to IP addresses.
15 /etc/motd Welcome message after a user logs in (message of the day)
16 /etc/issue Linux welcome message before the login prompt.
17 /etc/sysconfig/* Central configuration files of the system.

System Binaries

The directory /sbin/ contains important programs for system administration. Programs that are run by normal users as well as located in /bin/.

Programs in the directory /sbin/ can also, as a rule, be run by normal users, but only to display the configured values. Changes to the configuration can only be made by the user root.

The following is an overview of important files in the directory /sbin/.

S.No. Directory Description
1 /sbin/SuSEconfig Used to configure the overall system; evaluates entries in the configuration files in the directory/etc/sysconfig/ and writes further configuration files.
2 /sbin/conf.d* Contains more scripts from the SuSEconfig family. They are called up by /sbin/SuSEconfig.
3 /sbin/yast Administration tool for SUSE Linux Enterprise Server.
4 /sbin/fdisk Modifies partitions.
5 /sbin/fsck Checks file systems (file system check).
6 /sbin/init Initializes the system.
7 /sbin/mkfs Creates a file system (formatting).
8 /sbin/shutdown Shuts down the system.

/usr Directory Files

The directory /usr/, in accordance with the FHS, represents a second hierarchical layer.

This is the location for all application programs, graphical interface files, additional libraries, locally installed programs, and commonly shared directories containing documentation.

These include the following:

S.No. Directory Description
1 /usr/X11R6/ Files of the X Window System
2 /usr/lib/ Libraries
3 /usr/bin/ Almost all executable programs
4 /usr/local/ Locally installed programs, now frequently found in the directory /opt/
5 /usr/sbin/ Programs for system administration
6 /usr/share/doc/ Documentation
7 /usr/Share/man/ The manual pages (Command descriptions)
8 /usr/src/ Source files of all programs and the kernel (if installed)

Variable Files

This directory and its subdirectories contain files are located that can be modified while the system is running.

The following table provides an overview of the most important directories beneath /var/:

S.No. Directory Description
1 /var/lib/ Variable libraries (such as databases for the commands Locate and rpm)
2 /var/log/ Log files for most services
3 /var/run/ Files with information on running processes
4 /var/spool/ Directory for queues (printers,email)
5 /var/lock/ Lock files to protect devices from multiple use

Process Files

Linux handles process information that is made available to users via the directory /proc/. This directory does not contain any real files and therefore does not occupy and space on the hard disk.

It is generated dynamically when it is accessed. Each process has its own directory. The values in these directories can be read out as if they were in a file. Some values can also be set by writing to the corresponding files. Changes to this virtual file system only have an effect as long as the system is running.

In addition to directories for each individual process, /proc/ also includes directories and files containing information about the state of the system.

The following are the most important of these:

S.No. Directory Description
1 /proc/cpuinfo Information about the processor
2 /proc/dma Use of the DMA ports (Direct Memory Access)
3 /proc/interrupts Use of the interrupt
4 /proc/ioports Use of the intrasystem I/O ports
5 /proc/filesystems File system formats that the kernel understands
6 /proc/modules Active modules
7 /proc/mounts Mounted file systems
8 /proc/net/* Network-specific information and statistics in human-readable form
9 /proc/partitions Existing partitions
10 /proc/pci Existing PCI devices
11 /proc/scsi/ Connected SCSI devices
12 /proc/sys/* System and kernel information
13 /proc/version Kernel version

Directories That Cannot Be Exported

The following directories cannot be exported. They must always be located locally on each computer.

S.No. Directory Description
1 /bin/ Important programs
2 /boot/ Kernel and boot files
3 /dev/ Device files
4 /etc/ Configuration files
5 /lib/ Libraries
6 /sbin/ Important programs for system administration

Shared Directories

The following directories can be shared:

S.No. Directory Description
1 /home/ Home directories
2 /opt/ Applications
3 /usr/ The Hierarchy below /usr/

Device Files

Each hardware component existing in the system such as hard drive partitions, CD drives, printer, and mouse is represented as a file in the directory /dev/.

The hardware components are addressed via these files by writing to or reading from one of these files. Two find of device files are included:

  • Character-oriented device files – For devices working sequentially, such as Printer, Mouse or Tape Drive
  • Block-oriented device files – Such as Floppy disks and hard drives
S.No. Device Device File Description
1 Terminals dev/console
/dev/tty1
The system console
The first virtual console, reachable with Ctrl+Alt+F1.
2 Serial ports /dev/ttyS0
/dev/ttyS*
The first serial port.
3 Parallel Ports /dev/lp0
/dev/lp*
The first parallel port
4 Floppy disk drives /dev/fd0<
/dev/fd*
The first floppy disk drive. if the drives are addressed via the device files fd0 and fd1, the kernel tries to recognize the floppy disk format itself.
5 IDE hard drives /dev/hda
/dev/hdc
/dev/hd*
The first IDE hard drive on the first IDE controller.
The first IDE hard drive on the second IDE controller.
To label the partitions, the device names are given numbers.
6 IDE CD-ROM drives /dev/hd* The drives are named in the same way as the IDE hard drives. This means that is the second drive on the second IDE controller.
7 CD-ROM drive /dev/hdd
8 SCSI hard drives /dev/sda
/dev/sda*
/dev/sda1
The first SCSI hard drive.
With SCSI hard drives, the device names are given numbers to label the various partitions. For example, is the first primary partition on the first SCSI hard drive.
9 SCSI CD-ROM drives /dev/scd0
/dev/scd*
The first SCSI CD-ROM drive.
You may also like:

Related Posts

Leave a Reply