Changing Ownership: chown
command lets you to change the ownership of a file to someone else. Only the
root user can do this.
The format of the command is as follows:
[root@local host ~]# chown <owner name> <dir/file>
Before apply chown
command by default view of ls- l
See the figure given below.
Now I want to change the owner of file "tri".
Want to see the effect ? ok apply ls -l command again .
Wow command works, owner mohit is replaced by wisdom.
Let play with its options.
[root@local host ~]#chown -R <username> <directory>
This option tells
the command to recursively descend through the directory tree and apply the new ownership
not only to the directory itself, but to all of the files and directories within it.
Check the status of directory /home/mohit/max
I think you would have understood that owner of some files is root and owner of rest of the files is mohit
Before applying command take one back using cd ..
The result would be
I think no need to explain.
You can use the command in verbose mode using -v
with command like this.
chown -R -v
Use man page to know the other options.