Table of Contents

Create Hard And Soft Links

General Information

Creating “short cuts” to files/directories.


Soft link

Hard link


Example listing of a symbolic link

ls -l /etc/systemd/system/
lrwxrwxrwx. 1 root root   37 Oct 17  2014 default.target -> /lib/systemd/system/multi-user.target

Create symlink

ln -s /etc/motd motd-local

Create hardlink

touch file1
ln file1 file2

List the files

ll
-rw-------. 1 root root       9227 Oct 17  2014 anaconda-ks.cfg
-rw-r--r--. 2 root root          0 Jun 20 15:11 file1
-rw-r--r--. 2 root root          0 Jun 20 15:11 file2

List with inode (-i) information

ls -li
  8419076 -rw-------. 1 root root       9227 Oct 17  2014 anaconda-ks.cfg
  8442605 -rw-r--r--. 2 root root          0 Jun 20 15:11 file1
  8442605 -rw-r--r--. 2 root root          0 Jun 20 15:11 file2