Linux chown -R 参数,是什么意思

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17629046/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-07 00:15:18  来源:igfitidea点击:

Linux chown -R parameter, what does it mean

linuxchown

提问by nomnom

The explanation is:

解释是:

"-R, --recursive

operate on files and directories recursively"

"-R, --recursive

递归操作文件和目录”

What does "recursive" mean here?

“递归”在这里是什么意思?

采纳答案by devnull

"Recursive" implies that the operation will be performed for all files and directories (and all files and directories within any directory). So

“递归”意味着将对所有文件和目录(以及任何目录中的所有文件和目录)执行操作。所以

chown -R foo /some/path

would change file owner to foofor all files and directories in /some/path

会将文件所有者更改foo为中的所有文件和目录/some/path

p.s. You might have even seen the dictionary entry for recursive:

ps 您甚至可能已经看过以下词典条目recursive

recursive, n: See recursive

递归, n: 见递归

回答by alex

It means apply it to sub-directories and their contents, that is, recursechown()when a directory is encountered.

这意味着将其应用于子目录及其内容,即遇到目录时递归chown()

回答by Mohammad Javad Naderi

In some Linux commands, if you run the command on a folderwith -R, the command will operate on all files and folders in that folder's tree. If you run the command on a file, -Rhas no effect.

在一些Linux命令,如果你在运行该命令的文件夹-R,该命令将在该文件夹的树中的所有文件和文件夹进行操作。如果对文件运行该命令,-R则无效。

The command will operate on given folder, and recursivelyoperates on files and folders within it. It is based on recursion.

该命令将对给定文件夹进行操作,并递归操作其中的文件和文件夹。它基于递归

For example, you can remove a folder and its contents with

例如,您可以删除文件夹及其内容

rm -R folder-name

Or you can find all occurrences of a specific string in all files within current folder tree with

或者,您可以使用以下命令在当前文件夹树中的所有文件中查找特定字符串的所有出现

grep -R -n the-string . 

In this example -nis for displaying line numbers.

本例-n中用于显示行号。