← 返回命令列表

Linux command

ln 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Create symbolic link

ln -s [target] [linkname]

Create hard link

ln [target] [linkname]

Create symbolic link (force overwrite)

ln -sf [target] [linkname]

Create link in directory

ln -s [target] [directory/]

Create relative symbolic link

ln -sr [target] [linkname]

Verbose output

ln -sv [target] [linkname]

说明

ln creates links between files. Hard links share the same inode; symbolic links are references. Symbolic links can span filesystems and link to directories. Hard links cannot.

参数

-s
Create symbolic (soft) link.
-f
Force, overwrite existing.
-r
Create relative symbolic link.
-v
Verbose output.
-n
Don't dereference symlinks.
--help
Display help information.

FAQ

What is the ln command used for?

ln creates links between files. Hard links share the same inode; symbolic links are references. Symbolic links can span filesystems and link to directories. Hard links cannot.

How do I run a basic ln example?

Run `ln -s [target] [linkname]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -s do in ln?

Create symbolic (soft) link.