为什么 ls -la 不显示当前目录是符号链接?

4 linux filesystems symlink

这更像是一种好奇心,但我注意到/etc/httpd/logs符号链接到/var/log/httpd,但是当我在里面时/etc/httpd/logsls -la我看到:

drwx------ 2 root root    4096 Mar 21 14:58 .
drwxr-xr-x 9 root root    4096 Mar 17 03:10 ..
Run Code Online (Sandbox Code Playgroud)

为什么.条目不显示 lrwx....

但是当我去/etc/httpd和做ls -la我看到:

lrwxrwxrwx 1 root root   19 Mar  4 17:12 logs -> ../../var/log/httpd
Run Code Online (Sandbox Code Playgroud)

jsc*_*ott 7

我可以回答一个问题吗?假设您在此处安装了 RedHat/CentOS...

ls /etc/httpd/
  # should return something like:
  # conf  conf.d  logs  modules  run
cd /etc/httpd/logs/
  # Why does this next command fail?
ls ../conf
  # ls: cannot access ../conf: No such file or directory
  # But this next command works?
cd ../conf
Run Code Online (Sandbox Code Playgroud)

简短的回答是,当您在“内部” /etc/httpd/logs(符号链接)时,您实际上是在内部/var/log/httpd,这一个目录。

cd /etc/httpd/logs/
pwd
  # /etc/httpd/logs
pwd -P
  # /var/log/httpd  
Run Code Online (Sandbox Code Playgroud)