HostOnNet Blog

How To Use chown Command

Looking for Linux Server Admin or WordPress Expert? We can help.

Linux Kernel

chown command changes the user and/or group ownership of for given file. The syntax is:

chown owner-user file
chown owner-user:owner-group file
chown owner-user:owner-group directory
chown options owner-user:owner-group file

Here i list permissions of file access.log

# ls -l access.log

Sample outputs:

root@cloud1:/# ls -l access.log
-rw-r--r-- 1 root root 1 Jun  5 05:13 access.log
root@cloud1:/#

In this next example, the owner is set to kiran followed by a colon and a group onwership is also set to kiran group, run:

# chown kiran:kiran  access.log
# ls -l  access.log

Sample outputs:

root@cloud1:/# ls -l access.log
-rw-r--r-- 1 kiran kiran 1 Jun  5 05:13 access.log
root@cloud1:/#

Likewise, but also change its group to “kiran”, enter:

# chown root:kiran  access.log

Change the owner of /Template and subfiles to “root”, run:

# chown -R  root /Template

-R Recursively change ownership of directories and their sub folders.

Here i am going to change user and group premission to “filmrevi”, run

chown -R filmrevi:filmrevi /home/filmrevi/public_html/

About Annie

I've been working in Technical Section for over 10 years in a wide range of tech jobs from Tech Support to Software Testing. I started writing blog for my future reference and useful for all.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.