how to use “ln” command with its examples

  • It is used to make links between files in Linux/UNIX environment.
  • It comes from “coreutils-8.4” package.
  • Path: /bin/ln

Examples:

1. To create a link of an existing file

$ ln file.txt file.ln

2. To create an soft link for the existing file

$ ln -s file.txt file.ln

3. To make a backup of each destination file

$ ln –backup file.txt file.bk

4. To allow super user to attempt to create hard linked directories

$ ln -d

5. To create the links with removing the existing destination files

$ ln -f
$ ln –force

6. To prompt whether to remove the destination file

$ ln -i
$ ln –interactive 

7. To make hard links to symbolic link references

$ ln -L
$ ln –logical 

8. To treat the destination symlink directory as file

$ ln -n
$ ln –no-dereference 

9. To make hard links directly to symbolic links

$ ln -P
$ ln –physical

10. To make symbolic links instead of hard links

$ ln -s

11. To override the usual backup suffix

$ ln -S
$ ln –suffix=SUFFIX 

12. To specify the directory to which the directory should be created

$ ln -t
$ ln –target-directory=DIRECTORY 

13. To treat the link name as normal file

$ ln -T
$ ln –no-target-directory 

14. To print the name of each linked file

$ ln -v
$ ln –verbose

15. To get the help for ln

$ ln –help

16. To get the version info

$ ln –version

Related Commands: link, symlink 

Leave a Reply

Your email address will not be published. Required fields are marked *