Symbolic Link

  ln -s source_file myfile

     Replace source_file with the name of the existing file for which you want to create the symbolic link (this file can be any existing file or directory across the file systems). Replacemyfile with the name of the symbolic link. Theln command then creates the symbolic link. After you've made the symbolic link, you can perform an operation on or executemyfile, just as you could with thesource_file. You can use normal file management commands (e.g.,cp, rm) on the symbolic link.

     Note: If you delete the source file or move it to a different location, your symbolic file will not function properly. You should either delete or move it. If you try to use it for other purposes (e.g., if you try to edit or execute it), the system will send a "file nonexistent" message.

 

 

lrwxrwxrwx

drwx------

第一个符号代表文件类型,d是文件夹,l是连接文件,-是普通文件,后面的是权限,r是读取,w是写入,x是执行,3个为1段,第一段代表的是建立这个文件的用户权限,第二段为建立这个文件的用户所属组的权限,第三段为其他用户的权限,哪像为空,则没有这个权限

 

 

$ echo Hello >myfile
$ ln -s myfile mylink
$ ls -il
total 4
    169 -rw-rw-r--    1 zhang     zhang            6 Dec 10 21:30 myfile
    416 lrwxrwxrwx    1 zhang     zhang            6 Dec 10 21:30 mylink
-> myfile
$ cat myfile
Hello
$ cat mylink
Hello

 

您可以看到 mylink 的文件类型是 l,这表示它是一个符号链接。进入权限对符号链接并不重要:它们总是 rwxrwxrwx。您也可以看到它一个与 myfile 不同的文件,因为它们的信息节点号是不同的。但是它符号化地指向了这个文件,因此当您键入 cat mylink 的时候,您实际将打印 myfile 的内容。我们可以通过如下操作证明符号链接的内容是任意字符串:

$ ln -s "I'm no existing file" anotherlink
$ ls -il anotherlink
    418 lrwxrwxrwx    1 zhang     zhang           20 Dec 10 21:43 anotherlink
-> I'm no existing file
$ cat anotherlink
cat: anotherlink: No such file or directory

你可能感兴趣的:(function,File,command,delete,System)