I use command ls
, stat
, readlink
.
Take file /etc/localtime
as an example
[flying@lempstacker ~]$ ls /etc/localtime
/etc/localtime
[flying@lempstacker ~]$ ls -l /etc/localtime
lrwxrwxrwx. 1 root root 35 Aug 2 22:41 /etc/localtime -> ../usr/share/zoneinfo/Asia/Shanghai
Operation
Using stat
[flying@lempstacker ~]$ stat /etc/localtime
File: ‘/etc/localtime’ -> ‘../usr/share/zoneinfo/Asia/Shanghai’
Size: 35 Blocks: 0 IO Block: 4096 symbolic link
Device: fd01h/64769d Inode: 272202388 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2016-11-23 09:00:59.999887800 +0800
Modify: 2016-08-02 22:41:26.090389904 +0800
Change: 2016-08-02 22:41:26.090389904 +0800
Birth: -
[flying@lempstacker ~]$ stat -c "%N" /etc/localtime
‘/etc/localtime’ -> ‘../usr/share/zoneinfo/Asia/Shanghai’
Using readlink
[flying@lempstacker ~]$ readlink /etc/localtime
../usr/share/zoneinfo/Asia/Shanghai
[flying@lempstacker ~]$ readlink -f /etc/localtime
/usr/share/zoneinfo/Asia/Shanghai
It seems like that command readlink -f
is better.
Explanation
-f, --canonicalize: canonicalize by following every symlink in every component of the given name recursively; all but the last component must exist —— From man readlink
scp
versions follow symlinks by default, don't they? You should check yours and maybe save yourself some work. – jw013 Oct 6 '11 at 3:26scp -r
forces following symlinks. – Eonil Oct 6 '11 at 4:43