Last updated on:

File Hierarchy System

The Linux filesystem hierarchy starts with the root represented by a / character. Under the root can be found other directories containing task specific files. The hierarchy conforms to a standard called the Linux File Hierarchy System.

Before proceeding further, using putty or a terminal on your host system, connect to your virtual machine using the trainee account with a password of trainee via localhost and one of the following ports :

Debian 8: 2022

SLES 12: 3022

Ubuntu 16.04: 4022

CentOS 7: 5022

For example, using a terminal on a Linux host :

$ ssh -l trainee -p 5022 localhost
The authenticity of host '[localhost]:5022 ([127.0.0.1]:6022)' can't be established.
ECDSA key fingerprint is SHA256:RgOsp/XI7JHNq+oIfHKw+jkHdtTnBIh+Dd7kVmHRxtU.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[localhost]:5022' (ECDSA) to the list of known hosts.
trainee@localhost's password: trainee

Using putty on a Windows™ host :

(Click on image to enlarge - note that this does not work in PDF version)

Click on the Accept button:

(Click on image to enlarge - note that this does not work in PDF version)

Login as trainee with password trainee :

(Click on image to enlarge - note that this does not work in PDF version)

Once connected, when using either CentOS 7, Debian 8 or SLES 12, enter the su - command, hit the ↵ Enter key and use the password fenestros. When using Ubuntu 16.04, enter the sudo su - command, hit the ↵ Enter key and use the password trainee. You are now connected as the root user.

Directory Contents

Directory	Contents
/bin	Contains user programs such as ls, cp e.t.c.. Note that under RHEL 7 / CentOS7, this is a soft link (shorcut) to /usr/bin.
/boot	Contains bootloader files, kernels and initrd (INItial Ram Disk) files.
/dev	Contains nodes for accessing all the peripherals and devices connected to the system. The udev binary takes care of dynamically creating and deleting the relevant nodes automatically.
/etc	Contains static configuration files.
/home	Contains a directory for each registered user of the system except for root.
/lib	Contains common 32 bit libraries for applications and modules. Note that under RHEL 7 / CentOS7, this is a soft link (shorcut) to /usr/lib.
/lib64	Contains common 64 bit libraries for applications and modules. Note that under RHEL 7 / CentOS7, this is a soft link (shorcut) to /usr/lib64.
/lost+found	Contains damaged file fragments found by the fsck command.
/media	Contains a folder for each of the mounted external file systems (CDRom DVDRom, USB Key e.t.c.).
/misc	RHEL 5, 6 and CentOS 5, 6 only. Contains mount points for local directories mounted via the automounter.
/mnt	Contains a folder for each external file system mounted temporarily by root.
/net	RHEL 5, 6 and CentOS 5, 6 only. Contains mount points for network directories mounted via the automounter.
/opt	Contains optional application packages.
/proc	Contains a virtual file system that documents kernel and process status information as text files.
/root	The home directory of the root user.
/run	Replaces the /var/run directory. Note that under RHEL 7 / CentOS7, Debian 7, Debian 8 and SLES 12, /var/run is a soft link (shorcut) to /run.
/sbin	Contains essential system administration binaires. Note that under RHEL 7 / CentOS7, this is a soft link (shorcut) to /usr/sbin.
/selinux	Contains a virtual file system used by SELINUX.
/snap	Ubuntu 16.04 only. Used in conjunction with the new Snap packages.
/srv	Contains site specific data served by the system (www,ftp,databases e.t.c.).
/sys	Contains a virtual file system that describes devices for udev.
/tmp	Contains the temporary files created by the system and by applications.
/usr	Contains user commands in /usr/bin, HOWTOs in /usr/share/doc, manuals in /usr/share/man and is the Secondary Hierarchy for read-only user data.
/var	Contains variable files. i.e. files that continually change such as log files and spool files.

Directory Structure

Debian

trainee@debian6:/$ ls -l
total 92
drwxr-xr-x 2 root root 4096 6 déc. 2014 bin
drwxr-xr-x 3 root root 4096 6 déc. 2014 boot
drwxr-xr-x 15 root root 3120 25 août 16:51 dev
drwxr-xr-x 121 root root 12288 4 juil. 15:05 etc
drwxr-xr-x 3 root root 4096 24 avril 2011 home
lrwxrwxrwx 1 root root 28 24 avril 2011 initrd.img -> boot/initrd.img-2.6.32-5-686
drwxr-xr-x 12 root root 12288 6 déc. 2014 lib
drwx------ 2 root root 16384 24 avril 2011 lost+found
drwxr-xr-x 3 root root 4096 24 avril 2011 media
drwxr-xr-x 2 root root 4096 14 déc. 2010 mnt
drwxr-xr-x 4 root root 4096 4 déc. 2011 opt
dr-xr-xr-x 128 root root 0 4 juil. 14:34 proc
drwx------ 11 root root 4096 7 déc. 2014 root
drwxr-xr-x 2 root root 4096 6 déc. 2014 sbin
drwxr-xr-x 2 root root 4096 21 juil. 2010 selinux
drwxr-xr-x 2 root root 4096 24 avril 2011 srv
drwxr-xr-x 12 root root 0 4 juil. 14:34 sys
drwxrwxrwt 10 root root 4096 25 août 16:34 tmp
drwxr-xr-x 10 root root 4096 24 avril 2011 usr
drwxr-xr-x 14 root root 4096 24 avril 2011 var
lrwxrwxrwx 1 root root 25 24 avril 2011 vmlinuz -> boot/vmlinuz-2.6.32-5-686

trainee@debian7:/$ ls -l
total 84
drwxr-xr-x 2 root root 4096 juin 26 16:06 bin
drwxr-xr-x 3 root root 4096 juin 26 16:09 boot
drwxr-xr-x 14 root root 3160 juil. 4 16:36 dev
drwxr-xr-x 133 root root 12288 juil. 4 16:36 etc
drwxr-xr-x 3 root root 4096 juin 26 15:42 home
lrwxrwxrwx 1 root root 32 juin 26 15:35 initrd.img -> /boot/initrd.img-3.2.0-4-686-pae
lrwxrwxrwx 1 root root 28 juin 26 15:35 initrd.img.old -> /boot/initrd.img-3.2.0-4-486
drwxr-xr-x 15 root root 4096 juin 26 16:01 lib
drwx------ 2 root root 16384 juin 26 15:35 lost+found
drwxr-xr-x 3 root root 4096 juil. 15 2014 media
drwxr-xr-x 2 root root 4096 juil. 7 2014 mnt
drwxr-xr-x 2 root root 4096 juil. 15 2014 opt
dr-xr-xr-x 131 root root 0 juin 26 16:17 proc
drwx------ 4 root root 4096 juil. 4 15:14 root
drwxr-xr-x 20 root root 880 juil. 4 16:36 run
drwxr-xr-x 2 root root 4096 juin 26 16:07 sbin
drwxr-xr-x 2 root root 4096 juin 10 2012 selinux
drwxr-xr-x 2 root root 4096 juil. 15 2014 srv
drwxr-xr-x 13 root root 0 juin 26 16:17 sys
drwxrwxrwt 9 root root 4096 juil. 4 16:17 tmp
drwxr-xr-x 10 root root 4096 juin 26 15:39 usr
drwxr-xr-x 12 root root 4096 juin 26 15:39 var
lrwxrwxrwx 1 root root 28 juin 26 15:39 vmlinuz -> boot/vmlinuz-3.2.0-4-686-pae
lrwxrwxrwx 1 root root 24 juin 26 15:39 vmlinuz.old -> boot/vmlinuz-3.2.0-4-486

trainee@debian8:/$ ls -l
total 84
drwxr-xr-x 2 root root 4096 juin 28 16:31 bin
drwxr-xr-x 3 root root 4096 juin 28 16:31 boot
drwxr-xr-x 17 root root 3080 juil. 23 17:04 dev
drwxr-xr-x 125 root root 12288 août 27 12:18 etc
drwxr-xr-x 3 root root 4096 juin 28 16:30 home
lrwxrwxrwx 1 root root 33 juin 28 16:26 initrd.img -> /boot/initrd.img-3.16.0-4-686-pae
lrwxrwxrwx 1 root root 29 juin 28 16:26 initrd.img.old -> /boot/initrd.img-3.16.0-4-586
drwxr-xr-x 18 root root 4096 juin 28 16:31 lib
drwxr-xr-x 2 root root 4096 juin 6 17:07 live-build
drwx------ 2 root root 16384 juin 28 16:26 lost+found
drwxr-xr-x 3 root root 4096 juin 6 16:32 media
drwxr-xr-x 2 root root 4096 juin 6 16:32 mnt
drwxr-xr-x 3 root root 4096 juin 28 16:38 opt
dr-xr-xr-x 138 root root 0 juin 28 16:41 proc
drwx------ 2 root root 4096 juin 28 16:35 root
drwxr-xr-x 24 root root 820 août 27 12:18 run
drwxr-xr-x 2 root root 4096 juin 28 16:39 sbin
drwxr-xr-x 2 root root 4096 juin 6 16:32 srv
dr-xr-xr-x 13 root root 0 juin 28 16:41 sys
drwxrwxrwt 12 root root 4096 juil. 23 16:17 tmp
drwxr-xr-x 10 root root 4096 juin 28 16:29 usr
drwxr-xr-x 11 root root 4096 juin 28 16:29 var
lrwxrwxrwx 1 root root 29 juin 28 16:29 vmlinuz -> boot/vmlinuz-3.16.0-4-686-pae
lrwxrwxrwx 1 root root 25 juin 28 16:29 vmlinuz.old -> boot/vmlinuz-3.16.0-4-586

Ubuntu

trainee@ubuntu1404:/$ ls -l
total 92
drwxr-xr-x 2 root root 4096 sept. 27 2014 bin
drwxr-xr-x 3 root root 4096 sept. 27 2014 boot
drwxrwxr-x 2 root root 4096 sept. 27 2014 cdrom
drwxr-xr-x 15 root root 4120 sept. 25 15:17 dev
drwxr-xr-x 131 root root 12288 sept. 25 15:17 etc
drwxr-xr-x 3 root root 4096 sept. 27 2014 home
lrwxrwxrwx 1 root root 33 sept. 27 2014 initrd.img -> boot/initrd.img-3.13.0-32-generic
drwxr-xr-x 23 root root 4096 sept. 27 2014 lib
drwx------ 2 root root 16384 sept. 27 2014 lost+found
drwxr-xr-x 3 root root 4096 sept. 28 2014 media
drwxr-xr-x 2 root root 4096 avril 11 2014 mnt
drwxr-xr-x 3 root root 4096 sept. 28 2014 opt
dr-xr-xr-x 102 root root 0 sept. 25 15:17 proc
drwx------ 2 root root 4096 oct. 14 2014 root
drwxr-xr-x 20 root root 700 sept. 25 15:17 run
drwxr-xr-x 2 root root 12288 sept. 28 2014 sbin
drwxr-xr-x 2 root root 4096 juil. 22 2014 srv
dr-xr-xr-x 13 root root 0 sept. 25 15:17 sys
drwxrwxrwt 4 root root 4096 sept. 25 15:17 tmp
drwxr-xr-x 10 root root 4096 juil. 22 2014 usr
drwxr-xr-x 13 root root 4096 juil. 23 2014 var
lrwxrwxrwx 1 root root 30 sept. 27 2014 vmlinuz -> boot/vmlinuz-3.13.0-32-generic

trainee@ubuntu1604:/$ ls -l
total 100
drwxr-xr-x 2 root root 4096 mai 3 07:47 bin
drwxr-xr-x 3 root root 4096 mai 3 07:49 boot
drwxrwxr-x 2 root root 4096 mai 3 07:25 cdrom
drwxr-xr-x 19 root root 4180 août 18 12:39 dev
drwxr-xr-x 129 root root 12288 sept. 25 11:12 etc
drwxr-xr-x 3 root root 4096 mai 3 07:27 home
lrwxrwxrwx 1 root root 32 mai 3 07:31 initrd.img -> boot/initrd.img-4.4.0-21-generic
drwxr-xr-x 22 root root 4096 mai 3 07:47 lib
drwxr-xr-x 2 root root 4096 avril 21 00:07 lib64
drwx------ 2 root root 16384 mai 3 07:17 lost+found
drwxr-xr-x 2 root root 4096 avril 21 00:07 media
drwxr-xr-x 2 root root 4096 avril 21 00:07 mnt
drwxr-xr-x 3 root root 4096 mai 3 08:14 opt
dr-xr-xr-x 114 root root 0 août 18 12:39 proc
drwx------ 4 root root 4096 mai 3 08:33 root
drwxr-xr-x 24 root root 820 sept. 25 11:40 run
drwxr-xr-x 2 root root 12288 mai 3 07:51 sbin
drwxr-xr-x 2 root root 4096 avril 19 16:31 snap
drwxr-xr-x 2 root root 4096 avril 21 00:07 srv
dr-xr-xr-x 13 root root 0 août 18 12:38 sys
drwxrwxrwt 9 root root 4096 sept. 25 11:17 tmp
drwxr-xr-x 11 root root 4096 avril 21 00:13 usr
drwxr-xr-x 14 root root 4096 avril 21 00:19 var
lrwxrwxrwx 1 root root 29 mai 3 07:31 vmlinuz -> boot/vmlinuz-4.4.0-21-generic

Red Hat Enterprise Linux (RHEL)/CentOS

[trainee@centos5 /]$ ls -l
total 138
drwxr-xr-x 2 root root 4096 août 25 13:27 bin
drwxr-xr-x 4 root root 1024 août 25 14:03 boot
drwxr-xr-x 11 root root 3800 août 25 14:06 dev
drwxr-xr-x 102 root root 12288 août 25 14:06 etc
drwxr-xr-x 3 root root 4096 août 25 13:36 home
drwxr-xr-x 14 root root 4096 août 25 13:42 lib
drwx------ 2 root root 16384 août 25 13:16 lost+found
drwxr-xr-x 3 root root 4096 août 25 14:06 media
drwxr-xr-x 2 root root 0 août 25 14:06 misc
drwxr-xr-x 2 root root 4096 mai 11 2011 mnt
drwxr-xr-x 2 root root 0 août 25 14:06 net
drwxr-xr-x 4 root root 4096 août 25 13:44 opt
dr-xr-xr-x 143 root root 0 août 25 14:05 proc
drwxr-x--- 4 root root 4096 août 25 14:01 root
drwxr-xr-x 2 root root 12288 août 25 14:03 sbin
drwxr-xr-x 4 root root 0 août 25 14:05 selinux
drwxr-xr-x 2 root root 4096 mai 11 2011 srv
drwxr-xr-x 11 root root 0 août 25 14:05 sys
drwxrwxrwt 14 root root 4096 août 25 14:09 tmp
drwxr-xr-x 14 root root 4096 août 25 13:23 usr
drwxr-xr-x 21 root root 4096 août 25 13:31 var

[trainee@centos6 /]$ ls -l
total 98
dr-xr-xr-x. 2 root root 4096 9 août 12:52 bin
dr-xr-xr-x. 5 root root 1024 7 déc. 2014 boot
drwxr-xr-x. 19 root root 3820 25 août 11:29 dev
drwxr-xr-x. 119 root root 12288 25 août 11:28 etc
drwxr-xr-x. 3 root root 4096 3 mai 2013 home
dr-xr-xr-x. 20 root root 12288 9 août 12:52 lib
drwx------. 2 root root 16384 3 mai 2013 lost+found
drwxr-xr-x. 2 root root 4096 7 déc. 2014 media
drwxr-xr-x. 2 root root 0 25 août 11:28 misc
drwxr-xr-x. 3 root root 4096 5 juil. 12:22 mnt
drwxr-xr-x. 2 root root 0 25 août 11:28 net
drwxr-xr-x. 6 root root 4096 7 déc. 2014 opt
dr-xr-xr-x. 154 root root 0 25 août 11:27 proc
dr-xr-x---. 10 root root 4096 9 août 12:58 root
dr-xr-xr-x. 2 root root 12288 9 août 12:52 sbin
drwxr-xr-x. 7 root root 0 25 août 11:27 selinux
drwxr-xr-x. 2 root root 4096 23 sept. 2011 srv
drwxr-xr-x. 13 root root 0 25 août 11:27 sys
drwxrwxrwt. 16 root root 4096 25 août 11:30 tmp
drwxr-xr-x. 13 root root 4096 3 mai 2013 usr
drwxr-xr-x. 22 root root 4096 9 août 12:50 var

[trainee@centos7 /]$ ls -l
total 32
lrwxrwxrwx. 1 root root 7 Mar 8 13:41 bin -> usr/bin
dr-xr-xr-x. 4 root root 4096 Jun 4 15:00 boot
drwxr-xr-x. 19 root root 3280 Jul 7 15:55 dev
drwxr-xr-x. 131 root root 8192 Jul 23 17:05 etc
drwxr-xr-x. 4 root root 47 Jul 5 14:11 home
lrwxrwxrwx. 1 root root 7 Mar 8 13:41 lib -> usr/lib
lrwxrwxrwx. 1 root root 9 Mar 8 13:41 lib64 -> usr/lib64
drwxr-xr-x. 2 root root 6 Jun 10 2014 media
drwxr-xr-x. 3 root root 18 Jul 5 13:57 mnt
drwxr-xr-x. 4 root root 47 Jun 4 09:36 opt
dr-xr-xr-x. 177 root root 0 Jul 7 15:53 proc
dr-xr-x---. 5 root root 4096 Aug 25 11:31 root
drwxr-xr-x. 35 root root 1100 Jul 23 15:40 run
lrwxrwxrwx. 1 root root 8 Mar 8 13:41 sbin -> usr/sbin
drwxr-xr-x. 2 root root 6 Jun 10 2014 srv
dr-xr-xr-x. 13 root root 0 Jul 7 15:53 sys
drwxrwxrwt. 25 root root 4096 Jul 23 15:40 tmp
drwxr-xr-x. 13 root root 4096 Mar 8 13:41 usr
drwxr-xr-x. 22 root root 4096 Jul 7 15:53 var

SUSE Linux Enterprise Server (SLES)

trainee@SLES11SP1:/> ls -l
total 101
drwxr-xr-x 2 root root 4096 25 sept. 15:48 bin
drwxr-xr-x 4 root root 1024 25 sept. 17:08 boot
drwxr-xr-x 16 root root 4020 25 sept. 17:08 dev
drwxr-xr-x 88 root root 12288 25 sept. 17:14 etc
drwxr-xr-x 3 root root 4096 25 sept. 15:55 home
drwxr-xr-x 13 root root 4096 25 sept. 15:49 lib
drwxr-xr-x 8 root root 12288 25 sept. 15:48 lib64
drwx------ 2 root root 16384 25 sept. 15:43 lost+found
drwxr-xr-x 2 root root 4096 5 mai 2010 media
drwxr-xr-x 2 root root 4096 5 mai 2010 mnt
drwxr-xr-x 2 root root 4096 5 mai 2010 opt
dr-xr-xr-x 88 root root 0 25 sept. 17:07 proc
drwx------ 6 root root 4096 25 sept. 17:14 root
drwxr-xr-x 3 root root 12288 25 sept. 15:50 sbin
drwxr-xr-x 2 root root 4096 5 mai 2010 selinux
drwxr-xr-x 4 root root 4096 25 sept. 15:43 srv
drwxr-xr-x 12 root root 0 25 sept. 17:07 sys
drwxrwxrwt 4 root root 4096 25 sept. 17:22 tmp
drwxr-xr-x 13 root root 4096 25 sept. 15:43 usr
drwxr-xr-x 15 root root 4096 25 sept. 15:44 var

trainee@SLES12SP1:/> ls -l
total 0
drwxr-xr-x 1 root root 1810 20 sept. 13:33 bin
drwxr-xr-x 1 root root 1096 21 sept. 04:19 boot
drwxr-xr-x 16 root root 3620 21 sept. 04:18 dev
drwxr-xr-x 1 root root 4746 21 sept. 04:18 etc
drwxr-xr-x 1 root root 14 20 sept. 13:34 home
drwxr-xr-x 1 root root 2906 20 sept. 13:32 lib
drwxr-xr-x 1 root root 4998 20 sept. 13:31 lib64
drwxr-xr-x 1 root root 0 21 sept. 2014 mnt
drwxr-xr-x 1 root root 0 21 sept. 2014 opt
dr-xr-xr-x 100 root root 0 20 sept. 13:47 proc
drwx------ 1 root root 112 20 sept. 14:00 root
drwxr-xr-x 25 root root 640 21 sept. 04:18 run
drwxr-xr-x 1 root root 5044 20 sept. 13:33 sbin
drwxr-xr-x 1 root root 0 21 sept. 2014 selinux
drwxr-xr-x 1 root root 12 20 sept. 13:29 srv
dr-xr-xr-x 12 root root 0 20 sept. 13:47 sys
drwxrwxrwt 1 root root 102 21 sept. 04:18 tmp
drwxr-xr-x 1 root root 130 20 sept. 13:29 usr
drwxr-xr-x 1 root root 108 20 sept. 13:33 var

File Types

The three major file types under Linux are :

Ordinary files,

Directories,

Special files or Devices.

Note that :

Ordinary files can be anything from text files to binaries.

The length of a file name is limited to 225 characters, including the file extension.

Linux is case sensitive.

If a file name starts with a dot (.), it is a hidden file.

The mount command

In order to be able to use external file systems, such as a CDRom or DVDRom, Linux needs to be informed of their availability. This is accomplished by using the mount command:

# mount /dev/<special_file> /mnt/<directory_name> [Enter]

where /dev/<special_file> is the file system to mount and /mnt/<directory_name> is the target directory where the mounted file system will be available to the system. The directory /mnt/<directory_name> must exist prior to using the mount command.

In the case where the mount command is used without options, the current mounted file systems are shown:

Debian

root@debian6:~# mount
/dev/sda1 on / type ext3 (rw,errors=remount-ro)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
fusectl on /sys/fs/fuse/connections type fusectl (rw)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)

root@debian7:~# mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,relatime,size=10240k,nr_inodes=127976,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=103420k,mode=755)
/dev/disk/by-uuid/0f1cdb0c-8bd7-45ec-8d99-064292047bdb on / type ext4 (rw,relatime,errors=remount-ro,user_xattr,barrier=1,data=ordered)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=597180k)
rpc_pipefs on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,nosuid,nodev,noexec,relatime)

root@debian8:~# mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,relatime,size=10240k,nr_inodes=126281,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,relatime,size=206376k,mode=755)
/dev/sda1 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
tmpfs on /etc/machine-id type tmpfs (ro,relatime,size=206376k,mode=755)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=22,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
mqueue on /dev/mqueue type mqueue (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
rpc_pipefs on /run/rpc_pipefs type rpc_pipefs (rw,relatime)
tmpfs on /run/user/119 type tmpfs (rw,nosuid,nodev,relatime,size=103188k,mode=700,uid=119,gid=127)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=103188k,mode=700,uid=1000,gid=1000)

Ubuntu

trainee@ubuntu1404:/$ mount
/dev/sda1 on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/cgroup type tmpfs (rw)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
none on /run/user type tmpfs (rw,noexec,nosuid,nodev,size=104857600,mode=0755)
none on /sys/fs/pstore type pstore (rw)
systemd on /sys/fs/cgroup/systemd type cgroup (rw,noexec,nosuid,nodev,none,name=systemd)

root@ubuntu1604:~# mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,nosuid,relatime,size=230832k,nr_inodes=57708,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=50028k,mode=755)
/dev/sda1 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd,nsroot=/)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb,nsroot=/)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory,nsroot=/)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer,nsroot=/)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset,nsroot=/)
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids,nsroot=/)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio,nsroot=/)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio,nsroot=/)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event,nsroot=/)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices,nsroot=/)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct,nsroot=/)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=22,pgrp=1,timeout=0,minproto=5,maxproto=5,direct)
mqueue on /dev/mqueue type mqueue (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=50028k,mode=700,uid=1000,gid=1000)

RHEL/CentOS

[root@centos5 ~]# mount
/dev/sda2 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

[root@centos6 /]# mount
/dev/sda2 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sda1 on /boot type ext3 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

[root@centos7 ~]# mount
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime,seclabel)
devtmpfs on /dev type devtmpfs (rw,nosuid,seclabel,size=1449668k,nr_inodes=362417,mode=755)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,seclabel)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,seclabel,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,nodev,seclabel,mode=755)
tmpfs on /sys/fs/cgroup type tmpfs (rw,nosuid,nodev,noexec,seclabel,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct,cpu)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/net_cls type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)
configfs on /sys/kernel/config type configfs (rw,relatime)
/dev/sda2 on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
selinuxfs on /sys/fs/selinux type selinuxfs (rw,relatime)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=32,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,seclabel)
mqueue on /dev/mqueue type mqueue (rw,relatime,seclabel)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
nfsd on /proc/fs/nfsd type nfsd (rw,relatime)
/dev/sda1 on /boot type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)

SLES

SLES11SP1:~ # mount
/dev/sda2 on / type ext3 (rw,acl,user_xattr)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
debugfs on /sys/kernel/debug type debugfs (rw)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,mode=1777)
devpts on /dev/pts type devpts (rw,mode=0620,gid=5)
/dev/sda1 on /boot type ext3 (rw,acl,user_xattr)
fusectl on /sys/fs/fuse/connections type fusectl (rw)
securityfs on /sys/kernel/security type securityfs (rw)

SLES12SP1:~ # mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
devtmpfs on /dev type devtmpfs (rw,nosuid,size=1931968k,nr_inodes=482992,mode=755)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
tmpfs on /sys/fs/cgroup type tmpfs (rw,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct,cpu)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)
/dev/sda2 on / type btrfs (rw,relatime,space_cache,subvolid=259,subvol=/@/.snapshots/1/snapshot)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=31,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
mqueue on /dev/mqueue type mqueue (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
/dev/sda2 on /.snapshots type btrfs (rw,relatime,space_cache,subvolid=258,subvol=/@/.snapshots)
/dev/sda2 on /var/lib/mailman type btrfs (rw,relatime,space_cache,subvolid=269,subvol=/@/var/lib/mailman)
/dev/sda2 on /var/lib/mariadb type btrfs (rw,relatime,space_cache,subvolid=270,subvol=/@/var/lib/mariadb)
/dev/sda2 on /var/log type btrfs (rw,relatime,space_cache,subvolid=274,subvol=/@/var/log)
/dev/sda2 on /tmp type btrfs (rw,relatime,space_cache,subvolid=265,subvol=/@/tmp)
/dev/sda2 on /var/spool type btrfs (rw,relatime,space_cache,subvolid=276,subvol=/@/var/spool)
/dev/sda2 on /var/lib/named type btrfs (rw,relatime,space_cache,subvolid=272,subvol=/@/var/lib/named)
/dev/sda2 on /srv type btrfs (rw,relatime,space_cache,subvolid=264,subvol=/@/srv)
/dev/sda2 on /usr/local type btrfs (rw,relatime,space_cache,subvolid=266,subvol=/@/usr/local)
/dev/sda2 on /var/opt type btrfs (rw,relatime,space_cache,subvolid=275,subvol=/@/var/opt)
/dev/sda2 on /var/lib/pgsql type btrfs (rw,relatime,space_cache,subvolid=273,subvol=/@/var/lib/pgsql)
/dev/sda2 on /opt type btrfs (rw,relatime,space_cache,subvolid=263,subvol=/@/opt)
/dev/sda2 on /var/tmp type btrfs (rw,relatime,space_cache,subvolid=277,subvol=/@/var/tmp)
/dev/sda2 on /var/lib/mysql type btrfs (rw,relatime,space_cache,subvolid=271,subvol=/@/var/lib/mysql)
/dev/sda2 on /var/lib/libvirt/images type btrfs (rw,relatime,space_cache,subvolid=268,subvol=/@/var/lib/libvirt/images)
/dev/sda2 on /var/crash type btrfs (rw,relatime,space_cache,subvolid=267,subvol=/@/var/crash)
/dev/sda2 on /home type btrfs (rw,relatime,space_cache,subvolid=262,subvol=/@/home)
/dev/sda2 on /boot/grub2/x86_64-efi type btrfs (rw,relatime,space_cache,subvolid=261,subvol=/@/boot/grub2/x86_64-efi)
/dev/sda2 on /boot/grub2/i386-pc type btrfs (rw,relatime,space_cache,subvolid=260,subvol=/@/boot/grub2/i386-pc)

Important : Note that under RHEL 5 / CentOS 5, Debian 6 and SLES 11, the default filesystem is ext3, under RHEL 6 / CentOS 6, Debian 7, Debian 8, Ubuntu 14.04 and Ubuntu 16.04, the default filesystem is ext4, under RHEL 7 / CentOS the default filesystem is xfs whilst under SLES 12, the default filesystem is btrfs. Please see the unit Managing Disks, Swap Space and Filesystems for further coursework concerning ext3, ext4, xfs and btrfs filesystems.

Command Line Switches

The following switches can be used with the mount command:

root@debian8:~# mount --help
Usage:
mount [-lhV]
mount -a [options]
mount [options] [--source] <source> | [--target] <directory>
mount [options] <source> <directory>
mount <operation> <mountpoint> [<target>]
Options:
-a, --all mount all filesystems mentioned in fstab
-c, --no-canonicalize don't canonicalize paths
-f, --fake dry run; skip the mount(2) syscall
-F, --fork fork off for each device (use with -a)
-T, --fstab <path> alternative file to /etc/fstab
-h, --help display this help text and exit
-i, --internal-only don't call the mount.<type> helpers
-l, --show-labels lists all mounts with LABELs
-n, --no-mtab don't write to /etc/mtab
-o, --options <list> comma-separated list of mount options
-O, --test-opts <list> limit the set of filesystems (use with -a)
-r, --read-only mount the filesystem read-only (same as -o ro)
-t, --types <list> limit the set of filesystem types
--source <src> explicitly specifies source (path, label, uuid)
--target <target> explicitly specifies mountpoint
-v, --verbose say what is being done
-V, --version display version information and exit
-w, --rw, --read-write mount the filesystem read-write (default)
-h, --help display this help and exit
-V, --version output version information and exit
Source:
-L, --label <label> synonym for LABEL=<label>
-U, --uuid <uuid> synonym for UUID=<uuid>
LABEL=<label> specifies device by filesystem label
UUID=<uuid> specifies device by filesystem UUID
PARTLABEL=<label> specifies device by partition label
PARTUUID=<uuid> specifies device by partition UUID
<device> specifies device by path
<directory> mountpoint for bind mounts (see --bind/rbind)
<file> regular file for loopdev setup
Operations:
-B, --bind mount a subtree somewhere else (same as -o bind)
-M, --move move a subtree to some other place
-R, --rbind mount a subtree and all submounts somewhere else
--make-shared mark a subtree as shared
--make-slave mark a subtree as slave
--make-private mark a subtree as private
--make-unbindable mark a subtree as unbindable
--make-rshared recursively mark a whole subtree as shared
--make-rslave recursively mark a whole subtree as slave
--make-rprivate recursively mark a whole subtree as private
--make-runbindable recursively mark a whole subtree as unbindable
For more details see mount(8).

root@ubuntu1604:~# mount --help
Usage:
mount [-lhV]
mount -a [options]
mount [options] [--source] <source> | [--target] <directory>
mount [options] <source> <directory>
mount <operation> <mountpoint> [<target>]
Mount a filesystem.
Options:
-a, --all mount all filesystems mentioned in fstab
-c, --no-canonicalize don't canonicalize paths
-f, --fake dry run; skip the mount(2) syscall
-F, --fork fork off for each device (use with -a)
-T, --fstab <path> alternative file to /etc/fstab
-i, --internal-only don't call the mount.<type> helpers
-l, --show-labels show also filesystem labels
-n, --no-mtab don't write to /etc/mtab
-o, --options <list> comma-separated list of mount options
-O, --test-opts <list> limit the set of filesystems (use with -a)
-r, --read-only mount the filesystem read-only (same as -o ro)
-t, --types <list> limit the set of filesystem types
--source <src> explicitly specifies source (path, label, uuid)
--target <target> explicitly specifies mountpoint
-v, --verbose say what is being done
-w, --rw, --read-write mount the filesystem read-write (default)
-h, --help display this help and exit
-V, --version output version information and exit
Source:
-L, --label <label> synonym for LABEL=<label>
-U, --uuid <uuid> synonym for UUID=<uuid>
LABEL=<label> specifies device by filesystem label
UUID=<uuid> specifies device by filesystem UUID
PARTLABEL=<label> specifies device by partition label
PARTUUID=<uuid> specifies device by partition UUID
<device> specifies device by path
<directory> mountpoint for bind mounts (see --bind/rbind)
<file> regular file for loopdev setup
Operations:
-B, --bind mount a subtree somewhere else (same as -o bind)
-M, --move move a subtree to some other place
-R, --rbind mount a subtree and all submounts somewhere else
--make-shared mark a subtree as shared
--make-slave mark a subtree as slave
--make-private mark a subtree as private
--make-unbindable mark a subtree as unbindable
--make-rshared recursively mark a whole subtree as shared
--make-rslave recursively mark a whole subtree as slave
--make-rprivate recursively mark a whole subtree as private
--make-runbindable recursively mark a whole subtree as unbindable
For more details see mount(8).

[root@centos7 ~]# mount --help
Usage:
mount [-lhV]
mount -a [options]
mount [options] [--source] <source> | [--target] <directory>
mount [options] <source> <directory>
mount <operation> <mountpoint> [<target>]
Options:
-a, --all mount all filesystems mentioned in fstab
-c, --no-canonicalize don't canonicalize paths
-f, --fake dry run; skip the mount(2) syscall
-F, --fork fork off for each device (use with -a)
-T, --fstab <path> alternative file to /etc/fstab
-h, --help display this help text and exit
-i, --internal-only don't call the mount.<type> helpers
-l, --show-labels lists all mounts with LABELs
-n, --no-mtab don't write to /etc/mtab
-o, --options <list> comma-separated list of mount options
-O, --test-opts <list> limit the set of filesystems (use with -a)
-r, --read-only mount the filesystem read-only (same as -o ro)
-t, --types <list> limit the set of filesystem types
--source <src> explicitly specifies source (path, label, uuid)
--target <target> explicitly specifies mountpoint
-v, --verbose say what is being done
-V, --version display version information and exit
-w, --rw, --read-write mount the filesystem read-write (default)
-h, --help display this help and exit
-V, --version output version information and exit
Source:
-L, --label <label> synonym for LABEL=<label>
-U, --uuid <uuid> synonym for UUID=<uuid>
LABEL=<label> specifies device by filesystem label
UUID=<uuid> specifies device by filesystem UUID
PARTLABEL=<label> specifies device by partition label
PARTUUID=<uuid> specifies device by partition UUID
<device> specifies device by path
<directory> mountpoint for bind mounts (see --bind/rbind)
<file> regular file for loopdev setup
Operations:
-B, --bind mount a subtree somewhere else (same as -o bind)
-M, --move move a subtree to some other place
-R, --rbind mount a subtree and all submounts somewhere else
--make-shared mark a subtree as shared
--make-slave mark a subtree as slave
--make-private mark a subtree as private
--make-unbindable mark a subtree as unbindable
--make-rshared recursively mark a whole subtree as shared
--make-rslave recursively mark a whole subtree as slave
--make-rprivate recursively mark a whole subtree as private
--make-runbindable recursively mark a whole subtree as unbindable
For more details see mount(8).

SLES12SP1:~ # mount --help
Usage:
mount [-lhV]
mount -a [options]
mount [options] [--source] <source> | [--target] <directory>
mount [options] <source> <directory>
mount <operation> <mountpoint> [<target>]
Options:
-a, --all mount all filesystems mentioned in fstab
-c, --no-canonicalize don't canonicalize paths
-f, --fake dry run; skip the mount(2) syscall
-F, --fork fork off for each device (use with -a)
-T, --fstab <path> alternative file to /etc/fstab
-h, --help display this help text and exit
-i, --internal-only don't call the mount.<type> helpers
-l, --show-labels lists all mounts with LABELs
-n, --no-mtab don't write to /etc/mtab
-o, --options <list> comma-separated list of mount options
-O, --test-opts <list> limit the set of filesystems (use with -a)
-r, --read-only mount the filesystem read-only (same as -o ro)
-t, --types <list> limit the set of filesystem types
--source <src> explicitly specifies source (path, label, uuid)
--target <target> explicitly specifies mountpoint
-v, --verbose say what is being done
-V, --version display version information and exit
-w, --rw, --read-write mount the filesystem read-write (default)
-h, --help display this help and exit
-V, --version output version information and exit
Source:
-L, --label <label> synonym for LABEL=<label>
-U, --uuid <uuid> synonym for UUID=<uuid>
LABEL=<label> specifies device by filesystem label
UUID=<uuid> specifies device by filesystem UUID
PARTLABEL=<label> specifies device by partition label
PARTUUID=<uuid> specifies device by partition UUID
<device> specifies device by path
<directory> mountpoint for bind mounts (see --bind/rbind)
<file> regular file for loopdev setup
Operations:
-B, --bind mount a subtree somewhere else (same as -o bind)
-M, --move move a subtree to some other place
-R, --rbind mount a subtree and all submounts somewhere else
--make-shared mark a subtree as shared
--make-slave mark a subtree as slave
--make-private mark a subtree as private
--make-unbindable mark a subtree as unbindable
--make-rshared recursively mark a whole subtree as shared
--make-rslave recursively mark a whole subtree as slave
--make-rprivate recursively mark a whole subtree as private
--make-runbindable recursively mark a whole subtree as unbindable
For more details see mount(8).

The /etc/fstab file

In the case where the mount command is used with the -a option, all mount points specified in the /etc/fstab file are mounted:

Debian

root@debian6:~# cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
# / was on /dev/sda1 during installation
UUID=a42a1ddd-14bc-4dde-a537-e6c1b984a782 / ext3 errors=remount-ro 0 1
# swap was on /dev/sda5 during installation
UUID=e21d8931-21ca-4ab3-9fbb-bd71657b312e none swap sw 0 0

root@debian7:~# cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
UUID=0f1cdb0c-8bd7-45ec-8d99-064292047bdb / ext4 errors=remount-ro 0 1
# swap was on /dev/sda5 during installation
UUID=ae5f67d1-6fad-487e-ad41-d53992a75755 none swap sw 0 0

root@debian8:~# cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
UUID=0ac29bda-b6bb-41c2-b47a-03fecb95bc87 / ext4 errors=remount-ro 0 1
# swap was on /dev/sda5 during installation
UUID=fa3153a5-5ef4-46fe-9115-d3773a06d283 none swap sw 0 0

Ubuntu

root@ubuntu1404:~# cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
UUID=70eb8bc5-1759-433d-9797-9342a7b82cb2 / ext4 errors=remount-ro 0 1
# swap was on /dev/sda5 during installation
UUID=85017f2f-081d-464e-ad83-52c3c895a113 none swap sw 0 0

root@ubuntu1604:~# cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
UUID=c27fce7f-cc8a-4c6f-b19b-d929a4d570f2 / ext4 errors=remount-ro 0 1
# swap was on /dev/sda5 during installation
UUID=68f67549-63f1-4833-b792-3566455bbe95 none swap sw 0 0

[root@centos5 ~]# cat /etc/fstab
LABEL=/ / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
LABEL=SWAP-sda3 swap swap defaults 0 0

RHEL/CentOS

[root@centos6 ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Fri May 3 13:33:42 2013
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=b9f29672-c84e-4d3b-b132-189758a084eb / ext4 defaults 1 1
UUID=01baf03d-df0d-479b-b3e4-81ce63b8dec3 /boot ext4 defaults 1 2
UUID=2646a33a-65f3-4501-9ced-9459435fd774 swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0

[root@centos7 ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Sun Mar 8 12:38:10 2015
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=b35de665-5ec8-4226-a533-58a1b567ac91 / xfs defaults 1 1
UUID=e8d3bd48-1386-411c-9675-41c3f8f1a309 /boot xfs defaults 1 2
UUID=11a4d11d-81e4-46a7-82e0-7796cd597dc9 swap swap defaults 0 0

SLES

SLES11SP1:~ # cat /etc/fstab
/dev/disk/by-id/ata-VBOX_HARDDISK_VB62af9a29-d9a982d5-part3 swap swap defaults 0 0
/dev/disk/by-id/ata-VBOX_HARDDISK_VB62af9a29-d9a982d5-part2 / ext3 acl,user_xattr 1 1
/dev/disk/by-id/ata-VBOX_HARDDISK_VB62af9a29-d9a982d5-part1 /boot ext3 acl,user_xattr 1 2
proc /proc proc defaults 0 0
sysfs /sys sysfs noauto 0 0
debugfs /sys/kernel/debug debugfs noauto 0 0
usbfs /proc/bus/usb usbfs noauto 0 0
devpts /dev/pts devpts mode=0620,gid=5 0 0

SLES12SP1:~ # cat /etc/fstab
UUID=db743358-c2d6-47f6-97d7-e7a9c650f0c5 swap swap defaults 0 0
UUID=6b7e374a-ae42-4f93-b6aa-d288dfbbb74b / btrfs defaults 0 0
UUID=6b7e374a-ae42-4f93-b6aa-d288dfbbb74b /boot/grub2/i386-pc btrfs subvol=@/boot/grub2/i386-pc 0 0
UUID=6b7e374a-ae42-4f93-b6aa-d288dfbbb74b /boot/grub2/x86_64-efi btrfs subvol=@/boot/grub2/x86_64-efi 0 0
UUID=6b7e374a-ae42-4f93-b6aa-d288dfbbb74b /home btrfs subvol=@/home 0 0
UUID=6b7e374a-ae42-4f93-b6aa-d288dfbbb74b /opt btrfs subvol=@/opt 0 0
UUID=6b7e374a-ae42-4f93-b6aa-d288dfbbb74b /srv btrfs subvol=@/srv 0 0
UUID=6b7e374a-ae42-4f93-b6aa-d288dfbbb74b /tmp btrfs subvol=@/tmp 0 0
UUID=6b7e374a-ae42-4f93-b6aa-d288dfbbb74b /usr/local btrfs subvol=@/usr/local 0 0
UUID=6b7e374a-ae42-4f93-b6aa-d288dfbbb74b /var/crash btrfs subvol=@/var/crash 0 0
UUID=6b7e374a-ae42-4f93-b6aa-d288dfbbb74b /var/lib/libvirt/images btrfs subvol=@/var/lib/libvirt/images 0 0
UUID=6b7e374a-ae42-4f93-b6aa-d288dfbbb74b /var/lib/mailman btrfs subvol=@/var/lib/mailman 0 0
UUID=6b7e374a-ae42-4f93-b6aa-d288dfbbb74b /var/lib/mariadb btrfs subvol=@/var/lib/mariadb 0 0
UUID=6b7e374a-ae42-4f93-b6aa-d288dfbbb74b /var/lib/mysql btrfs subvol=@/var/lib/mysql 0 0
UUID=6b7e374a-ae42-4f93-b6aa-d288dfbbb74b /var/lib/named btrfs subvol=@/var/lib/named 0 0
UUID=6b7e374a-ae42-4f93-b6aa-d288dfbbb74b /var/lib/pgsql btrfs subvol=@/var/lib/pgsql 0 0
UUID=6b7e374a-ae42-4f93-b6aa-d288dfbbb74b /var/log btrfs subvol=@/var/log 0 0
UUID=6b7e374a-ae42-4f93-b6aa-d288dfbbb74b /var/opt btrfs subvol=@/var/opt 0 0
UUID=6b7e374a-ae42-4f93-b6aa-d288dfbbb74b /var/spool btrfs subvol=@/var/spool 0 0
UUID=6b7e374a-ae42-4f93-b6aa-d288dfbbb74b /var/tmp btrfs subvol=@/var/tmp 0 0
UUID=6b7e374a-ae42-4f93-b6aa-d288dfbbb74b /.snapshots btrfs subvol=@/.snapshots 0 0

Understanding the /etc/fstab file

Each line in /etc/fstab has 6 fields :

Field 1	Field 2	Field 3	Field 4	Field 5	Field 6
Special file or UUID or Virtual File System	Mount Point	Filesystem Type	Comma separated list of options	Used by the dump command ( 1 = dump, 0 or empty = do not dump )	The order in which the fsck command checks the disks/partitions at boot time

The UUID ( Universally Unique Identifier ) is a randomly generated 128 bit string that is automatically generated by the system when a filesystem is created on the partition.

Mountpoint Options

The most important mount point options are as follows:

Option	Filesystem	Description	Default Value
defaults	All	Use default options: rw, suid, dev, exec, auto, nouser, and async.	N/A 1) Not Applicable
auto/noauto	All	Do or do not mount when “mount -a” is given.	auto
rw/ro	All	Mount the filesystem read-write/read-only.	rw
suid/nosuid	All	Allow/disallow set-user-identifier or set-group-identifier bits to take effect.	suid
dev/nodev	All	Interpret/do not interpret character or block special devices on the filesystem.	dev
exec/noexec	All	Permit/do not permit execution of binaries.	exec
sync/async	All	All I/O to the filesystem should be done synchronously/asynchronously.	async
user/nouser	All	Allow/disallow a user to mount. The mount point is read from the /etc/fstab file. Only the user that mounted the filesystem can unmount it.	N/A
users	All	Allow every user to mount and unmount the filesystem.	N/A
owner	All	Allow device owner to mount.	N/A
atime/noatime	POSIX	Do not use noatime feature, then the inode access time is controlled by kernel defaults/Do not update inode access times on this filesystem	atime
uid=value	Non-Linux filesystems	Set the owner of the root of the filesystem.	root
gid=value	Non-Linux filesystems	Set the group of the root of the filesystem.	N/A
umask=value	Non-Linux filesystems	Set the umask. The default is the umask of the current process. The value is given in octal.	N/A
dmask=value	Non-Linux filesystems	Set the umask applied to directories only. The value is given in octal.	Current processes' umask
fmask=value	Non-Linux filesystems	Set the umask applied to regular files only. The value is given in octal.	Current processes' umask

The umount command

To unmount a file system, you need to use the umount command. For example:

# umount /mnt/target_directory [Entrée]

Command Line Switches

The following switches can be used with the umount command:

trainee@debian8:~$ umount --help
Usage:
umount [-hV]
umount -a [options]
umount [options] <source> | <directory>
Options:
-a, --all unmount all filesystems
-A, --all-targets unmount all mountpoints for the given device in the
current namespace
-c, --no-canonicalize don't canonicalize paths
-d, --detach-loop if mounted loop device, also free this loop device
--fake dry run; skip the umount(2) syscall
-f, --force force unmount (in case of an unreachable NFS system)
-i, --internal-only don't call the umount.<type> helpers
-n, --no-mtab don't write to /etc/mtab
-l, --lazy detach the filesystem now, clean up things later
-O, --test-opts <list> limit the set of filesystems (use with -a)
-R, --recursive recursively unmount a target with all its children
-r, --read-only in case unmounting fails, try to remount read-only
-t, --types <list> limit the set of filesystem types
-v, --verbose say what is being done
-h, --help display this help and exit
-V, --version output version information and exit
For more details see umount(8).

root@ubuntu1604:~# umount --help
Usage:
umount [-hV]
umount -a [options]
umount [options] <source> | <directory>
Unmount filesystems.
Options:
-a, --all unmount all filesystems
-A, --all-targets unmount all mountpoints for the given device in the
current namespace
-c, --no-canonicalize don't canonicalize paths
-d, --detach-loop if mounted loop device, also free this loop device
--fake dry run; skip the umount(2) syscall
-f, --force force unmount (in case of an unreachable NFS system)
-i, --internal-only don't call the umount.<type> helpers
-n, --no-mtab don't write to /etc/mtab
-l, --lazy detach the filesystem now, clean up things later
-O, --test-opts <list> limit the set of filesystems (use with -a)
-R, --recursive recursively unmount a target with all its children
-r, --read-only in case unmounting fails, try to remount read-only
-t, --types <list> limit the set of filesystem types
-v, --verbose say what is being done
-h, --help display this help and exit
-V, --version output version information and exit
For more details see umount(8).

[root@centos7 ~]# umount --help
Usage:
umount [-hV]
umount -a [options]
umount [options] <source> | <directory>
Options:
-a, --all unmount all filesystems
-A, --all-targets unmount all mountpoins for the given device
in the current namespace
-c, --no-canonicalize don't canonicalize paths
-d, --detach-loop if mounted loop device, also free this loop device
--fake dry run; skip the umount(2) syscall
-f, --force force unmount (in case of an unreachable NFS system)
-i, --internal-only don't call the umount.<type> helpers
-n, --no-mtab don't write to /etc/mtab
-l, --lazy detach the filesystem now, and cleanup all later
-O, --test-opts <list> limit the set of filesystems (use with -a)
-R, --recursive recursively unmount a target with all its children
-r, --read-only In case unmounting fails, try to remount read-only
-t, --types <list> limit the set of filesystem types
-v, --verbose say what is being done
-h, --help display this help and exit
-V, --version output version information and exit
For more details see umount(8).

SLES12SP1:~ # umount --help
Usage:
umount [-hV]
umount -a [options]
umount [options] <source> | <directory>
Options:
-a, --all unmount all filesystems
-A, --all-targets unmount all mountpoints for the given device in the
current namespace
-c, --no-canonicalize don't canonicalize paths
-d, --detach-loop if mounted loop device, also free this loop device
--fake dry run; skip the umount(2) syscall
-f, --force force unmount (in case of an unreachable NFS system)
-i, --internal-only don't call the umount.<type> helpers
-n, --no-mtab don't write to /etc/mtab
-l, --lazy detach the filesystem now, clean up things later
-O, --test-opts <list> limit the set of filesystems (use with -a)
-R, --recursive recursively unmount a target with all its children
-r, --read-only in case unmounting fails, try to remount read-only
-t, --types <list> limit the set of filesystem types
-v, --verbose say what is being done
-h, --help display this help and exit
-V, --version output version information and exit
For more details see umount(8).

Unix File Systems

Each file system contains the following :

superblock

inodes

data blocks

Superblock

The superblock contains :

the block size,

the size of the file system,

the number of mounts for the file system,

a pointer to the root of the file system,

pointers to the free inodes,

pointers to free data blocks.

Linux maintains multiple redundant copies of the superblock in every file system.

For example, to view the primary and backup superblock locations on ext filesystems, use the following command:

root@debian8:~# mount | grep ext
/dev/sda1 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
root@debian8:~# dumpe2fs /dev/sda1 | grep -i superblock
dumpe2fs 1.42.12 (29-Aug-2014)
Primary superblock at 0, Group descriptors at 1-1
Backup superblock at 32768, Group descriptors at 32769-32769
Backup superblock at 98304, Group descriptors at 98305-98305
Backup superblock at 163840, Group descriptors at 163841-163841
Backup superblock at 229376, Group descriptors at 229377-229377
Backup superblock at 294912, Group descriptors at 294913-294913
Backup superblock at 819200, Group descriptors at 819201-819201
Backup superblock at 884736, Group descriptors at 884737-884737
Backup superblock at 1605632, Group descriptors at 1605633-1605633

root@ubuntu1604:~# mount | grep ext
/dev/sda1 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
root@ubuntu1604:~# dumpe2fs /dev/sda1 | grep -i superblock
dumpe2fs 1.42.13 (17-May-2015)
Primary superblock at 0, Group descriptors at 1-1
Backup superblock at 32768, Group descriptors at 32769-32769
Backup superblock at 98304, Group descriptors at 98305-98305
Backup superblock at 163840, Group descriptors at 163841-163841
Backup superblock at 229376, Group descriptors at 229377-229377
Backup superblock at 294912, Group descriptors at 294913-294913
Backup superblock at 819200, Group descriptors at 819201-819201
Backup superblock at 884736, Group descriptors at 884737-884737
Backup superblock at 1605632, Group descriptors at 1605633-1605633

SLES11SP1:~ # mount | grep ext
/dev/sda2 on / type ext3 (rw,acl,user_xattr)
/dev/sda1 on /boot type ext3 (rw,acl,user_xattr)
SLES11SP1:~ # dumpe2fs /dev/sda1 | grep -i superblock
dumpe2fs 1.41.9 (22-Aug-2009)
Primary superblock at 1, Group descriptors at 2-2
Backup superblock at 8193, Group descriptors at 8194-8194
Backup superblock at 24577, Group descriptors at 24578-24578
Backup superblock at 40961, Group descriptors at 40962-40962
Backup superblock at 57345, Group descriptors at 57346-57346
Backup superblock at 73729, Group descriptors at 73730-73730

To repair an ext file system using a backup superblock use the following command :

# e2fsck -f -b 32768 /dev/sda1 [Enter]

or

# e2fsck -f -b 8193 /dev/sda1 [Enter]

dependant upon which distribution you are using.

Inodes

Each file is represented by an inode. An inode contains the following information:

the file type : -, d, l, b, c, p, s,

file permissions, for example : rwx rw- r–,

the number of hard links,

the UID of the file creator or the current UID attributed by the chown command,

the GID of the creating process or the current GID attributed by the chgrp command,

the file size in bytes,

the date of the last modification of the file's inode content : ctime,

the date of the last modification of the file contents : mtime,

the date of the last access : atime,

allocation addresses that point to the data blocks used by the file.

For example:

Execute the following command:

root@debian8:~# ls -ld /dev/console /dev/sda1 /etc /etc/passwd
crw------- 1 root root 5, 1 Aug 18 11:29 /dev/console
brw-rw---- 1 root disk 8, 1 Aug 18 11:29 /dev/sda1
drwxr-xr-x 121 root root 12288 Aug 18 11:29 /etc
-rw-r--r-- 1 root root 2094 May 1 20:32 /etc/passwd

root@ubuntu1604:~# ls -ld /dev/console /dev/sda1 /etc /etc/passwd
crw------- 1 root root 5, 1 sept. 28 10:31 /dev/console
brw-rw---- 1 root disk 8, 1 sept. 28 10:31 /dev/sda1
drwxr-xr-x 129 root root 12288 sept. 28 10:41 /etc
-rw-r--r-- 1 root root 2296 mai 3 08:08 /etc/passwd

[root@centos7 ~]# ls -ld /dev/console /dev/sda1 /etc /etc/passwd
crw-------. 1 root root 5, 1 Sep 28 10:48 /dev/console
brw-rw----. 1 root disk 8, 1 Sep 28 10:48 /dev/sda1
drwxr-xr-x. 136 root root 8192 Sep 28 10:57 /etc
-rw-r--r--. 1 root root 2267 Sep 22 14:29 /etc/passwd

SLES12SP1:~ # ls -ld /dev/console /dev/sda1 /etc /etc/passwd
crw------- 1 root root 5, 1 Sep 28 10:37 /dev/console
brw-rw---- 1 root disk 8, 1 Sep 28 10:37 /dev/sda1
drwxr-xr-x 1 root root 4746 Sep 28 10:38 /etc
-rw-r--r-- 1 root root 1335 Sep 20 13:34 /etc/passwd

The first character of each line indicates the file type:

- - an ordinary file,

d - a directory,

l - a symbolic link,

b - a bloc type peripheral,

c - a character type peripheral,

p - a named pipe for communication between processes,

s - a network socket.

To see the inode numbers, execute the previous command with, in addition, the -i option:

root@debian8:~# ls -ldi /dev/console /dev/sda1 /etc /etc/passwd
5601 crw------- 1 root root 5, 1 Aug 18 11:29 /dev/console
6890 brw-rw---- 1 root disk 8, 1 Aug 18 11:29 /dev/sda1
38995 drwxr-xr-x 121 root root 12288 Aug 18 11:29 /etc
52831 -rw-r--r-- 1 root root 2094 May 1 20:32 /etc/passwd

root@ubuntu1604:~# ls -ldi /dev/console /dev/sda1 /etc /etc/passwd
14 crw------- 1 root root 5, 1 sept. 28 10:31 /dev/console
376 brw-rw---- 1 root disk 8, 1 sept. 28 10:31 /dev/sda1
390913 drwxr-xr-x 129 root root 12288 sept. 28 10:41 /etc
396002 -rw-r--r-- 1 root root 2296 mai 3 08:08 /etc/passwd

[root@centos7 ~]# ls -ldi /dev/console /dev/sda1 /etc /etc/passwd
4683 crw-------. 1 root root 5, 1 Sep 28 10:48 /dev/console
8107 brw-rw----. 1 root disk 8, 1 Sep 28 10:48 /dev/sda1
33595521 drwxr-xr-x. 136 root root 8192 Sep 28 10:57 /etc
35670335 -rw-r--r--. 1 root root 2267 Sep 22 14:29 /etc/passwd

SLES12SP1:~ # ls -ldi /dev/console /dev/sda1 /etc /etc/passwd
4306 crw------- 1 root root 5, 1 Sep 28 10:37 /dev/console
6871 brw-rw---- 1 root disk 8, 1 Sep 28 10:37 /dev/sda1
257 drwxr-xr-x 1 root root 4746 Sep 28 12:02 /etc
58930 -rw-r--r-- 1 root root 1335 Sep 20 13:34 /etc/passwd

Data Blocks

File data is stored in data blocks. In the case of a directory, the data block contains a table referencing the inodes and the names of the contents of the directory.

The name of the file is stored in the parent directory's data block and not in the inode. This means that a file can be referenced by one or more different names. To add a name to a data block, you need to create what is called a hard link.

Hard (Physical) Links

A hard link is created by using the ln command.

Debian

root@debian8:~# cd /tmp; mkdir inode; cd inode; touch file1; ls -ali
total 8
140612 drwxr-xr-x 2 root root 4096 Aug 18 13:28 .
130564 drwxrwxrwt 10 root root 4096 Aug 18 13:28 ..
140613 -rw-r--r-- 1 root root 0 Aug 18 13:28 file1

file1 shows an inode number of 140613 and a single name, indicated by the number 1 in the third column:

140613 -rw-r--r-- 1 root root 0 Aug 18 13:28 file1

now create the hard link and check the result:

root@debian8:/tmp/inode# ln file1 file2
root@debian8:/tmp/inode# ls -ali
total 8
140612 drwxr-xr-x 2 root root 4096 Aug 18 13:29 .
130564 drwxrwxrwt 10 root root 4096 Aug 18 13:28 ..
140613 -rw-r--r-- 2 root root 0 Aug 18 13:28 file1
140613 -rw-r--r-- 2 root root 0 Aug 18 13:28 file2

Now you can see two lines, one for file1 and a second for file2:

140613 -rw-r--r-- 2 root root 0 Aug 18 13:28 file1
140613 -rw-r--r-- 2 root root 0 Aug 18 13:28 file2

file1 and file2 are referenced by the same inode. As a result the number of names has been increased to two in the thrid column.

Ubuntu

root@ubuntu1604:~# cd /tmp; mkdir inode; cd inode; touch file1; ls -ali
total 8
521308 drwxr-xr-x 2 root root 4096 sept. 29 10:26 .
390918 drwxrwxrwt 10 root root 4096 sept. 29 10:26 ..
521340 -rw-r--r-- 1 root root 0 sept. 29 10:26 file1

file1 shows an inode number of 521340 and a single name, indicated by the number 1 in the third column:

521340 -rw-r--r-- 1 root root 0 sept. 29 10:26 file1

now create the hard link and check the result:

root@ubuntu1604:/tmp/inode# ln file1 file2
root@ubuntu1604:/tmp/inode# ls -ali
total 8
521308 drwxr-xr-x 2 root root 4096 sept. 29 10:27 .
390918 drwxrwxrwt 10 root root 4096 sept. 29 10:26 ..
521340 -rw-r--r-- 2 root root 0 sept. 29 10:26 file1
521340 -rw-r--r-- 2 root root 0 sept. 29 10:26 file2

Now you can see two lines, one for file1 and a second for file2:

521340 -rw-r--r-- 2 root root 0 sept. 29 10:26 file1
521340 -rw-r--r-- 2 root root 0 sept. 29 10:26 file2

file1 and file2 are referenced by the same inode. As a result the number of names has been increased to two in the thrid column.

RHEL/CentOS

[root@centos7 ~]# cd /tmp; mkdir inode; cd inode; touch file1; ls -ali
total 0
287056 drwxr-xr-x. 2 root root 60 Sep 28 12:16 .
11071 drwxrwxrwt. 10 root root 240 Sep 28 12:16 ..
287058 -rw-r--r--. 1 root root 0 Sep 28 12:16 file1

file1 shows an inode number of 287058 and a single name, indicated by the number 1 in the third column:

287058 -rw-r--r--. 1 root root 0 Sep 28 12:16 file1

now create the hard link and check the result:

[root@centos7 inode]# ln file1 file2
[root@centos7 inode]# ls -ali
total 0
287056 drwxr-xr-x. 2 root root 80 Sep 28 12:18 .
11071 drwxrwxrwt. 10 root root 240 Sep 28 12:16 ..
287058 -rw-r--r--. 2 root root 0 Sep 28 12:16 file1
287058 -rw-r--r--. 2 root root 0 Sep 28 12:16 file2

Now you can see two lines, one for file1 and a second for file2:

287058 -rw-r--r--. 2 root root 0 Sep 28 12:16 file1
287058 -rw-r--r--. 2 root root 0 Sep 28 12:16 file2

file1 and file2 are referenced by the same inode. As a result the number of names has been increased to two in the thrid column.

SLES

SLES12SP1:~ # cd /tmp; mkdir inode; cd inode; touch file1; ls -ali
total 0
442 drwxr-xr-x 1 root root 10 Sep 28 12:23 .
256 drwxrwxrwt 1 root root 112 Sep 28 12:23 ..
443 -rw-r--r-- 1 root root 0 Sep 28 12:23 file1

file1 shows an inode number of 443 and a single name, indicated by the number 1 in the third column:

443 -rw-r--r-- 1 root root 0 Sep 28 12:23 file1

now create the hard link and check the result:

SLES12SP1:/tmp/inode # ln file1 file2
SLES12SP1:/tmp/inode # ls -ali
total 0
442 drwxr-xr-x 1 root root 20 Sep 28 12:24 .
256 drwxrwxrwt 1 root root 112 Sep 28 12:23 ..
443 -rw-r--r-- 2 root root 0 Sep 28 12:23 file1
443 -rw-r--r-- 2 root root 0 Sep 28 12:23 file2

Now you can see two lines, one for file1 and a second for file2:

443 -rw-r--r-- 2 root root 0 Sep 28 12:23 file1
443 -rw-r--r-- 2 root root 0 Sep 28 12:23 file2

file1 and file2 are referenced by the same inode. As a result the number of names has been increased to two in the thrid column.

Important - Hard links cannot be created across file system boundaries. A hard link can only be created if the source file exists.

Soft (Symbolic) Links

A soft link is a shortcut to a file or directory. A soft link is created using the same ln command with the -s option.

Debian

root@debian8:/tmp/inode# ln -s file1 file3
root@debian8:/tmp/inode# ls -ali
total 8
140612 drwxr-xr-x 2 root root 4096 Aug 18 13:36 .
130564 drwxrwxrwt 10 root root 4096 Aug 18 13:28 ..
140613 -rw-r--r-- 2 root root 0 Aug 18 13:28 file1
140613 -rw-r--r-- 2 root root 0 Aug 18 13:28 file2
140614 lrwxrwxrwx 1 root root 5 Aug 18 13:36 file3 -> file1

Ubuntu

root@ubuntu1604:/tmp/inode# ln -s file1 file3
root@ubuntu1604:/tmp/inode# ls -ali
total 8
521308 drwxr-xr-x 2 root root 4096 sept. 29 10:32 .
390918 drwxrwxrwt 10 root root 4096 sept. 29 10:26 ..
521340 -rw-r--r-- 2 root root 0 sept. 29 10:26 file1
521340 -rw-r--r-- 2 root root 0 sept. 29 10:26 file2
521342 lrwxrwxrwx 1 root root 5 sept. 29 10:32 file3 -> file1

RHEL/CentOS

[root@centos7 inode]# ln -s file1 file3
[root@centos7 inode]# ls -ali
total 0
287056 drwxr-xr-x. 2 root root 100 Sep 28 12:30 .
11071 drwxrwxrwt. 10 root root 240 Sep 28 12:16 ..
287058 -rw-r--r--. 2 root root 0 Sep 28 12:16 file1
287058 -rw-r--r--. 2 root root 0 Sep 28 12:16 file2
333487 lrwxrwxrwx. 1 root root 5 Sep 28 12:30 file3 -> file1

SLES

SLES12SP1:/tmp/inode # ln -s file1 file3
SLES12SP1:/tmp/inode # ls -ali
total 4
442 drwxr-xr-x 1 root root 30 Sep 28 12:26 .
256 drwxrwxrwt 1 root root 112 Sep 28 12:23 ..
443 -rw-r--r-- 2 root root 0 Sep 28 12:23 file1
443 -rw-r--r-- 2 root root 0 Sep 28 12:23 file2
444 lrwxrwxrwx 1 root root 5 Sep 28 12:26 file3 -> file1

Note here that the soft link is referenced by a separate inode.

Important - A soft link can be created across file system boundaries and can be created even when the source file does not exist.

<html>

Copyright © 2004-2017 Hugh Norris.<br><br> <a rel=“license” href=“http://creativecommons.org/licenses/by-nc-nd/3.0/”><img alt=“Creative Commons License” style=“border-width:0” src=“https://i.creativecommons.org/l/by-nc-nd/3.0/88x31.png” /></a><br />This work is licensed under a <a rel=“license” href=“http://creativecommons.org/licenses/by-nc-nd/3.0/”>Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License</a>

</html>