ADVERTISEMENT

Linux Commands ❯ ln

ln

Make links between files
syntax:

ln [OPTION]... [-T] TARGET LINK_NAME
ln [OPTION]... TARGET
ln [OPTION]... TARGET... DIRECTORY
ln [OPTION]... -t DIRECTORY TARGET...
  • ln my_file1 my_file1_link1
    create a hard link called my_file1_link1 which refers to my_file1. the inode number will be same for both.
  • ln my_dir1/* my_dir2
    create hard links for all the files under my_dir1 in directory my_dir2
  • ln -f my_file1 my_file1_link1
    create a hard link called my_file1_link1 which refers to my_file1. any existing file called my_file1_link1 will be overwritten
  • ln -i my_file1 my_file1_link1
    create a hard link called my_file1_link1 which refers to my_file1.prompted to overwrite any existing file called my_file1_link1
  • ln -s my_file1 my_file1_link1
    create a symbolic/soft link called my_file1_link1 which refers to my_file1. the inode number of the soft link defers the actual file.
  • ln -s my_dir1 my_dir1_link1
    create a symbolic/soft link called my_dir1_link1 which refers to directory my_dir1. the inode number of the soft link defers the actual directory.
  • ln -t my_dir1 my_file1
    create a hard link called my_file1 which refers to my_file1 in my_dir1 directory