12 Awesome chown command practical examples to change owner and group

Everybody knows that, “everything is a file in linux”. So file permission is very important one, all the files and folders having four important parts (special one ,owner,group,others). In this article i’m going to explain about, how to change the owner and group permission to files and folders. We can change owner/user and group permission using chown command.

Syntax :

The common syntax for chown command.

Syntax :# chown [-Options] [Owner-Name]:[Group-Name] [File/Folder Name]

1) How to Change the ownership of a file ?

See the below output (test100.zip file associated owner and group with root) and now i’m going to change the ownership of file from root to mageshm.

[email protected] [/home/mageshm]# ls -la
total 216372
-rw-------.  1 mageshm mageshm      1663 Feb 15 15:50 .bash_history
-rw-r--r--.  1 mageshm mageshm        18 May 11  2012 .bash_logout
-rw-r--r--.  1 mageshm mageshm       176 May 11  2012 .bash_profile
-rw-r--r--.  1 mageshm mageshm       124 May 11  2012 .bashrc
-rw-r--r--.  1 root    root           26 Dec 27 17:55 liks
drwxr-xr-x.  3 mageshm mageshm      4096 Dec 31 14:24 links/
drwxrwxr-x.  2 mageshm mageshm      4096 Nov 16 15:44 perl5/
lrwxrwxrwx.  1 root    root           31 Dec  7 15:11 s-link-file -> /links/soft-link/test-soft-link
-rw-r--r--.  1 root  root    104874307 Dec 30  2012 test100.zip
-rw-r--r--.  1 root    root     11536384 Dec 30  2012 test10.zip
-rw-r--r--.  1 root    root           61 Dec 27 19:05 test2-bzip2.txt 

Use the below command to change the file ownership.

[email protected] [/home/mageshm]# chown magesh test100.zip

[email protected] [/home/mageshm]# ls -la
total 216372
-rw-------.  1 mageshm mageshm      1663 Feb 15 15:50 .bash_history
-rw-r--r--.  1 mageshm mageshm        18 May 11  2012 .bash_logout
-rw-r--r--.  1 mageshm mageshm       176 May 11  2012 .bash_profile
-rw-r--r--.  1 mageshm mageshm       124 May 11  2012 .bashrc
-rw-r--r--.  1 root    root           26 Dec 27 17:55 liks
drwxr-xr-x.  3 mageshm mageshm      4096 Dec 31 14:24 links/
drwxrwxr-x.  2 mageshm mageshm      4096 Nov 16 15:44 perl5/
lrwxrwxrwx.  1 root    root           31 Dec  7 15:11 s-link-file -> /links/soft-link/test-soft-link
-rw-r--r--.  1 mageshm root    104874307 Dec 30  2012 test100.zip
-rw-r--r--.  1 root    root     11536384 Dec 30  2012 test10.zip
-rw-r--r--.  1 root    root           61 Dec 27 19:05 test2-bzip2.txt 

2) How to Change the group of a file ?

See the above output (test100.zip file associated group with root) and now i’m going to change the group of file from root to mageshm. Use the below command to change the file group.

[email protected] [/home/mageshm]# chown :magesh test100.zip

[email protected] [/home/mageshm]# ls -la
total 216372
-rw-------.  1 mageshm mageshm      1663 Feb 15 15:50 .bash_history
-rw-r--r--.  1 mageshm mageshm        18 May 11  2012 .bash_logout
-rw-r--r--.  1 mageshm mageshm       176 May 11  2012 .bash_profile
-rw-r--r--.  1 mageshm mageshm       124 May 11  2012 .bashrc
-rw-r--r--.  1 root    root           26 Dec 27 17:55 liks
drwxr-xr-x.  3 mageshm mageshm      4096 Dec 31 14:24 links/
drwxrwxr-x.  2 mageshm mageshm      4096 Nov 16 15:44 perl5/
lrwxrwxrwx.  1 root    root           31 Dec  7 15:11 s-link-file -> /links/soft-link/test-soft-link
-rw-r--r--.  1 mageshm mageshm 104874307 Dec 30  2012 test100.zip
-rw-r--r--.  1 root    root     11536384 Dec 30  2012 test10.zip
-rw-r--r--.  1 root    root           61 Dec 27 19:05 test2-bzip2.txt 

3) How to Change the owner and group (both at a time) of a file ?

See the above output (test2-bzip2.txt file associated owner and group with root) and now i’m going to change the owner and group of file from root to 2daygeek. Use the below command to change the file owner and group.

[email protected] [/home/mageshm]# chown 2daygeek:2daygeek test2-bzip2.txt

[email protected] [/home/mageshm]# ls -la
total 216372
-rw-------.  1 mageshm  mageshm      1663 Feb 15 15:50 .bash_history
-rw-r--r--.  1 mageshm  mageshm        18 May 11  2012 .bash_logout
-rw-r--r--.  1 mageshm  mageshm       176 May 11  2012 .bash_profile
-rw-r--r--.  1 mageshm  mageshm       124 May 11  2012 .bashrc
-rw-r--r--.  1 root     root           26 Dec 27 17:55 liks
drwxr-xr-x.  3 mageshm  mageshm      4096 Dec 31 14:24 links/
drwxrwxr-x.  2 mageshm  mageshm      4096 Nov 16 15:44 perl5/
lrwxrwxrwx.  1 root     root           31 Dec  7 15:11 s-link-file -> /links/soft-link/test-soft-link
-rw-r--r--.  1 mageshm  mageshm 104874307 Dec 30  2012 test100.zip
-rw-r--r--.  1 root     root     11536384 Dec 30  2012 test10.zip
-rw-r--r--.  1 2daygeek 2daygeek       61 Dec 27 19:05 test2-bzip2.txt 

4) How to Change the owner and group more then one file ?

See the above output (test2-bzip2.txt (2daygeek) and test100.zip(mageshm) file associated owner and group with mageshm and 2daygeek) and now i’m going to change the owner and group of files to root. Use the below command to change more then one file owner and group.

[email protected] [/home/mageshm]# chown root:root test100.zip test2-bzip2.txt

[email protected] [/home/mageshm]# ls -la
total 216372
-rw-------.  1 mageshm mageshm      1663 Feb 15 15:50 .bash_history
-rw-r--r--.  1 mageshm mageshm        18 May 11  2012 .bash_logout
-rw-r--r--.  1 mageshm mageshm       176 May 11  2012 .bash_profile
-rw-r--r--.  1 mageshm mageshm       124 May 11  2012 .bashrc
-rw-r--r--.  1 root    root           26 Dec 27 17:55 liks
drwxr-xr-x.  3 mageshm mageshm      4096 Dec 31 14:24 links/
drwxrwxr-x.  2 mageshm mageshm      4096 Nov 16 15:44 perl5/
lrwxrwxrwx.  1 root    root           31 Dec  7 15:11 s-link-file -> /links/soft-link/test-soft-link
-rw-r--r--.  1 root    root    104874307 Dec 30  2012 test100.zip
-rw-r--r--.  1 root    root     11536384 Dec 30  2012 test10.zip
-rw-r--r--.  1 root    root           61 Dec 27 19:05 test2-bzip2.txt 

5) How to Change the owner and group Recursively ?

See the below output, links folder having owner and group mageshm and all the files having (root permission) and folders having (mageshm permission) Recursively. Now i’m going to change owner and group permission to 2daygeek.

[email protected] [/home/mageshm]# ls -la
total 216372
-rw-------.  1 mageshm mageshm      1663 Feb 15 15:50 .bash_history
-rw-r--r--.  1 mageshm mageshm        18 May 11  2012 .bash_logout
-rw-r--r--.  1 mageshm mageshm       176 May 11  2012 .bash_profile
-rw-r--r--.  1 mageshm mageshm       124 May 11  2012 .bashrc
-rw-r--r--.  1 root    root           26 Dec 27 17:55 liks
drwxr-xr-x.  3 mageshm mageshm      4096 Dec 31 14:24 links/
drwxrwxr-x.  2 mageshm mageshm      4096 Nov 16 15:44 perl5/
lrwxrwxrwx.  1 root    root           31 Dec  7 15:11 s-link-file -> /links/soft-link/test-soft-link
-rw-r--r--.  1 root    root    104874307 Dec 30  2012 test100.zip
-rw-r--r--.  1 root    root     11536384 Dec 30  2012 test10.zip
-rw-r--r--.  1 root    root           61 Dec 27 19:05 test2-bzip2.txt

[email protected] [/home/mageshm]# cd links
[email protected] [/home/mageshm/links]# ls -la
total 16
drwxr-xr-x. 3 mageshm mageshm 4096 Dec 31 14:25 soft-link/
-rw-r--r--. 1 root    root      60 Dec 27 19:40 test-bzip2.txt

[email protected] [/home/mageshm/links]# cd soft-link
[email protected] [/home/mageshm/links/soft-link]# ls -la
total 16
-rw-r--r--. 1 root    root      61 Dec 27 19:40 test2-bzip2.txt
drwxr-xr-x. 2 mageshm mageshm 4096 Dec 31 14:25 test-soft-link-folder/

[email protected] [/home/mageshm/links/soft-link]# cd test-soft-link-folder
[email protected] [/home/mageshm/links/soft-link/test-soft-link-folder]# ls -la
total 12
-rw-r--r--. 1 root    root      61 Dec 27 19:40 test1-bzip2.txt 

Use the below command to change Recursively file/folders owner and group.

[email protected] [/home/mageshm]# chown -R 2daygeek:2daygeek links

[email protected] [/home/mageshm]# ls -la
total 216372
-rw-------.  1 mageshm  mageshm      1663 Feb 15 15:50 .bash_history
-rw-r--r--.  1 mageshm  mageshm        18 May 11  2012 .bash_logout
-rw-r--r--.  1 mageshm  mageshm       176 May 11  2012 .bash_profile
-rw-r--r--.  1 mageshm  mageshm       124 May 11  2012 .bashrc
-rw-r--r--.  1 root     root           26 Dec 27 17:55 liks
drwxr-xr-x.  3 2daygeek 2daygeek      4096 Dec 31 14:24 links/
drwxrwxr-x.  2 mageshm  mageshm      4096 Nov 16 15:44 perl5/
lrwxrwxrwx.  1 root     root           31 Dec  7 15:11 s-link-file -> /links/soft-link/test-soft-link
-rw-r--r--.  1 root     root    104874307 Dec 30  2012 test100.zip
-rw-r--r--.  1 root     root     11536384 Dec 30  2012 test10.zip
-rw-r--r--.  1 root     root           61 Dec 27 19:05 test2-bzip2.txt

[email protected] [/home/mageshm]# cd links
[email protected] [/home/mageshm/links]# ls -la
total 16
drwxr-xr-x. 3 2daygeek 2daygeek 4096 Dec 31 14:25 soft-link/
-rw-r--r--. 1 2daygeek 2daygeek   60 Dec 27 19:40 test-bzip2.txt

[email protected] [/home/mageshm/links]# cd soft-link
[email protected] [/home/mageshm/links/soft-link]# ls -la
total 16
-rw-r--r--. 1 2daygeek 2daygeek   61 Dec 27 19:40 test2-bzip2.txt
drwxr-xr-x. 2 2daygeek 2daygeek 4096 Dec 31 14:25 test-soft-link-folder/

[email protected] [/home/mageshm/links/soft-link]# cd test-soft-link-folder
[email protected] [/home/mageshm/links/soft-link/test-soft-link-folder]# ls -la
total 12
-rw-r--r--. 1 2daygeek 2daygeek 61 Dec 27 19:40 test1-bzip2.txt

6) How to Change the owner and group to link files ?

Here i’m going to change the link file (index.html and the original file is located at /home/2daygeek/index.html) owner and group permission from root to mageshm. See what will be happen.

[email protected] [/home/mageshm]# chown mageshm:mageshm index.html

[email protected] [/home/mageshm]# ls -la
total 216372
-rw-------.  1 mageshm mageshm      1663 Feb 15 15:50 .bash_history
-rw-r--r--.  1 mageshm mageshm        18 May 11  2012 .bash_logout
-rw-r--r--.  1 mageshm mageshm       176 May 11  2012 .bash_profile
-rw-r--r--.  1 mageshm mageshm       124 May 11  2012 .bashrc
-rw-r--r--.  1 root    root           26 Dec 27 17:55 liks
drwxr-xr-x.  3 mageshm mageshm      4096 Dec 31 14:24 links/
drwxrwxr-x.  2 mageshm mageshm      4096 Nov 16 15:44 perl5/
lrwxrwxrwx.  1 root    root           25 Feb 19 17:29 index.html -> /home/2daygeek/index.html
-rw-r--r--.  1 root    root    104874307 Dec 30  2012 test100.zip
-rw-r--r--.  1 root    root     11536384 Dec 30  2012 test10.zip
-rw-r--r--.  1 root    root           61 Dec 27 19:05 test2-bzip2.txt 

It seem’s that there is no change on current directory, Now i’m moving to 2daygeek directory and found that the source index.html file owner and group permission has been changed.

[email protected] [/home/mageshm]# cd ..

[email protected] [/home/mageshm]# cd 2daygeek

[email protected] [/home/mageshm]# ls -la
total 48
-rw-------.  1 2daygeek 2daygeek  675 Feb 15 15:48 .bash_history
-rw-r--r--.  1 2daygeek 2daygeek   18 May 11  2012 .bash_logout
-rw-r--r--.  1 2daygeek 2daygeek  176 May 11  2012 .bash_profile
-rw-r--r--.  1 2daygeek 2daygeek  124 May 11  2012 .bashrc
drwxr-xr-x.  3 root     root     4096 Jan 24 13:57 cp-test/
-rw-r--r--.  1 mageshm  mageshm    23 Feb 19 17:04 index.html
drwxrwxr-x.  2 2daygeek 2daygeek 4096 Nov 19 15:42 perl5/
drwxrwxr-x.  2 2daygeek 2daygeek 4096 Nov 19 15:42 public_ftp/
drwxrwxr-x.  3 2daygeek 2daygeek 4096 Nov 19 15:42 public_html/
-rw-r--r--.  1 root     root      211 Dec 16 11:55 test

7) How to Change the owner and group to link files forcefully using (-h) option ?

If you read the above example, you know what was happen. Here i’m going to change the link file owner and group permission from root to 2daygeek forcefully using (-h) option. See what will be happen.

[email protected] [/home/mageshm]# chown -h 2daygeek:2daygeek index.html

[email protected] [/home/mageshm]# ls -la
total 216372
-rw-------.  1 mageshm  mageshm      1663 Feb 15 15:50 .bash_history
-rw-r--r--.  1 mageshm  mageshm        18 May 11  2012 .bash_logout
-rw-r--r--.  1 mageshm  mageshm       176 May 11  2012 .bash_profile
-rw-r--r--.  1 mageshm  mageshm       124 May 11  2012 .bashrc
-rw-r--r--.  1 root     root           26 Dec 27 17:55 liks
drwxr-xr-x.  3 mageshm  mageshm      4096 Dec 31 14:24 links/
drwxrwxr-x.  2 mageshm  mageshm      4096 Nov 16 15:44 perl5/
lrwxrwxrwx.  1 2daygeek 2daygeek       25 Feb 19 17:29 index.html -> /home/2daygeek/index.html
-rw-r--r--.  1 root     root    104874307 Dec 30  2012 test100.zip
-rw-r--r--.  1 root     root     11536384 Dec 30  2012 test10.zip
-rw-r--r--.  1 root     root           61 Dec 27 19:05 test2-bzip2.txt 

Yes, Now the link file ownership permission got changed.

8) How to Change the ownership of a file using (- -from) option ?

See the above example output (test100.zip file associated owner and group with root) and now i’m going to change the ownership of file from root to mageshm using (- -from) option. See what will be happen.

[email protected] [/home/mageshm]# chown --from=root mageshm test100.zip

[email protected] [/home/mageshm]# ls -la
total 216372
-rw-------.  1 mageshm  mageshm      1663 Feb 15 15:50 .bash_history
-rw-r--r--.  1 mageshm  mageshm        18 May 11  2012 .bash_logout
-rw-r--r--.  1 mageshm  mageshm       176 May 11  2012 .bash_profile
-rw-r--r--.  1 mageshm  mageshm       124 May 11  2012 .bashrc
-rw-r--r--.  1 root     root           26 Dec 27 17:55 liks
drwxr-xr-x.  3 mageshm  mageshm      4096 Dec 31 14:24 links/
drwxrwxr-x.  2 mageshm  mageshm      4096 Nov 16 15:44 perl5/
lrwxrwxrwx.  1 2daygeek 2daygeek      25 Feb 19 17:29 index.html -> /home/2daygeek/index.html
-rw-r--r--.  1 mageshm  root    104874307 Dec 30  2012 test100.zip
-rw-r--r--.  1 root     root     11536384 Dec 30  2012 test10.zip
-rw-r--r--.  1 root     root           61 Dec 27 19:05 test2-bzip2.txt 

Now, the file ownership permission got changed from root to mageshm

9) How to Change the group of a file using (–from) option ?

See the above example output (test100.zip file associated owner and group with root) and now i’m going to change the ownership of file from root to mageshm using (–from) option. See what will be happen.

[email protected] [/home/mageshm]# chown --from=:root :mageshm test100.zip

[email protected] [/home/mageshm]# ls -la
total 216372
-rw-------.  1 mageshm  mageshm      1663 Feb 15 15:50 .bash_history
-rw-r--r--.  1 mageshm  mageshm        18 May 11  2012 .bash_logout
-rw-r--r--.  1 mageshm  mageshm       176 May 11  2012 .bash_profile
-rw-r--r--.  1 mageshm  mageshm       124 May 11  2012 .bashrc
-rw-r--r--.  1 root     root           26 Dec 27 17:55 liks
drwxr-xr-x.  3 mageshm  mageshm      4096 Dec 31 14:24 links/
drwxrwxr-x.  2 mageshm  mageshm      4096 Nov 16 15:44 perl5/
lrwxrwxrwx.  1 2daygeek 2daygeek       25 Feb 19 17:29 index.html -> /home/2daygeek/index.html
-rw-r--r--.  1 mageshm  mageshm 104874307 Dec 30  2012 test100.zip
-rw-r--r--.  1 root    root     11536384 Dec 30  2012 test10.zip
-rw-r--r--.  1 root    root           61 Dec 27 19:05 test2-bzip2.txt 

Now, the file group permission got changed from root to mageshm

10) How to copy the owner/group permission from one file to another file ?

See the above example output (test100.zip file associated owner and group with mageshm and test10.zip file associated owner and group with root) and now i’m going to copy the owner/group permission from test100.zip file to test10.zip file using (–reference) option. See what will be happen.

[email protected] [/home/mageshm]# chown --from=:root :mageshm test100.zip

[email protected] [/home/mageshm]# ls -la
total 216372
-rw-------.  1 mageshm  mageshm      1663 Feb 15 15:50 .bash_history
-rw-r--r--.  1 mageshm  mageshm        18 May 11  2012 .bash_logout
-rw-r--r--.  1 mageshm  mageshm       176 May 11  2012 .bash_profile
-rw-r--r--.  1 mageshm  mageshm       124 May 11  2012 .bashrc
-rw-r--r--.  1 root     root           26 Dec 27 17:55 liks
drwxr-xr-x.  3 mageshm  mageshm      4096 Dec 31 14:24 links/
drwxrwxr-x.  2 mageshm  mageshm      4096 Nov 16 15:44 perl5/
lrwxrwxrwx.  1 2daygeek 2daygeek       25 Feb 19 17:29 index.html -> /home/2daygeek/index.html
-rw-r--r--.  1 mageshm    root  104874307 Dec 30  2012 test100.zip
-rw-r--r--.  1 mageshm mageshm   11536384 Dec 30  2012 test10.zip
-rw-r--r--.  1 root    root           61 Dec 27 19:05 test2-bzip2.txt 

Now, the file owner/group permission got changed from root to mageshm

11) How to Change the owner and group to link directory/folder forcefully using (-H) option ?

Here i’m going to change the link directory owner and group permission from root to magshm forcefully using (-H) option. See what will be happen. I’m going to create the softlink to folder. See the current status of link folder permission and original location.

[email protected] [/home/mageshm]# ln -s /home/2daygeek/cp-test /home/mageshm/

[email protected] [/home/mageshm]# ls -la
total 216372
-rw-------.  1 mageshm  mageshm      1663 Feb 15 15:50 .bash_history
-rw-r--r--.  1 mageshm  mageshm        18 May 11  2012 .bash_logout
-rw-r--r--.  1 mageshm  mageshm       176 May 11  2012 .bash_profile
-rw-r--r--.  1 mageshm  mageshm       124 May 11  2012 .bashrc
-rw-r--r--.  1 root     root           26 Dec 27 17:55 liks
drwxr-xr-x.  3 mageshm  mageshm      4096 Dec 31 14:24 links/
drwxrwxr-x.  2 mageshm  mageshm      4096 Nov 16 15:44 perl5/
lrwxrwxrwx.  1 root     root    22 Feb 20 14:38 cp-test -> /home/2daygeek/cp-test/
lrwxrwxrwx.  1 2daygeek 2daygeek       25 Feb 19 17:29 index.html -> /home/2daygeek/index.html
-rw-r--r--.  1 root     root    104874307 Dec 30  2012 test100.zip
-rw-r--r--.  1 root     root     11536384 Dec 30  2012 test10.zip
-rw-r--r--.  1 root     root           61 Dec 27 19:05 test2-bzip2.txt 

[email protected] [/home/mageshm]# cd /home/2daygeek

[email protected] [/home/2daygeek]# ls -la
total 48
-rw-------.  1 2daygeek 2daygeek  675 Feb 15 15:48 .bash_history
-rw-r--r--.  1 2daygeek 2daygeek   18 May 11  2012 .bash_logout
-rw-r--r--.  1 2daygeek 2daygeek  176 May 11  2012 .bash_profile
-rw-r--r--.  1 2daygeek 2daygeek  124 May 11  2012 .bashrc
drwxr-xr-x.  3 root     root     4096 Jan 24 13:57 cp-test/
-rw-r--r--.  1 mageshm  mageshm    23 Feb 19 17:04 index.html

[email protected] [/home/2daygeek]# cd /home/2daygeek/cp-test

[email protected] [/home/2daygeek/cp-test]# ls -la
total 216340
drwxr-xr-x. 3 root     root       4096 Dec 31 14:24 links/
-rw-r--r--. 1 root     root     104857600 Jan 24 12:06 test100.dat
-rw-r--r--. 1 root     root     104874307 Jan 24 12:06 test100.zip
-rw-r--r--. 1 root     root      11536384 Jan 24 12:06 test10.zip
-rw-r--r--. 1 root     root            61 Dec 27 19:05 test2-bzip2.txt
-rw-r--r--. 1 root     root            61 Dec 31 14:24 test3-bzip2.txt

[email protected] [/home/2daygeek/cp-test]# cd links

[email protected] [/home/2daygeek/cp-test/links]# ls -la
total 16
drwxr-xr-x. 3 root root 4096 Dec 31 14:25 soft-link/
-rw-r--r--. 1 root root   60 Dec 27 19:40 test-bzip2.txt

Now, i’m going to perform the action and see what will happen.

[email protected] [/home/mageshm]# chown -R -H mageshm:mageshm cp-test

[email protected] [/home/mageshm]# ls -la
total 216372
-rw-------.  1 mageshm  mageshm      1663 Feb 15 15:50 .bash_history
-rw-r--r--.  1 mageshm  mageshm        18 May 11  2012 .bash_logout
-rw-r--r--.  1 mageshm  mageshm       176 May 11  2012 .bash_profile
-rw-r--r--.  1 mageshm  mageshm       124 May 11  2012 .bashrc
-rw-r--r--.  1 root     root           26 Dec 27 17:55 liks
drwxr-xr-x.  3 mageshm  mageshm      4096 Dec 31 14:24 links/
drwxrwxr-x.  2 mageshm  mageshm      4096 Nov 16 15:44 perl5/
lrwxrwxrwx.  1 mageshm  mageshm 22 Feb 20 14:38 cp-test -> /home/2daygeek/cp-test/
lrwxrwxrwx.  1 2daygeek 2daygeek       25 Feb 19 17:29 index.html -> /home/2daygeek/index.html
-rw-r--r--.  1 root     root    104874307 Dec 30  2012 test100.zip
-rw-r--r--.  1 root     root     11536384 Dec 30  2012 test10.zip
-rw-r--r--.  1 root     root           61 Dec 27 19:05 test2-bzip2.txt 

[email protected] [/home/mageshm]# cd /home/2daygeek

[email protected] [/home/2daygeek]# ls -la
total 48
-rw-------.  1 2daygeek 2daygeek  675 Feb 15 15:48 .bash_history
-rw-r--r--.  1 2daygeek 2daygeek   18 May 11  2012 .bash_logout
-rw-r--r--.  1 2daygeek 2daygeek  176 May 11  2012 .bash_profile
-rw-r--r--.  1 2daygeek 2daygeek  124 May 11  2012 .bashrc
drwxr-xr-x.  3 mageshm  mageshm 4096 Jan 24 13:57 cp-test/
-rw-r--r--.  1 mageshm  mageshm    23 Feb 19 17:04 index.html

[email protected] [/home/2daygeek]# cd /home/2daygeek/cp-test

[email protected] [/home/2daygeek/cp-test]# ls -la
total 216340
drwxr-xr-x. 3 mageshm     mageshm       4096 Dec 31 14:24 links/
-rw-r--r--. 1 mageshm     mageshm     104857600 Jan 24 12:06 test100.dat
-rw-r--r--. 1 mageshm     mageshm     104874307 Jan 24 12:06 test100.zip
-rw-r--r--. 1 mageshm     mageshm      11536384 Jan 24 12:06 test10.zip
-rw-r--r--. 1 mageshm     mageshm            61 Dec 27 19:05 test2-bzip2.txt
-rw-r--r--. 1 mageshm     mageshm            61 Dec 31 14:24 test3-bzip2.txt

Yes, Now the link folder and original location recursively owner and group permission got changed.

12) How to make changes with verbose option ?

When we use (-v) option with chown command it will shows what is going on while performin the option. See the below output.

[email protected] [/home/mageshm]# chown -v -R root:mageshm links
changed ownership of `links/test-bzip2.txt' to root:mageshm
changed ownership of `links/soft-link/index.html' to root:mageshm
changed ownership of `links/soft-link/test2-bzip2.txt' to root:mageshm
changed ownership of `links/soft-link/test-soft-link-folder/test1-bzip2.txt' to root:mageshm
changed ownership of `links/soft-link/test-soft-link-folder' to root:mageshm
changed ownership of `links/soft-link/index.php' to root:mageshm
changed ownership of `links/soft-link' to root:mageshm
changed ownership of `links' to root:mageshm

The above output clearly shows, the owner permission got changed from mageshm to root.

Magesh Maruthamuthu

Love to play with all Linux distribution

You may also like...