root即使未设置权限,用户也可以写入文件write。
root即使未设置权限,用户也可以读取文件read。
root即使未设置权限,用户也可以 cd进入目录execute。
root未设置权限时,用户无法执行文件execute。
为什么?
user$ echo '#!'$(which bash) > file
user$ chmod 000 file
user$ ls -l file
---------- 1 user user 12 Jul 17 11:11 file
user$ cat file # Normal user cannot read
cat: file: Permission denied
user$ su
root$ echo 'echo hello' >> file # root can write
root$ cat file # root can read …Run Code Online (Sandbox Code Playgroud) 在tar命令的手册页中,列出了跟踪硬链接的选项。
-h, --dereference
follow symlinks; archive and dump the files they point to
--hard-dereference
follow hard links; archive and dump the files they refer to
Run Code Online (Sandbox Code Playgroud)
如何tar知道文件是硬链接?它是如何遵循的?
如果我不选择这个选项怎么办?它是如何不硬解引用?
在一些答案下,我看到建议避免在答案中使用特定于 shell 的命令的评论。
我如何知道所有 shell 中存在哪些命令、运算符等?有标准清单吗?
man builtins给出命令列表。这些是我可以在适用于所有 shell 的便携式 shell 脚本中使用的唯一命令吗?而不是在终端屏幕上显示所有可能性,如:
$ ls /etc/<TAB>
Display all 230 possibilities? (y or n)
Run Code Online (Sandbox Code Playgroud)
我想将所有可能性保存到一个文件中。
ls /etc/ > file.txt不会总是有效。apt-get 就是一个例子:
$ apt-get <TAB>
autoclean check install update
autoremove clean purge upgrade
build-dep dist-upgrade remove
changelog dselect-upgrade source
Run Code Online (Sandbox Code Playgroud)
我正在寻找类似tabcompletions 'ls /etc/'输出所有可能性的命令,以便我可以运行如下命令,该命令比较两个命令的选项卡完成可能性:
diff <(tabcompletions 'ls ') <(tabcompletions 'cd ')
Run Code Online (Sandbox Code Playgroud)
那可能吗?
我在某处看到了这种重定向的用法,并认为这是一个错字:
grep root < /etc/passwd
Run Code Online (Sandbox Code Playgroud)
但是在我运行它之后,我看到它给出了与以下相同的输出
grep root /etc/passwd:
$ grep root < /etc/passwd
root:x:0:0:root:/root:/bin/bash
$ grep root /etc/passwd
root:x:0:0:root:/root:/bin/bash
Run Code Online (Sandbox Code Playgroud)
同样的事情发生在
cat < /etc/passwd
cat /etc/passwd
Run Code Online (Sandbox Code Playgroud)
但是,与 一起使用时,重定向将被忽略ls:
ls < /etc/passwd
Run Code Online (Sandbox Code Playgroud)
不打印相同的输出
ls /etc/passwd
Run Code Online (Sandbox Code Playgroud)
怎么了?
bash ×3
command-line ×2
shell ×2
autocomplete ×1
executable ×1
hard-link ×1
io ×1
linux ×1
permissions ×1
root ×1
standard ×1
tar ×1