2018-11-15 22:33:39 +00:00
|
|
|
|
|
|
|
---
|
|
|
|
layout: page
|
|
|
|
category-page: basic
|
|
|
|
category-title: Basic commands
|
|
|
|
author: Joy Albertini
|
|
|
|
tags:directory file chown symbolic link
|
|
|
|
title: chown
|
|
|
|
---
|
|
|
|
|
|
|
|
<p>The <code>chown</code>
|
|
|
|
If you want to change the user ID of a specific file, you can use chown. <br>
|
|
|
|
Device-name:Current-position username$ chown owner[:group] file <br>
|
|
|
|
Example chown Joy:student alice.txt add Joy to the group student <br>
|
|
|
|
Use chgrp [:group] file to create a group for a file <br>
|
|
|
|
Use Sudo chown owner[:group], if you need root permission for add the user to the group </p>
|
|
|
|
|
|
|
|
<pre>
|
2018-11-16 19:47:01 +00:00
|
|
|
chown user [group] file1 file2 ...
|
2018-11-15 22:33:39 +00:00
|
|
|
</pre>
|
|
|
|
|
|
|
|
<ul>
|
2018-11-16 19:47:01 +00:00
|
|
|
<li><b>-f</b> Don't show all error messages except usage messages.</li>
|
|
|
|
<li><b>-h</b> Changes the symbolic link and not the file or directory referred
|
|
|
|
by the symbolic link.
|
|
|
|
</li>
|
|
|
|
<li><b>-R</b> changing the ownership for each file in a folder, if it encounters
|
|
|
|
a symbolic link it will cheange the owenership of that symbolic link,
|
|
|
|
and the directoryfile referred in the symbolic link, but the directory is not
|
|
|
|
further transversed.
|
|
|
|
</li>
|
|
|
|
<li><b>-RH</b> changing the ownership for each file in a folder, if encounter symbolic link
|
|
|
|
it will change the owenership of that symbolic link,
|
|
|
|
the directory/file referred in the symbolic link, and all the
|
|
|
|
directory is further transversed.
|
|
|
|
</li>
|
|
|
|
<li><b>-RL</b> If the -R option is specified and a symbolic link referencing a file of type directory
|
|
|
|
is specified on the command line or encountered during the traversal of a file hierarchy,
|
|
|
|
the chown command shall change the user ID (and group ID, if specified) of the directory
|
|
|
|
referenced by the symbolic link and all files in the file hierarchy below it.
|
|
|
|
</li>
|
|
|
|
<li><b>-RP</b> changing the ownership for each file in a folder, if encounter symbolic
|
|
|
|
link it will cheange the owenership of that symbolic link, but will not chenage the
|
|
|
|
the directory/file referred in the symbolic link, and the directory is not
|
|
|
|
further transversed.
|
|
|
|
</li>
|
2018-11-15 22:33:39 +00:00
|
|
|
</ul>
|