在 Debian(以及其它 Linux 系统)里,“软连接文件”就是符号链接(symbolic link,symlink)。下面按常见需求给你几种找法。
find 查找软连接文件find /path/to/dir -type l
例如查找整个系统(较慢):
find / -type l
find /path/to/dir -type l -lname "target*"
例如查找指向 python3 的软连接:
find /usr -type l -lname "*python3*"
ls 查看软连接ls -l
软连接会显示成:
lrwxrwxrwx 1 root root 10 Mar 1 10:00 link -> target
ls -l | grep '^l'
file 判断是否为软连接file 文件名
示例输出:
link: symbolic link to target
readlink 查看软连接指向readlink 软连接名
查看并解析绝对路径:
readlink -f 软连接名
find /path/to/dir -xtype l
或者:
find /path/to/dir -type l ! -exec test -e {} \; -print
ls -l /usr/bin | grep '^l'
lib*.so 软连接find /usr/lib -type l -name "*.so*"
如果你是想找某个软件的软连接、清理无效软连接,或者批量处理软连接,可以告诉我具体场景,我给你更针对性的命令。