Reference rookie tutorial Linux: https: //www.runoob.com/linux/linux-comm-ln.html
ln the linux command. Linux ln command is a very important command, its function is to establish a link synchronization at another location for a certain file. When we need a different directory, use the same file, we do not need in the catalog every need are a must to put the same file, As long as we have a fixed directory, put the file, and then use the ln command links (link) it can, without having to repeat the disk space occupied in other directories. grammar: ln [parameters] [source file or directory] [destination file or directory] Wherein the format for the parameter [-bdfinsvF] [-S backup-suffix] [-V {numbered,existing,simple}] [--help] [--version] [--] Function: Linux file system, the so-called link (link), we can be regarded as an alias files, and links can be divided into two types: hard link (hard link) and soft Then (symbolic link), a hard link means can have a plurality of file names, and the soft link is a way to produce a special file, the contents of the file It is a pointer to another file location. A hard link is the presence of the same file system, but it can be a soft link across different file systems. Whether soft or hard links will not link to a copy of the original file, it will only occupy a very small amount of disk space. Soft links: 1 soft link, in the form of the path. Like shortcuts Windows operating system 2 soft links can span file systems, hard links can not be 3 . Soft links can be linked to a file name that does not exist 4 . Soft links can link to the directory Hard Links: 1 . Hard link, in the form of a copy of the file. But do not take up physical space. 2 Do not allow to create hard links to directories 3 . Hard links can only be created in the same file system Command parameters Necessary parameters: - b delete, covering previously established links - d superuser is allowed to make hard links to directories - f enforce - i interactive mode, the user is prompted whether the file exists covering - the n-generally regarded as the symbolic link directory - S soft link (symbol link) - v displays detailed process Select parameters: -S " -S <backup suffix string> " or " --suffix = <backup suffix string> " -V " -V <backup> " or " --version-Control = <backup> " - help displays help information - version display version information Examples Create a soft link to the file, create a soft link link2013 as log2013.log file, if log2013.log lost, link2013 will fail: ln -s log2013.log link2013 Output: [root@localhost test]# ll -rw-r--r-- 1 root bin 61 11-13 06:03 log2013.log [root@localhost test]# ln -s log2013.log link2013 [root@localhost test]# ll lrwxrwxrwx 1 root root 11 12-07 16:01 link2013 -> log2013.log -rw-r--r-- 1 root bin 61 11-13 06:03 log2013.log Create a hard link to the file, create a hard link ln2013 as log2013.log, the same as the property of log2013.log and ln2013 ln log2013.log ln2013 Output: [root@localhost test]# ll lrwxrwxrwx 1 root root 11 12-07 16:01 link2013 -> log2013.log -rw-r--r-- 1 root bin 61 11-13 06:03 log2013.log [root@localhost test]# ln log2013.log ln2013 [root@localhost test]# ll lrwxrwxrwx 1 root root 11 12-07 16:01 link2013 -> log2013.log -rw-r--r-- 2 root bin 61 11-13 06:03 ln2013 -rw-r--r-- 2 root bin 61 11-13 06:03 log2013.log