Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux chown -R parameter, what does it mean [closed]

Tags:

linux

chown

The explanation is:

"-R, --recursive

operate on files and directories recursively"

What does "recursive" mean here?

like image 692
nomnom Avatar asked Jul 13 '13 09:07

nomnom


People also ask

What does the chown do in Linux?

The chown command changes user ownership of a file, directory, or link in Linux. Every file is associated with an owning user or group.

What does chown R mean?

The easiest way to use the chown recursive command is to execute “chown” with the “-R” option for recursive and specify the new owner and the folders that you want to change.

What is chmod chown?

chown is an abbreviation for “changing owner”, which is pretty self-explanatory. While chmod handles what users can do with a file once they have access to it, chown assigns ownership. As you may have noticed, none of the chmod commands we discussed above changed who owns the files we're working with.

How do you chown a group only?

Check out chgrp command. It can be used by the file owner to change the group ownership. No, this command only changes the group. chmod will change the owner and can be used to change both the owner and group.


3 Answers

"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 foo for all files and directories in /some/path

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

recursive, n: See recursive

like image 96
devnull Avatar answered Oct 04 '22 18:10

devnull


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

The command will operate on given folder, and recursively operates 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 -n is for displaying line numbers.

like image 26
Mohammad Javad Naderi Avatar answered Oct 04 '22 18:10

Mohammad Javad Naderi


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

like image 35
alex Avatar answered Oct 04 '22 20:10

alex