Chown: Difference between revisions

From Psygen Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
Line 6: Line 6:
<code>chown bob myfile.txt</code> Changes the owner of '''myfile.txt''' to '''bob'''
<code>chown bob myfile.txt</code> Changes the owner of '''myfile.txt''' to '''bob'''


Change the group:
Change the group:<br />
<code>chown :office myfile.txt</code> Change just the group of '''myfile.txt''' to '''office'''.
<code>chown :office myfile.txt</code> Change just the group of '''myfile.txt''' to '''office'''.


Change the owner and the group:
Change the owner and the group:<br />
<code>chown bob:office myfile.txt</code> Change the owner of '''myfile.txt''' to '''bob''', and change the group to '''office'''
<code>chown bob:office myfile.txt</code> Change the owner of '''myfile.txt''' to '''bob''', and change the group to '''office'''


Change the owner and group (shortcut):
Change the owner and group (shortcut):<br />
<code>chown bob. myfile.txt</code> Change the owner of '''myfile.txt''' to '''bob''', and change the group to the '''bob''' group.
<code>chown bob. myfile.txt</code> Change the owner of '''myfile.txt''' to '''bob''', and change the group to the '''bob''' group.


Change the owner and group for a directory, and all files and directories below it:
Change the owner and group for a directory, and all files and directories below it:<br />
<code>chown -R bob. /home/bob/workf</code>
<code>chown -R bob. /home/bob/workf</code>



Latest revision as of 03:13, 21 December 2016

chown changes the user and/or group ownership of a file or directory.

Examples:

Change the owner:
chown bob myfile.txt Changes the owner of myfile.txt to bob

Change the group:
chown :office myfile.txt Change just the group of myfile.txt to office.

Change the owner and the group:
chown bob:office myfile.txt Change the owner of myfile.txt to bob, and change the group to office

Change the owner and group (shortcut):
chown bob. myfile.txt Change the owner of myfile.txt to bob, and change the group to the bob group.

Change the owner and group for a directory, and all files and directories below it:
chown -R bob. /home/bob/workf

References

  1. chown man page