相关函数：link, unlink
头文件：#include <unistd.h>
定义函数：int symlink(const char * oldpath, const char * newpath);函数说明：symlink()以参数newpath 指定的名称来建立一个新的连接(符号连接)到参数oldpath 所指定的已存在文件. 参数oldpath 指定的文件不一定要存在, 如果参数newpath 指定的名称为一已存在的文件则不会建立连接.
返回值：成功则返回0, 失败返回-1, 错误原因存于errno.错误代码：
1、EPERM 参数oldpath 与newpath 所指的文件系统不支持符号连接。
2、EROFS 欲测试写入权限的文件存在于只读文件系统内。
3、EFAULT 参数oldpath 或newpath 指针超出可存取内存空间。
4、ENAMETOOLONG 参数oldpath 或newpath 太长。
5、ENOMEM 核心内存不足。
6、EEXIST 参数newpath 所指的文件名已存在。
8、ELOOP 参数pathname 有过多符号连接问题。
9、ENOSPC 文件系统的剩余空间不足。
10、EIO I/O 存取错误。
范例
#include <unistd.h>
main()
{
}
展开全文
• [+]创建Web列表[-] git clone [-] cd Symlink-Scanner [+]如果有，请键入命令nano namalist.txt [-]请扫描您要扫描的Web内容[+]如果单击ctrl + x〜>保存〜>输入[+]运行程序[-] python2 Symlink.py [+]键入namalist....
• <div><p>Feature request: Symlink originals when cache originals is selected if no watermarks or modifications are needed. <p>I believe this is already the behavior for resized images that just happen ...
• os0.symlink(path1,path0) path0 += "/" + component0 component0 = "beta" os0.symlink(path1,path0) path0 += "/" + component0 path1 += "...
• Yet another <code>symlink</code> question'. I do so because I have seem lots of threads about it and although the workarounds are there (i.e. #2329 and #2617), I could not find a thread that ...
• grunt-contrib-symlink v1.0.0 创建符号链接。 入门 如果您以前从未使用过 ，请务必查看《指南》，因为它说明了如何创建以及安装和使用Grunt插件。 熟悉该过程后，可以使用以下命令安装此插件： npm install grunt...
• <div><p>It appears that the symlink from sites-available to sites-enabled is happening after the service gets refreshed. This is problematic as we need to bounce nginx manually (unless we make another...


函数种类: 文件存取

该函数用在Linux和WINDOWS2008以上系统。

参考
====================================================
fsutil hardlink create < 新文件名> <现有文件名>
Source             - Displays the Windows 2000 name targeted by Source
Source Destination - Links source directory to Destination directory or a Windows 2000 device or any valid Windows 2000 name
Source /D          - Deletes Source, regardless of whether a link exists at source
/?                 - Prints this help message
Windows Server 2003 Resource Kit 可以在微软网站下载到，在XP/Vista下也可以使用。
相关链接：http://www.microsoft.com/technet/sysinternals/FileAndDisk/Junction.mspx
Junction 的使用方法：
Junction v1.04 - Windows junction creator and reparse point viewer
Systems Internals - http://www.sysinternals.com
The first usage is for displaying reparse point information, and the second usage is for creating or deleting a NTFS junction point:
usage: junction.exe [-s] [-q] <file or directory>
-q     Don't print error messages (quiet)
-s     Recurse subdirectories
usage: junction.exe [-d] <junction directory> [<junction target>]
-d     Delete the specified junction
<目录路径 一>指向的目录必须为空！如果路径一不存在则自动创建一个新目录
<目录路径一>指向的空目录 会被删除，但是它指向的目标目录并不会受到影响
其他注意事项：

转载于:https://www.cnblogs.com/yisuo/p/9246945.html
展开全文
• 符号链接symlinkA symlink (also called a symbolic link) is a type of file in Linux that points to another file or a folder on your computer. Symlinks are similar to shortcuts in Windows. 符号链接(也...
符号链接symlinkA symlink (also called a symbolic link) is a type of file in Linux that points to another file or a folder on your computer. Symlinks are similar to shortcuts in Windows. 符号链接(也称为符号链接)是Linux中一种文件类型，它指向计算机上的另一个文件或文件夹。 符号链接类似于Windows中的快捷方式。
Some people call symlinks "soft links" – a type of link in Linux/UNIX systems – as opposed to "hard links." 有人称符号链接为“软链接”(Linux / UNIX系统中的一种链接)，而不是“硬链接”。
Soft links are similar to shortcuts, and can point to another file or directory in any file system. 软链接类似于快捷方式，并且可以指向任何文件系统中的另一个文件或目录。
Hard links are also shortcuts for files and folders, but a hard link cannot be created for a folder or file in a different file system. 硬链接也是文件和文件夹的快捷方式，但是无法为其他文件系统中的文件夹或文件创建硬链接。
Let's look at the steps involved in creating and removing a symlink. We'll also see what broken links are, and how to delete them. 让我们看看创建和删除符号链接所涉及的步骤。 我们还将看到什么是断开的链接，以及如何删除它们。
如何创建符号链接 (How to Create a Symlink)
The syntax for creating a symlink is: 创建符号链接的语法为：
ln -s <path to the file/folder to be linked> <the path of the link to be created>ln is the link command. The -s flag specifies that the link should be soft. -s can also be entered as -symbolic. ln是链接命令。 -s标志指定链接应为软链接。 -s也可以作为-symbolic输入。
By default, ln command creates hard links. The next argument is path to the file (or folder) that you want to link. (That is, the file or folder you want to create a shortcut for.)  默认情况下， ln命令创建硬链接。 下一个参数是您要链接path to the file (or folder) 。 (即，您要为其创建快捷方式的文件或文件夹。)
And the last argument is the path to link itself (the shortcut). 最后一个参数是path to link自身的path to link (快捷方式)。
如何为文件创建符号链接–示例命令 (How to Create a Symlink for a File – Example Command)
ln -s /home/james/transactions.txt trans.txtAfter running this command, you will be able to access the /home/james/transactions.txt with trans.txt. Any modification to trans.txt will also be reflected in the original file. 运行此命令后，您将能够使用/home/james/transactions.txt访问trans.txt 。 对trans.txt任何修改也将反映在原始文件中。
Note that this command above would create the link file trans.txt in your current directory. You can as well create a linked file in a folder link this: 请注意，上面的命令将在当前目录中创建链接文件trans.txt 。 您也可以在以下文件夹链接中创建链接文件：
ln -s /home/james/transactions.txt my-stuffs/trans.txtThere must be a directory already called "my-stuffs" in your current directory – if not the command will throw an error. 当前目录中必须已经有一个名为“ my-stuffs”的目录-如果没有，该命令将引发错误。
如何为文件夹创建符号链接–示例命令 (How to Create a Symlink for a Folder – Example Command)
Similar to above, we'd use: 与上述类似，我们将使用：
ln -s /home/james jamesThis would create a symlinked folder called 'james' which would contain the contents of /home/james. Any changes to this linked folder will also affect the original folder. 这将创建一个名为'james'的符号链接文件夹，其中包含/home/james的内容。 对此链接文件夹的任何更改也会影响原始文件夹。
如何删除符号链接 (How to remove a symlink)
Before you'd want to remove a symlink, you may want to confirm that a file or folder is a symlink, so that you do not tamper with your files.  在删除符号链接之前，您可能需要确认文件或文件夹是符号链接，以免篡改文件。
One way to do this is: 一种方法是：
ls -l <path-to-assumed-symlink>Running this command on your terminal will display the properties of the file. In the result, if the first character is a small letter L ('l'), it means the file/folder is a symlink. 在终端上运行此命令将显示文件的属性。 结果，如果第一个字符是小写字母L('l')，则表示文件/文件夹是符号链接。
You'd also see an arrow (->) at the end indicating the file/folder the simlink is pointing to. 您还将在末尾看到一个箭头(->)，指示simlink指向的文件/文件夹。
There are two methods to remove a symlink: 有两种方法可以删除符号链接：
The syntax is: 语法为：
unlink <path-to-symlink>This deletes the symlink if the process is successful. 如果过程成功，这将删除符号链接。
Even if the symlink is in the form of a folder, do not append '/', because Linux will assume it's a directory and unlink cannot delete directories. 即使符号链接是文件夹形式，也不要附加'/'，因为Linux将假定它是目录，并且unlink无法删除目录。
如何使用rm删除符号链接 (How to use rm to Remove a Symlink )
As we've seen, a symlink is just another file or folder pointing to an original file or folder. To remove that relationship, you can remove the linked file. 如我们所见，符号链接只是指向原始文件或文件夹的另一个文件或文件夹。 要删除该关系，可以删除链接的文件。
Hence, the syntax is: 因此，语法为：
rm <path-to-symlink>For example: 例如：
rm trans.txt
rm jamesNote that trying to do rm james/ would result an error, because Linux will assume 'james/' is a directory, which would require other options like r and f. But that's not what we want. A symlink may be a folder, but we are only concerned with the name. 注意，尝试执行rm james/会导致错误，因为Linux会假设'james /'是​​目录，这将需要其他选项，例如r和f 。 但这不是我们想要的。 一个符号链接可能是一个文件夹，但是我们只关心名称。
The main benefit of rm over unlink is that you can remove multiple symlinks at once, like you can with files. rm优于unlink的主要好处是，您可以一次删除多个符号链接，就像使用文件一样。
如何查找和删除断开的链接 (How to Find and Delete Broken Links)
Broken links occur when the file or folder that a symlink points to changes path or is deleted. 当符号链接指向的文件或文件夹更改路径或被删除时，链接断开。
For example, if 'transactions.txt' moves from /home/james to /home/james/personal, the 'trans.txt' link becomes broken. Every attempt to access to the file will result in a 'No such file or directory' error. This is because the link has no contents of its own. 例如，如果'transactions.txt'从/home/james移到/home/james/personal ，则'trans.txt'链接将断开。 每次尝试访问该文件都将导致“无此文件或目录”错误。 这是因为链接没有自己的内容。
When you discover broken links, you can easily delete the file. An easy way to find broken symlinks is: 发现断开的链接时，可以轻松删除文件。 查找损坏的符号链接的简单方法是：
find /home/james -xtype lThis will list all broken symlinks in the james directory – from files to directories to sub-directories. 这将列出james目录中所有损坏的符号链接–从文件到目录再到子目录。
Passing the -delete option will delete them like so: 传递-delete选项将删除它们，如下所示：
find /home/james -xtype l -delete 结语 (Wrapping up)
Symbolic link are an interesting feature of Linux and UNIX systems.  符号链接是Linux和UNIX系统的一个有趣功能。
You can create easily accessible symlinks to refer to a file or folder that would otherwise not be convenient to access. With some practice, you will understand how these work on an intuitive level, and they will make you much more efficient at managing file systems.
您可以创建易于访问的符号链接来引用原本不方便访问的文件或文件夹。 通过一些练习，您将了解它们在直观的水平上是如何工作的，它们将使您更加有效地管理文件系统。
翻译自: https://www.freecodecamp.org/news/symlink-tutorial-in-linux-how-to-create-and-remove-a-symbolic-link/符号链接symlink
展开全文
• <div><p>Would it be possible to add an option to forcibly link a file if the physical file already exists?</p><p>该提问来源于开源项目：anishathalye/dotbot</p></div>