为什么一个命令有效而另一个命令无效\xe2\x80\x99t?我找到了一些远程相关的文章,但我无法理解它们。
\n$ sudo ls -la /tmp/restricted\ntotal 12\ndrwxr-x---. 2 root root 42 Mar 17 17:40 .\ndrwxrwxrwt. 12 root root 12288 Mar 17 17:37 ..\n-rwxrwxr-x. 1 root tms 0 Mar 17 17:22 foo1\n-rwxrwxr-x. 1 root tms 0 Mar 17 17:22 foo2\n-rwxrwxr-x. 1 root tms 0 Mar 17 17:22 foo3\n\n$ sudo ls -a /tmp/restricted/foo*\nls: cannot access /tmp/restricted/foo*: No such file or directory\n
Run Code Online (Sandbox Code Playgroud)\n请注意,如果我将 /tmp/restricted 上的权限更改为 755 而不是 750,则两个命令都会成功:
\n$ sudo chmod 755 /tmp/restricted/\n\n$ sudo ls -la /tmp/restricted\ntotal 12\ndrwxr-xr-x. 2 root root 42 Mar 17 17:40 .\ndrwxrwxrwt. 12 root root 12288 Mar 17 17:37 ..\n-rwxrwxr-x. 1 root tms 0 Mar 17 17:22 foo1\n-rwxrwxr-x. 1 root tms 0 Mar 17 17:22 foo2\n-rwxrwxr-x. 1 root tms 0 Mar 17 17:22 foo3\n\n$ sudo ls -a /tmp/restricted/foo*\n/tmp/restricted/foo1 /tmp/restricted/foo2 /tmp/restricted/foo3\n
Run Code Online (Sandbox Code Playgroud)\n
Ste*_*itt 10
当您运行时sudo ls -la /tmp/restricted
,ls
以 root 身份运行并具有对/tmp/restricted
.
当您运行 时sudo ls -a /tmp/restricted/foo*
,您的 shell(不是以 root 身份运行)会尝试扩展/tmp/restricted/foo*
。它可以\xe2\x80\x99t,并且在你的情况下不考虑参数。ls
以 root 身份运行,参数为/tmp/restricted/foo*
,并且由于不存在具有该名称的文件,因此失败并显示您看到的错误消息\xe2\x80\x99。
通过强制 shell 不使用 glob,您可以看到相同的错误:(除非您在当前目录中ls "*"
有一个真正命名的文件)。*
归档时间: |
|
查看次数: |
2078 次 |
最近记录: |