软链接
A symbolic link merely contains a text string that is interpreted and followed by the operating system as a path to another file or directory. It is a file on its own and can exist independently of its target. If a symbolic link is deleted, its target remains unaffected. If the target is moved, renamed or deleted, any symbolic link that used to point to it continues to exist but now points to a non-existing file. Symbolic links pointing to non-existing files are sometimes called orphaned or dangling.
符号链接仅包含一个文本字符串,操作系统将其解释并作为另一个文件或目录的路径。它本身就是一个文件,可以独立于目标而存在。如果删除了符号链接,则其目标不受影响。如果移动,重命名或删除目标,则用于指向它的任何符号链接将继续存在,但现在指向不存在的文件。指向不存在文件的符号链接有时称为孤立或悬空。
ln -s source_file可以直接在当前目录下生成指向source_file的文件或文件夹,得到的结果时直接链接到文件夹,相当于快捷方式;-
ln -s source_file file.link可以直接生成指向source_file的link,得到的结果是直接链接到文件夹,相当于快捷方式; cp -rs file_dir soft.link.dir是递归创建file_dir中每一个子文件的软链接,且若file_dir中如果新增文件,soft.link.dir中不会新增文件的软链接。
ln -s和cp -rs的区别:
- ln -s 软链接到文件夹,子文件和子文件夹没有产生软链接;
- cp -rs 软链接到子文件,这样产生的文件软链接,比如可执行文件,拥有的是当前用户的权限。比如在trade用户下软链接到deploy用户下的可执行文件,得到的权限为trade用户的权限,而不是deploy用户的权限。
linux创建软链接的绝对路径与相对路径
建议使用绝对路径,避免不必要的困扰。https://www.cnblogs.com/simpleminds/p/7677164.html