Linux

Changing Ownership: chown

The 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>
Example
Before apply chown command by default view of ls- l command.
See the figure given below.
 ls -l
ls -l

Now I want to change the owner of file "tri".
 ls -l
ls -l

Want to see the effect ? ok apply ls -l command again .
 ls -l
ls -l

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.
chown  -R
chown -R

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 .. command
chown  -R
chown -R

The result would be
chown  -R
chown -R

I think no need to explain. You can use the command in verbose mode using -v with command like this.
chown  -R -v
chown -R -v

Use man page to know the other options.




admin