Skip to main content
117 votes

What is the main difference between chmod and chown?

In simple term chown is used to change the ownership of a file while chmod is for changing the file mode bits. chown defines who owns the file. chmod defines who can do what. When you make someone ...
Ravexina's user avatar
  • 56.2k
74 votes
Accepted

What is the main difference between chmod and chown?

Let's create a file touch rainbow Let's have a look at the file's metadata $ ls -l rainbow -rw-rw-r-- 1 zanna zanna 0 May 24 10:09 rainbow The first part of the information is the file type (- at ...
Zanna's user avatar
  • 71.2k
45 votes

Inadvertently nuked my disk permission structure - why?

The shell glob .* matches .. (the parent directory) in this case unfortunately that's /: steeldriver@t400s:/opt$ ls .* .: ..: bin boot cdrom dev etc home initrd.img initrd.img.old lib lib32 ...
steeldriver's user avatar
33 votes
Accepted

chown: invalid option -- 'i' Try 'chown --help' for more information

As the glob (pathname) expansion is done first by the shell before the chown runs, the glob pattern * is expanded to all files in the current directory first and chown is getting those as its options ...
heemayl's user avatar
  • 92.6k
30 votes
Accepted

Is there documentation for chown that is easier to understand?

Actually there is such documentation. Open a command line terminal - CtrlAltT and enter: info chown you will find this document uses less technical terms and phrasing, and explains the command in a ...
jordy's user avatar
  • 1,700
29 votes

Is there documentation for chown that is easier to understand?

I suggest installing tldr project: $ tldr chown # chown ...
Nykakin's user avatar
  • 3,784
25 votes
Accepted

Inadvertently nuked my disk permission structure - why?

This happened because you used: sudo chown -R root:www-data .* when you should have used this instead: sudo chown -R root:www-data ./* First, -R is recursive for all directories under the target ...
mchid's user avatar
  • 43.8k
22 votes

What is the main difference between chmod and chown?

When considering the permissions of a file (or directory, or whatever), there are two factors: who owns the file - the user and group, and what they can do with it - read, write, execute or a ...
muru's user avatar
  • 202k
21 votes

change ownership of all files from root to user

Just go to the directory you want to change: cd /opt/lampp/htdocs and change the permission using the chown command: sudo chown userName -R codeigniter Where userName is the username and ...
Saad Mirza's user avatar
18 votes
Accepted

chown $www-data results in invalid option -- d

$www is an empty variable, so chown sees the following: sudo chown -R -data:-data -data or rather -d is then interpreted as option. it should be: sudo chown -R www-data:www-data /path/to/public_html ...
pLumo's user avatar
  • 27.2k
17 votes

Set myself as owner of /etc with chown command now getting all kinds of errors

Since some of the files in /etc might not be owned by root, if you want to avoid reinstalling, you can do the following: Boot into a live system and mount the partition containing the /etc directory. ...
terdon's user avatar
  • 102k
15 votes
Accepted

How to set permission "-rw-rw-r--" to file?

Either chmod a-x,g+w file or chmod ug=rw,o=r file or using octal representation chmod 664 file
steeldriver's user avatar
14 votes

Not able to access Internet after running sudo chown -R $USER$USER /usr/lib/

Actually, no need to reinstall. This situation is quite reparable. I just ran the same command on my system and fixed it in about 10 minutes. You will need to either boot in recovery mode, or use a ...
Zanna's user avatar
  • 71.2k
14 votes
Accepted

Is `chown user:user lost+found` harmful?

Good advice comes with a rationale so that you can tell when it becomes bad advice. The purpose of lost+found being owned by root is so that no matter whose file it was that was lost it's not ...
Joshua's user avatar
  • 719
12 votes
Accepted

chown username:username .Xauthority

The command is sudo chown roey:roey .Xauthority 1st roey is the user, 2nd is the group roey
Rinzwind's user avatar
  • 304k
10 votes

Changed permissions of / to user

It worked from me, hope it helps someone. If this doesn't work reinstall is always an other option. On booting time: Select Advanced Options for Ubuntu. Switch to ubuntu recovery mode. Select root ...
Mukesh Joshi's user avatar
10 votes

/usr/bin/sudo must be owned by uid 0 and have the setuid bit set

Had the same issue on my droplet on digital ocean. sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set. Below are command that ive execute and reboot after. chown -R root:root /...
Marvee Lou Manriquez Ventures's user avatar
10 votes

What is the main difference between chmod and chown?

A few points/tips to add to the previous excellent answers: You must have execute permission on a directory (and all those above it) to access it Use the -R option to apply the changes recursively to ...
james-geldart's user avatar
10 votes
Accepted

User permission denied to follow Softlink in root's home

As mentioned in the comments, the /root is missing the execute permission. If the upper folders do not allow the execution, you cannot look inside the sub-folders (even if you have permissions for ...
Simon Sudler's user avatar
  • 4,021
9 votes
Accepted

I set /usr/bin, /usr/lib, and /usr/share to be owned by my regular user and now I am getting interesting errors

Okay, we need to clean up the mess made of your system first. You'll need to boot into recovery mode first, because you need root for this. Fix /usr/bin First off, we need to fix your binaries. Run ...
Kaz Wolfe's user avatar
  • 34.3k
9 votes

chown username:username .Xauthority

If you don't know what username/group you shoud use, I suggest using something like this: sudo chown $USER:`id -gn` .Xauthority $USER will be expanded into your current username. id -gn will returns ...
Ravexina's user avatar
  • 56.2k
9 votes

What is the main difference between chmod and chown?

Very good answers already, but I would like to make a contribution where the permissions is very easy to understand chmod u=r+w,o=r-w,g=-r-w test.php u = user o = other g = group This way you can ...
Adam's user avatar
  • 515
9 votes
Accepted

Defaulting new child files and folders to the parent folder ownership

Using the setfacl tool you can set this with: sudo setfacl -R -d -m o::rwx /opt/lampp/htdocs sudo setfacl -R -m o::rwx /opt/lampp/htdocs The first line sets this to default, while the second just ...
George Udosen's user avatar
8 votes
Accepted

Not able to access Internet after running sudo chown -R $USER$USER /usr/lib/

Any sort of chown operation on system directories is very dangerous. The easiest way to solve this problem would to be just to reinstall your operating system entirely. If you're lucky (and a bit ...
Kaz Wolfe's user avatar
  • 34.3k
8 votes

chown subfolders with current folder's owner and group

You don't actually need to parse the output to remove the whitespace - you added that in your command! You can just format it as you like (with chown's colon syntax) in the first place: $ stat -c "%U:...
Zanna's user avatar
  • 71.2k
8 votes
Accepted

Cannot modify files installed by `snap`

Snap partitions use SquashFS, which is basically a compressed, read-only disk image format that is usually used to create live CDs/DVDs. SquashFS was simply not designed to be read-write. To edit ...
xiota's user avatar
  • 4,959
8 votes
Accepted

Fix setuid and setgid bits in /usr?

I think you were lucky because you just removed the "writable" bit for groups. This won't affect the SETGID or SETUID bits. If they were set before, they are still set. The command chmod -R 777 /usr ...
PerlDuck's user avatar
  • 13.5k
7 votes

chown: invalid option -- 'i' Try 'chown --help' for more information

The issue was a file named -index.php in the folder, so chown interpreted it as a command line option. The solution was using the double-hyphens chown -R myuser:mygroup -- *
Marco Marsala's user avatar
7 votes

Is there documentation for chown that is easier to understand?

Not supposed to post link only answers (for which I apologise) but I think this link might be what you are looking for as it explains things in simple detail with examples.
graham's user avatar
  • 11.5k
7 votes
Accepted

Use chown -R while excluding one or two files

Set bash’s extglob option with shopt -s extglob and use it like that to exclude these files: sudo chown -R www-data:www-data !(file1.php) sudo chown -R ubuntu:ubuntu !(file2.txt|file3.php) This ...
dessert's user avatar
  • 40.4k

Only top scored, non community-wiki answers of a minimum length are eligible