Difference between Chown and Chmod

mattnz

Member
Registered
Joined
Jul 16, 2016
Messages
48
Points
8
What is the difference between the chown and chmod commands especially with reference to re-setting file permissions. Which is better to use?
Sometimes I get confused on using chown and chmod and I need an explanation to make me clear about these commands.
 

VirtuBox

Well-known member
Registered
Joined
May 3, 2016
Messages
1,622
Points
83
The main difference is chmod change the permissions of the files and chown change the owner.

chmod is use to change permission of a file or a folder, and it change the ability of the different group or users to read, write or execute the file.
-> To secure your WordPress install all folder should be in 755 and all files in 644.

chown change only the owner, not the permission. It will only transfer the owner permission to another user. But it will not change the ability of a group to use or not this file.
-> you have upload a file as root, and you change the owner to www-data to let's apache or nginx use it.
 

Luxin Host

Well-known member
Registered
Joined
Jun 26, 2016
Messages
543
Points
43
@VirtuBox did a great explanation, I will add to that with an example. take a look below and see an example of what each does:

Use the code below to change the permissions of the file/folder:
Code:
chmod XXX file
Incase you want to change the ownership of a file use the code below: (useful for multi user use)
Code:
chown username:username file
 

nairprasad7

New member
Registered
Joined
Aug 2, 2016
Messages
14
Points
3
The chmod and chown commands are used to control access to files in UNIX and Linux systems.

The chmod command stands for "change mode", and allows changing permissions of files and folders, also known as "modes" in UNIX. The chown command stands for "change owner", and allows changing the owner of a given file or folder, which can be a user and a group. That's the difference between them in a nutshell.
 

nitaish

Member
Registered
Joined
Dec 27, 2016
Messages
39
Points
0
The command chown is used to change ownership of files/folders and the command chmod is used to change permissions of files/folders. A very useful website is permissions-calculator.org to understand what octal to use in case of changing permissions using chmod.
 
Latest Threads
Replies
1
Views
24
Replies
0
Views
179
Replies
1
Views
39
Replies
2
Views
81
Recommended Threads
Replies
36
Views
19,733
Replies
10
Views
3,135

Latest postsNew threads

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top