Linux Chown command

How to use Linux Chown command


Today we will see in this post that how to change ownership and group permission on file and directory in Linux through command line. It's very easy to create, change, modify and delete ownership and group permission. Please read full articles if you face any problem regarding this articles so please leave comments or drop email within 24 hours you will get reply by our team.

Please leave comment if this article good and share it also.



Chown:

CHOWN stands for CHange file OWNer and Group. The chown command is most commonly used by Unix/Linux system administrators. chown is a command to change the ownership of a file/folder or even multiple files/folders at a time to a specified user/group. who need to fix a permissions problem with a file or directory, or many files and many directories.



To Change the owner of a file;

[root@localhost ONS]# ls -l testfile
-rw-r--r-- 1 root root 0 2017-05-22 20:03 testfile

[root@localhost ONS]# chown owner testfile

[root@localhost ONS]# ls -l testfile
-rw-r--r-- 1 owner root 0 2017-05-22 20:03 testfile

To Change the group of a file:

[root@localhost ONS]# ls -l testfile
-rw-r--r-- 1 root root 0 2017-05-22 20:03 testfile

[root@localhost ONS]# chown :group testfile

[root@localhost ONS]# ls -l testfile
-rw-r--r-- 1 root group 0 2017-05-22 20:03 testfile

To Change both owner and the group:

[root@localhost ONS]# ls -l testfile
-rw-r--r-- 1 root root 0 2017-05-22 20:03 testfile

[root@localhost ONS]# chown owner:group testfile

[root@localhost ONS]# ls -l testfile
-rw-r--r-- 1 owner group 0 2017-05-22 20:03 testfile


To Change the owner/group of the files by traveling the directories recursively:

Recursively grant ownership of the directory /files/work, and all files and subdirectories

[root@localhost ONS]# ls -l linux/linux1
-rw-r--r-- 1 root root 0 2017-05-22 21:52 linux/linux1

[root@localhost ONS]# chown -R owner:group linux/

[root@localhost ONS]# ls -l linux/redhat/test
-rw-r--r-- 1 owner group 0 2017-05-22 21:52 linux/redhat/test


Hope this will help to all of you and resolved your all query if you have any query or question so you may ask to send email on our email account (onlinenetworkssolution@gmail.com) or leave comment on page.


Share:

0 comments

Please leave your comments...... Thanks