How to create a symbolic link

Symbolic Link (referred also as symlink or soft link) is a file containing reference to either another file or a directory. They are supported by POSIX operating system standard such as Linux, FreeBSD, Mac OS X and in Windows operating system in the form of shortcut files.

Command to create a Symbolic Link

To create a symbolic link use ln command as shown below:

ln -s real-folder link folder

With above command link-folder will actually contain everything real-folder have. Also if any file is saved on the link-folder, it will actually save it into the real-folder.

Explained with example:

Suppose I want to create symbolic link folder householdAppliances on /var/www path. The actual (real) folder householdAppliances is on /home/sam path. For this following command is executed.

sudo ln -s /home/sam/householdAppliances /var/www


/home/sam/householdAppliances is a actual folder 
/var/www is a link folder that contains householdAppliances when command is executed
For e.g., after the command it look like


Accessing symbolic link folder: 

1. cd /var/www/
2. ll

Looks as: 

lrwxrwxrwx  1 sam www-data   32 Nov 28 11:35 householdAppliances -> /home/sam/householdAppliances/