If you need to change the ownership permission of file then you can use chown command. Through chown command you can change file’s owner and group information. You can change the file access permission such as write, read and access.
Here are the syntax of chown command :
Now let’s see how to use these commands with example :
For example you have to change the permission of exam.txt file, then first list the permission for the file exam.txt with below command :
The following will be the output:
Now you have to change the file permission from root to admin with following command :
And again list the permission for the file.
The output will be this :
Here are the syntax of chown command :
- chown owner-user file
- chown owner-user: owner-group file
- chown owner-user: owner-group directory
- chown options owner-user: owner-group file
Now let’s see how to use these commands with example :
For example you have to change the permission of exam.txt file, then first list the permission for the file exam.txt with below command :
Code:
# ls -l exam.txt
Code:
-rw-r--r-- 1 root root 0 Aug 17 05:48 exam.txt
Code:
# chown root exam.txt
Code:
# ls -l exam.txt
Code:
-rw-r--r-- 1 admin root 0 Aug 17 05:48 exam.txt