LINUX DIRECTORY STRUCTURE
Presented By :-
What is Directory?
It’s bunch of system files and also data files.
What is Directory in LINUX?
It’s same meaning in LINUX but in the LINUX there is
only one root.
How the LINUX Directory differ from that of familiar
In windows every drive has it’s own root , opposite to it
, in linux only single drive and single root.
Difference between ‘/’ and ‘/Root’
‘/’ is called as a root.
It’s Root directory.
Root of the all file systems of linux.
Every directory is “under” root ultimately.
Root is the user with God-like powers over the system. !!!
It’s administrative(root) user’s home directory.
Contains the boot loader , Grub and linux kernel
Contains everything required for the boot process except
for configuration files not needed at boot time.
Stores data that is used before the kernel begins
executing user-mode programs.
/boot is static and unsharable directory.
If /boot is lost , then we can’t boot os .
Home directory of root user.
Root is the name of system Admin.
/Root = system admin or Super User directory.
Why not in '/home'?
Because '/home' is often located on a different
partition or even on another system and would thus
be inaccessible to 'root' when - for some reason -
only '/' is mounted.
Stands for binary
Need for system startup
Used by everyone in terminal
Shells like bash, csh
No subdirectories in /bin
Basic commands for
Navigating in filesystem
bash bzip2 cat gzip ls mv rm...
binary files usually for system administration.
Only root can access.
System configuration programs
Format hard disk
fsck mkfs mount adduser poweroff...
/bin vs /sbin
/bin directory contains executable programs which
are needed in single user mode and to bring the
system up or repair it.
/sbin Like /bin, holds commands needed to boot the
sys-tem, but which are usually not executed by normal
/opt/bin, /opt/doc, /opt/include, /opt/info,
/opt/lib, and /opt/man
installed under either /opt/ or /opt/ sub-
srv stands for service.
Contains server specific services related data.
For example, /srv/cvs contains CVS related
Contains file that are required temporarily
Directory is cleared out at boot or at shutdown.
All essential libraries which are needed for
Windows equivalent to a shared library would
be a DLL (dynamically linked library) file
Also in this directory are kernel modules
Other library locations for other programs include
/usr/lib and /usr/local/lib
Generally these correspond to where the binary is
installed, i.e. a binary in /usr/bin would put a library
in /usr/lib, and a binary in /usr/local/bin would put
a library in usr/local/lib
• Stands for devices.
• Linux filesystem : everything is a file or a directory.
• So device is treated as file. Usually It is the location
of device files
• C:WindowsSystem in Windows Contains a file
describing every device,and these files can send data
to each device.
• It is equivalent to a mashup of the Device Manager.
• A device and a file both can be read from and
written to. So config a device is same with edit a file.
EX: sending data to /dev/ttyS0 that means you are
sending data to a communication device, such as a
/dev/dsp : speaker device
/dev/dsp is speaker configuration file means it is for
cat /etc/lilo.conf > /dev/dsp
The sound you will hear is the sound of
your /etc/lilo.conf file
• Contains all system related configuration files.
• Those files must be static and cannot be an executable binary.
• These files are generally text files andcan be edited using any
text editor:emacs or vi on the command line, or whatever
graphical equivalent (e.g. gedit, kate) your desktop offers.
• /etc/rc.d directory contains the system startup scripts.
• Fstab : Static information about filesystems.
• Group : User group file.
• Passwd : This is the password file, but it contains more: user
name, user password, userID, group ID, home directory, and
shell. It can optionally contain the user's “real name”.
• /etc/sgml : Configuration files for SGML
• /etc/xml : Configuration files for XML
• /etc/hostname : Contains the hostname of your machine
• /etc/hosts : This file is used to define a system name and
domain combination with a specific IP address
• /etc/fstab: system what drive to access, and where
to mount it in your System.
• /etc/x11: Configuration directory for x11, which is
the display system for graphical interfaces in Linux.
• /etc/x11/xorg.conf : specify the resolutions your
monitor and graphics card can display, for instance.
• Linux is a multi-user environment so each user is also
assigned a specific directory which is accessible only
to them and the system administrator.
• containing saved files, personal settings, etc. Contains
the user’s personal configuration files and their name
start with “.” (hidden file).
• Quite large to be used as User’s Documents Space
Mounting is the process by which you make a
filesystem available to the system.
On older Linux systems, the /mnt directory contains
points for removable devices that have been mounted
Mount point for temporary mounted file system.
On modern Linux systems the /media directory will
contain the mount points for removable media such as,
that are mounted automatically at insertion.
Pseudo file system residing in the virtual memory.It is
virtual file system maintained by the Linux kernel. The
“files” it contains are peepholes into the kernel itself.
The files are readable and will give you a picture of
how the kernel sees your computer.
Maintains highly dynamic data on the state of your
A new /proc file system is created every time your
Linux machine reboots.
/usr is the second major section of the
/usr is shareable, read-only data.
Any information that is host-speciﬁc or varies
with time is stored elsewhere.
Large software packages must not use a direct
subdirectory under the /usr hierarchy.
Requirements of /usr
bin -----Most user commands
include -----Header ﬁles included by C
local -----Local hierarchy (empty
after main installation)
sbin -----Non-vital system binaries
Contains executable files for many Linux
These are commands that are not part of the
core Linux operating system
Examples of commands in here:
General use include files, including header files,
C and C++ programming languages.
Contains libraries for the C and C++
Object files, libraries, and internal files not
intended to be executed directly by users or
The /usr/local hierarchy is for use by the system
administrator when installing software locally.
It may be used for programs and data that are
shareable amongst a group of hosts, but not
found in /usr.
Locally installed software must be placed within
/usr/local rather than /usr unless it is being
installed to replace or upgrade software in /usr.
Requirements of /usr/local
s bin -----Local binaries
etc -----Host-speciﬁc system conﬁguration for
games -----Local game binaries
include -----Local C header ﬁles
lib -----Local libraries
man -----Local online manuals
sbin -----Local system binaries
share -----Local architecture-independent hierarchy
src -----Local source code
This directory contains any non-essential
binaries used exclusively by the system
System administration programs that are
required for system repair, system recovery,
mounting /usr, or other essential functions must
be placed in /sbin instead.
/usr/share is for read-only architecture independent data
Intended to be shared across platforms (e.g. i386,
Any program or package which contains or requires data
that doesn’t need to be modiﬁed should store
If the contents are variable, go to /var e.g. a game file in
/usr/share/games must be static. Game play
logs go in /var/games
Requirements of /usr/share
man -----Online manuals
misc -----Miscellaneous architecture-
Source code is placed here, for reference
This includes the source code for the Linux
• This is files that are expected to be updated and
• This includes:
Administrative and Logging data
/var/log, /var/lock, and /var/run.
/var/mail, /var/cache/man, /var/cache/fonts, and
Because there might be circumstances when you may
want to mount /usr as read-only,
e.g. if it is on a CD or on another computer.
However, /var must not be linked to /usr because this
makes separation of /usr and /var more difficult and
is likely to create a naming conflict. Instead, link /var
Why not put it into /usr ?
cache lib lock log www named
Subdirectory of /var
cache Application cache data
lib Variable state information
local Variable data for /usr/local
lock Lock files
log Log files and directories
opt Variable data for /opt
run Data relevant to running processes
spool Application spool data
tmp Temporary files preserved between
Carsh for the dumped data
They must not be used arbitrarily by some new
since they would conflict with historical and/or local
practice. They are
Permissions in FS
There are 3 basic permissions
There are 3 basic level of users
How to find the permissions:
Adv. Softlink in Linux FS
If Root FS become 100% full, we have to create one
soft link that would point to another point mount
created with on same disk ultimately that New
Fs(/test) will store data instead of root
Symbolic links, or "symlinks" work a little like
Symbolic links work on the files and directory
Adv. Hard link in Linux FS
There are basically two main limitations with hard
- Hard links normally require that the link and the file
reside in the same file system.
- Only the super user can create a hard link to a
Thus, symbolic links were introduced to get around the
limitations of hard links.
So, the question is, are hard links still needed?
Are Hard links still needed?
Symlinks aren't followed by some HTTP servers
Hard-Links can be used for backups
You can delete any version of a hard link without
affecting the others.
Hard links allow us to take one file and have it be
multiple places in the file system at once, which save
lots of memory.