Introduction to the Linux file system and directory structure

File system format in linux

Linux can have many different file system formats which for someone that is used to Windows is a bit different because in Windows you never have to worry about it because Microsoft just defaults to NTFS.
Because it is open source it offers many different options. Linux not limit users or administrators in the file system they should use.

The file system is basically the way that data is stored on the hard drive, SSD or whatever storage medium you are using.

Most Linux file systems include a feature called journalling. Journalling is used to reduce the chance of file corruption, it does this by keeping a track of files that are being written to disk. If power is lost while data is being written to the disk then it can check the journal when the power comes back on and be able to remember where it left off.
The only issue with journaling is that there may be some performance decrease, but with modern hardware you will not be able to notice the difference.

Some of the file systems you can choose from are:

Linux’s directory structure

If you are new to Linux and used to Windows the way the Linux’s directory structure is layer out can be quite difficult to understand.

Everything in Linux is located under the / directory which is known as the root directory. This is sort of like the C: drive in Windows, but Linux does not actually give drive letters at all. Where a different partition in windows would show up as a different drive letter in lines it will just show as another directory under the root directory.

/etc – Configuration Files

Contains configuration files required by all programs.
This is also where the startup and shutdown shell scripts used to start and stop individual programs.
For example: /etc/resolv.conf, /etc/logrotate.conf

/sbin – System Binaries

Just like /bin, /sbin also contains binary executables.
The commands under the /sbin directory are more geared towards system maintenance purposes and will be regularly used by system administrators.
For example: iptables, reboot, fdisk, ifconfig

/dev – Device Filess

Contains device files.
These include terminal devices, usb, or any device attached to the system.
For example: /dev/tty1, /dev/usbmon0

/proc – Process Informations

Contains information about system process.
This is a pseudo filesystem contains information about running process. For example: /proc/{pid} directory contains information about the process with that particular pid.
This is a virtual filesystem with text information about system resources. For example: /proc/uptime

/var – Variable Filess

var stands for variable files.
Content of the files that are expected to grow can be found under this directory.
This includes — system log files (/var/log); packages and database files (/var/lib); emails (/var/mail); print queues (/var/spool); lock files (/var/lock); temp files needed across reboots (/var/tmp);

/usr – User Programss

Contains binaries, libraries, documentation, and source-code for second level programs.
/usr/bin contains binary files for user programs. If you can’t find a user binary under /bin, look under /usr/bin. For example: at, awk, cc, less, scp
/usr/sbin contains binary files for system administrators. If you can’t find a system binary under /sbin, look under /usr/sbin. For example: atd, cron, sshd, useradd, userdel
/usr/lib contains libraries for /usr/bin and /usr/sbin
/usr/local contains users programs that you install from source. For example, when you install apache from source, it goes under /usr/local/apache2

/lib – System Libraries

Contains library files that supports the binaries located under /bin and /sbin
Library filenames are either ld* or lib*.so.*
For example: ld-2.11.1.so, libncurses.so.5.7

/opt – Optional add-on Applicationss

opt stands for optional and it contains add-on applications from individual vendors.
add-on applications should be installed under either /opt/ or /opt/ sub-directory.

/srv – Service Data

srv stands for service. Contains server specific services related data.
For example, /srv/cvs contains CVS related data.

/media – Removable Media Devicess

Temporary mount directory for removable devices.
For examples, /media/cdrom for CD-ROM; /media/floppy for floppy drives; /media/cdrecorder for CD writer

/mnt – Mount Directorys

Temporary mount directory where sysadmins can mount filesystems.

/boot – Boot Loader Filess

Contains boot loader related files.
Kernel initrd, vmlinux, grub files are located under /boot
For example: initrd.img-2.6.32-24-generic, vmlinuz-2.6.32-24-generic

/home – Home Directories

Home directories for all users to store their personal files.
For example: /home/user and /home/jake