符号链接symlink_什么是符号链接或符号链接? 如何为Windows和Linux创建Symlink?

符号链接symlink

符号链接symlink

Symbolic Links are also known as Symlinks. Symlinks are used to create a shortcut for a given file or folder. Symlinks are very useful for different purposes which also prevents copy the same data over and over again. In this tutorial, we will learn what is symlinks and how to create and use symlinks for Linux and Windows operating systems?

符号链接也称为符号链接。 符号链接用于为给定文件或文件夹创建快捷方式。 符号链接对于不同目的非常有用,这也可以防止一遍又一遍地复制相同的数据。 在本教程中,我们将学习什么是符号链接以及如何为Linux和Windows操作系统创建和使用符号链接?

符号链接类型 (Symlink Types)

There is two type of symlinks. These are called Soft and Hard. Generally, Symlink is used for Soft symbolic links which are more popular than hard links.

符号链接有两种类型。 这些分别称为“软”和“硬”。 通常,Symlink用于软符号链接,该符号链接比硬链接更流行。

软符号链接 (Soft Symlinks)

Soft links are just links they do not contain actual data. Soft symlinks can be used to point different partitions.

软链接只是它们不包含实际数据的链接。 软符号链接可用于指向不同的分区。

硬符号链接 (Hard Symlinks)

Hardlinks are used to point directly to the actual data. Hard links can not be used to point to different partitions.

硬链接用于直接指向实际数据。 硬链接不能用于指向不同的分区。

为Windows创建Symlink (Create Symlink For Windows)

Windows operating systems provide mklink command to create the soft and hard symlink. If we want to create symlinks for paths like C:\ we generally need Administrator privileges because of these paths is a special path for users.

Windows操作系统提供mklink命令来创建软符号链接和硬符号链接。 如果我们要为诸如C:\类的路径创建符号链接,通常需要管理员特权,因为这些路径是用户的特殊路径。

为文件创建软符号链接 (Create Soft Symlink For File)

We can create a soft symbolic link for a file just providing the file name and symbolic link name like below. We will create a link named test.bat.

我们可以为文件创建一个软符号链接,只需提供文件名和符号链接名,如下所示。 我们将创建一个名为test.bat的链接。

> mklink test.bat autoexec.bat
Create Soft Symlink For File
Create Soft Symlink For File
为文件创建软符号链接

为目录/文件夹创建软符号链接(Create Soft Symlink For Directory/Folder)

In order to create Hard Symlink for a file we will use /D option like below. We will also provide source and link name.

为了为文件创建Hard Symlink,我们将使用/D选项,如下所示。 我们还将提供源名称和链接名称。

> mklink /D test.bat autoexec.bat
Create Hard Symlink For File
Create Hard Symlink For File
为文件创建硬符号链接

为文件创建硬符号链接(Create Hard Symlink For  File)

We can create a hard symlink for a file with the /H options like below.

我们可以使用/H选项为文件创建硬符号链接,如下所示。

> mklink /H test.bat autoexec.bat

为目录/文件夹创建硬符号链接 (Create Hard Symlink For Directory/Folder)

In order to create a hard symlink for a directory or a folder, we will provide the /J option like below.

为了为目录或文件夹创建硬符号链接,我们将提供如下的/J选项。

> mklink /J test.bat autoexec.bat

为Linux创建Symlink (Create Symlink For Linux)

Linux distributions like Ubuntu, Debian, Mint, Kali, Fedora, RedHat, CentOS provides the ln command in order to create symlinks. ln command can detect the file or folder and create symlink automatically. We will just provide soft or hard link option.

Linux发行版,如Ubuntu,Debian,Mint,Kali,Fedora,RedHat,CentOS提供ln命令以创建符号链接。 ln命令可以检测文件或文件夹并自动创建符号链接。 我们将只提供软链接或硬链接选项。

LEARN MORE  Useful Linux Commands
了解更多有用Linux命令

创建软符号链接(Create Soft Symlink)

We will use ln command in order to create a soft link for a file or directory. We will provide the -s option which means create a soft link, not a hard link.

我们将使用ln命令来为文件或目录创建软链接。 我们将提供-s选项,这意味着创建一个软链接,而不是硬链接。

$ ln -s /home/ismail/run.sh /mnt/run.sh

创建硬符号链接 (Create Hard Symlink)

We can create hard symlinks with the ln command too. We will just provide the source file name and the link name like below.

我们也可以使用ln命令创建硬符号链接。 我们将只提供源文件名和链接名,如下所示。

$ ln  /home/ismail/run.sh /mnt/run.sh
 

翻译自: https://www.poftut.com/what-is-symbolic-or-symlinks-how-to-create-symlink-for-windows-and-linux/

符号链接symlink

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值