Linux Basics

65 / 87
   

Files & Directories - Symbolic links

A symbolic link points to a file. In case, the original file is deleted, the symbolic link would be pointing to non-existing file.

You can create a symbolic link to a directory too.

  1. Create a file:

    nano orig_text1
    
  2. Put the following text in it:

    This is my not-so-valuable data
    
  3. Save and Exit: Press Ctrl+x and y

  4. Check if the file has right data:

    cat orig_text1
    
  5. Create Link:

    ln -s orig_text1 myslink
    
  6. Check if it is there:

    ls -l myslink
    

    You should see something like this

    lrwxrwxrwx 1 sandeepgiri9034 sandeepgiri9034 10 Dec 14 11:45 myslink -> orig_text1
    
  7. Check the contents of myslink using:

    cat myslink