我对 linux 相当sudo <command>
陌生<command>
,直到现在,一直认为与执行root
. 我最近玩了一下这个ls
命令,注意到了一个轻微但令人困惑的差异。
执行时sudo ls -lap
(在根目录中),我得到以下输出:
与当我ls -lap
作为root
(或作为没有 的普通用户sudo
)执行时:
Apart from the obvious but not important color difference, if you actually look closer, you see that the -p
option (showing a /
after directories) didn't work on links
when executing the command with sudo
.
Is there an actual difference between the two? Or is that a bug?
And either way, doesnt that mean that both commands are processed differently?
Your ls
is an alias, and sudo
doesn’t know about it. When you switch users to become root
, your interactive shell runs its startup scripts and sets up the relevant aliases.
Try running alias ls
as root
, not via sudo
, to see the corresponding command.
符号链接的输出差异似乎是向输出添加颜色的副作用:
ls -lp --color=tty /
v.
ls -lp --color=never /
将显示相同的差异。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句