18

Files and directories in Linux 6

Embed Size (px)

Citation preview

Linux files are organized in a logical fashion for ease of administration.

This logical division of files is maintained in hundreds of directories that are located in larger containers called file system.

RED HAT LINUX follows the FILE SYSTEM Hierarchy standard(FHS) for file organization.

FILE SYSTEM Disk Based:

DISK-based file systems are created on physical media such as a hard disk.

Memory- Based:

Memory- based file systems, also called virtual file system, are created at system boot up and destroyed at shut down.

FILE SYSTEM TREE The Linux file system structure is like an inverted tree

with the root of the tree at the top and branches and leaves at bottom.

The top level is referred to as root and represented by forward slash(/) character.

Two file systems -/ and /boot- are created, by default, when RHEL is installed.

The custom installation procedure provided later in this, also creates /var, /usr,/tmp,/opt and /home file systems in addition to / and /boot.

FILE SYSTEM TREE• These directories hold Static and Dynamic(or variable)

information.

The Static refers to file contents that are not usually modified.

Static dir normally contain cmds, lib routines, kernel files, devices files, etc.

The Dynamic or variable data refers to file contents that are modified as required.

DD hold log files, status files, configuration files, temporary files, etc.

RHEL provides a graphical file manager called nautilusthat can be used to view and navigate within the directory structure.

Linux Directory Hierarchy

The Binary directory (/bin): The binary directory contains crucial user executable

commands. This directory holds static data files.

The library directory (/lib): The library directory contains shared library files required by

programs. It contains sub-directories that hold static data files.

The System Binary Directory (/sbin): Most commands required at system up are located in the

system binary directory. In addition, most cmds requiring root privileges to run are

also located here. The /sbin dir holds static data files.

The etcetera directory(/etc): The etcetera directory holds most configuration files.

The /etc dir contains dynamic data files.

The lost+ found dir(/lost+found): This directory is used to hold files that become orphan after

system crash.

An orphan file is a file that has lost its name and it holds dynamic data.

/root: This is default home directory location for the root user.

/srv: This dir holds server data associated with database, website,

etc.

/boot: It contains linux kernels, boot loader and boot configuration

files in addition to other files required to boot RHEL.

The /boot file system contains static data files.

/var: /var contains data that frequently change while the system is

up and running.

UNIX system Resoucres file system(/usr): Disk based, this file system contains general files related to

the system.

ext2 The ext2 or second extended filesystem is a file system

for the Linux kernel.

It was initially designed by Rémy Card as a replacement for the extended file system (ext).

ext2 was the default filesystem in several Linux distributions.

ext2 is still the filesystem of choice for flash-based storage media (such as SD cards, and USB flash drives), since its lack of a journal minimizes the number of writes.

ext3 ext3, or third extended filesystem, is a journaled file

system that is commonly used by the Linux kernel.

It is the default file system for many popular Linux distributions.

Its main advantage over ext2 is journaling, which improves reliability and eliminates the need to check the file system after an unclean shutdown.

Its successor is ext4.

Journaling A journaling is a file system that keeps track of the

changes that will be made in a journal (usually a circular log in a dedicated area of the file system) before committing them to the main file system.

In the event of a system crash or power failure, such file systems are quicker to bring back online (stable state)and less likely to become corrupted.

Journaling provides for fast and effective recovery in case of disk crashes, instead of using e2fsck or fsck.

ReiserFS The Reiser file system is a journaling FS designed for

fast server performance, especially in directories containing thousands of files.

It is more space efficient than most other file system, because it does not take up a minimum of one block per file.

If we want to write a bunch of really small files to disk, ReiserFS squeezes them all into one block instead of writing one small file to one block file.

Cramfs: it is designed to cram a file system onto a small flash memory device.

It is small, simple and able to compress things well.

The largest file sizes is 16 MB, and the largest FS size is 256MB.

To update cramfs mkcramfs tool is used.

tmpfs is a common name for a temporary file storagefacility on many Unix-like operating systems.

It is intended to appear as a mounted file system, but stored in volatile memory instead of a persistent storage device.

A similar construction is a RAM disk, which appears as a virtual disk drive and hosts a disk file system.

ramfs: It is basically cramfs without the compression.

romfs: This is a read-only file system that is mostly used for the initial RAM disks of installation disks.

It was designed to take up very little space, so it can fit a kernel and some useful code into a small boot disk.

The romfs file system is created with a program called genromfs.

It is very useful as an initial ROM holding kernel modules that can be loaded later as needed.

PROC:

proc is a virtual file system that acts as an interface to the kernel’s internal data structures.

proc can be used to get detailed information about a system’s hardware and to change kernel parameters at run time.

Even the process listing command, ps, gets its information from the proc file system.

The kernel parameters can be changed with the sysctlcommand.