Answered Questions

  • Hard link and Soft link

    What is the difference between hard link and soft link?

    Star Read Best Answer

    Editorial / Best Answer

    BijaylaxmiMohapatra  

    • Member Since Nov-2008 | Nov 29th, 2008


    Hard Link
    when a file is copied, both the original and copy occupy separate space on the disk.
    unix allows a file to have more than one name and yet maintain a single copy on the disk. The file is then said to have more than one link or name, but all have the same inode number. This is called hard link. All attributes are identical any modification or change in one file is automatically available in the linked file. It provides some protection against accidental deletion. Let there be a file named restore.sh. You need to create another file which provides as backup to the original file. By creating a link, you create a backup.
    unix command used to create hard link >>ln- backup.sh restore.sh

    Soft Link
    It doesn't have the file's content but simply provids pathname of that automatically has the contents. This is called as softlink. but incase the original file is deleted we can't get the file's content from the linked file, coz, it just provides the path name of the file. This is also known as symbolic link. Windows shortcuts are more like symbolic links. The original file and the linked files have different inode nos.
    Unix command used to create soft link>>ln-s