Linux Filesystem Hierarchy
05/11/2005
The Linux Documentation Project
The Root Directory
/bin /mnt
/boot /opt
/dev /proc
/etc /root
/home /sbin
/initrd /usr
/lib /srv
/lost+found /tmp
/media /var
2
1. /bin
Contains several useful commands that are
of use to both the system administrator as
well as non-privileged users.
Usually contains the shells like bash, csh,
etc.... and commonly used commands like
cp, mv, rm, cat, ls.
Also contains programs which boot scripts
may depend on
There are no (real) subdirectories in /bin
3
1. /bin …(cont)
cat hostname rm
chgrp kill rmdir
chmod ln sed
chown
login sh
ls stty
cp
mkdir
date su
mknod
dd more
sync
df mount
true
dmesg mv umount
echo ps uname
false pwd
4
1. /bin detail
cat → Utility to concatenate files to standard output
chgrp → Utility to change file group ownership
chmod → Utility to change file access permissions
chown → Utility to change file owner and group
cp → Utility to copy files and directories
date → Utility to print or set the system data and time
dd → Utility to convert and copy a file
df → Utility to report filesystem disk space usage
dmesg → Utility to print or control the kernel message buffer
echo → Utility to display a line of text
false → Utility to do nothing, unsuccessfully
5
1. /bin detail (cont)
hostname → Utility to show or set the system's host name
kill → Utility to send signals to processes
ln → Utility to make links between files
login → Utility to begin a session on the system
ls → Utility to list directory contents
mkdir → Utility to make directories
mknod → Utility to make block or character special files
more → Utility to page through text
mount → Utility to mount a filesystem
mv → Utility to move/rename files
ps → Utility to report process status
6
1. /bin detail (cont)
pwd → Utility to print name of current working directory
rm → Utility to remove files or directories
rmdir → Utility to remove empty directories
sed → The `sed' stream editor
sh → The Bourne command shell
stty → Utility to change and print terminal line settings
su → Utility to change user ID
sync → Utility to flush filesystem buffers
true → Utility to do nothing, successfully
umount → Utility to unmount file systems
uname → Utility to print system information
7
2. /boot
Contains everything required for the boot
process except for configuration files not
needed at boot time and the map installer
Stores data that is used before the kernel
begins executing user-mode programs
May include the system kernel (under
symbolically linked)
8
2. /boot … detail
/boot/boot.0300 → Backup master boot record.
/boot/boot.b → The basic boot sector
/boot/chain.b → Used to boot non-Linux operating systems
/boot/config-kernel- → Installed kernel configuration. A config line
version such as: CONFIG_FONT_8x8=y
/boot/map → The location of the kernel
/boot/vmlinuz
/boot/vmlinuz-kernel- → Normally the kernel or symbolic link to the
version kernel
…
9
3. /dev
Usualy is the location of device files
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
modem.
'block devices' are devices that store or hold data
'character devices' can be thought of as devices that
transmit or transfer data
10
3. /dev … detail
/dev/ttyS0 → Device connected to Com1 (Modem, mouse,..)
/dev/psaux → PS/2 mouse connection
/dev/lp0 → First parallel port
/dev/dsp → Sound card (digital signal processor)
/dev/usb → USB device nodes.
/dev/sda → First SCSI device
/dev/scd → First SCSI CD-ROM device
/dev/cdrom → CD-ROM drive
/dev/fd0 → floppy drive
/dev/had → The partition on primary hdd
11
4. /etc
Contains all system related configuration
files
Local file used to control the operation of a
program
Those files must be static and cannot be an
executable binary
12
4. /etc … detail
/etc/X11/ : contains all the configuration files for the X Window
System
/etc/X11/XF86Config, /etc/X11/XF86Config-4 : 'X' configuration
file
/etc/ftpchroot : List of ftp users that need to be chrooted
/etc/ftpaccess : Determines who might get ftp-access to your
machine.
/etc/gateways : Lists gateways for 'routed'
/etc/group, /etc/passwd. lists the configured user groups and
who belongs to them.
/etc/hostname : Contains the hostname of your machine
/etc/host.conf : Determines the search order for look-ups
13
4. /etc … detail
/etc/hosts : This file is used to define a system name
and domain combination with a specific IP address
– 127.0.0.1 localhost ::1 localhost
– ip6-localhost ip6-loopback
– fe00::0 ip6-localnet
– ff00::0 ip6-mcastprefix
– ff02::1 ip6-allnodes
– ff02::2 ip6-allrouters
– ff02::3 ip6-allhosts
– 192.168.0.99 debian.localdomain.com debian
192.168.0.1 ws001
14
5. /home
The user home directories
Accessible only to its owner and the system
administrator
Contains the user’s personal configuration
files
Quite large to be used as User’s Documents
Space
15
6. /initrd
Provides the capability to load a RAM disk by the
boot loader. This RAM disk can then be mounted as
the root file system and programs can be run from it.
Afterwards, a new root file system can be mounted
from a different device. The previous root (from
initrd) is then moved to a directory and can be
subsequently unmounted.
Initrd is mainly designed to allow system startup to
occur in two phases, where the kernel comes up with
a minimum set of compiled-in drivers, and where
additional modules are loaded from initrd.
16
7. /lib
Contains kernel modules and those shared
library images (the C programming code
library) needed to boot the system and run
the commands in the root filesystem, ie. by
binaries in /bin and /sbin
Windows equivalent to a shared library would
be a DLL (dynamically linked library) file
17
7. /lib … detail
/lib/'machine-architecture‘ : Contains platform/architecture dependent
libraries.
/lib/iptables : iptables shared library files.
/lib/kbd : Contains various keymaps.
/lib/modules/'kernel-version‘ : The home of all the kernel modules. The
organisation of files here is reasonably clear so no requires no elaboration.
/lib/modules/'kernel-version'/isapnpmap.dep : has details on ISA based
cards, the modules that they require and various other attributes.
/lib/modules/'kernel-version'/modules.dep : lists all modules dependencies.
This file can be updated using the depmod command.
/lib/modules/'kernel-version'/pcimap : is the PCI equivalent of the
/lib/modules/'kernel-version'/isapnpmap.dep file.
/lib/modules/'kernel-version'/usbmap : is the USB equivalent of the
/lib/modules/'kernel-version'/isapnpmap.dep file.
/lib/oss : All OSS (Open Sound System) files are installed here by default.
/lib/security : PAM library files.
18
8. /lost+found
Contains the files which were recovered after
an unexpected event, such as a proper
shutdown.
Try to move each file back to its original
location
19
9. /media
Contains subdirectories which are used as
mount points for removeable media such as
floppy disks, cdroms and zip disks
20
10. /mnt
This is a generic mount point under mounted
(mount is to make a filesystem available to the
system) the filesystems or devices.
When a filesystem no longer needs to be
mounted, it can be unmounted with umount
• mount /dev/hda2 /home
• umount /dev/hda2
21
11. /opt
This directory is reserved for all the software
and add-on packages that are not part of the
default installation
/opt/'package' C:\Windows\Progam
Files\"Program Name"
22
12. /proc
Virtual filesystem, runtime system information
(e.g. system memory, devices mounted,
hardware configuration, etc).
The most of them have a file size of 0
To view, use “cat”. Use “vi” to edit.
23
13. /root
The home directory of the System
Administrator, 'root'
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.
24
14. /sbin
Like /bin bet less important
/sbin should contain only binaries essential
for booting, restoring, recovering, and/or
repairing the system in addition to the
binaries in /bin.
25
14. /sbin … detail
shutdown → Command to bring the system down.
Fastboot → Reboot the system without checking the disks (optional)
Fasthalt → Stop the system without checking the disks (optional)
fdisk → Partition table manipulator (optional)
fsck → File system check and repair utility (optional)
fsck.* → File system check and repair utility for a specific
filesystem (optional)
getty → The getty program (optional)
halt → Command to stop the system (optional)
ifconfig → Configure a network interface (optional)
26
14. /sbin … detail
init → Initial process (optional)
mkfs → Command to build a filesystem (optional)
mkfs.* → Command to build a specific filesystem (optional)
mkswap → Command to set up a swap area (optional)
reboot → Command to reboot the system (optional)
route → IP routing table utility (optional)
swapon → Enable paging and swapping (optional)
swapoff → Disable paging and swapping (optional)
update → Daemon to periodically flush filesystem buffers
(optional)
27
15. /usr
The largest share of data on a system
the most important directories in the system
as it contains all the user binaries, their
documentation, libraries, header files, etc....
X and its supporting libraries, and User
programs like telnet, ftp, etc.... as well, can
be found here.
28
16. /var
Contains variable data, files and directories
the system must be able to write to during
operation, like system logging files, mail and
printer spool directories, and transient and
temporary files
29