readlink 命令详解

| 选择喜欢的代码风格  

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

readlink 命令安装:


-bash/zsh: readlink command not found

#Debian
apt-get install coreutils

#Ubuntu
apt-get install coreutils

#Alpine
apk add coreutils

#Arch Linux
pacman -S coreutils

#Kali Linux
apt-get install coreutils

#CentOS
yum install coreutils

#Fedora
dnf install coreutils

#OS X
brew install coreutils

#Raspbian
apt-get install coreutils

#Docker
docker run cmd.cat/readlink readlink

readlink 命令补充说明:


readlink 命令是 Linux 系统中一个常用工具,主要用来找出符号链接所指向的位置。

PS:readlink 命令的 -e 选项,几乎等同于 realpath 命令

readlink 命令语法:


readlink [OPTION]... FILE

readlink 命令选项:


-f, --canonicalize
canonicalize by following every symlink in every component of the given name recursively; all but the last component must exist

-e, --canonicalize-existing
canonicalize by following every symlink in every component of the given name recursively, all components must exist

-m, --canonicalize-missing
canonicalize by following every symlink in every component of the given name recursively, without requirements on components existence

-n, --no-newline
do not output the trailing newline

-q, --quiet,

-s, --silent
suppress most error messages

-v, --verbose
report error messages

--help
display this help and exit

--version
output version information and exit

readlink 命令参数:


目标文件

readlink 命令实例:


readlink 获取符号链接指向的实际文件:

readlink filename

readlink 获取文件的绝对路径:

readlink -f filename

readlink 命令扩展阅读:




readlink 命令评论