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 ...
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 ...
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 ...
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 ...
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 ...
29
votes
Is there documentation for chown that is easier to understand?
I suggest installing tldr project:
$ tldr chown
# chown ...
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 ...
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 ...
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 ...
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
...
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. ...
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
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 ...
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 ...
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
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 ...
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 /...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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:...
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 ...
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 ...
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 -- *
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.
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
chown × 299permissions × 168
chmod × 80
command-line × 33
sudo × 33
root × 32
ownership × 29
mount × 25
14.04 × 16
server × 13
directory × 11
users × 11
12.04 × 10
20.04 × 8
apache2 × 8
login × 7
18.04 × 6
partitioning × 6
files × 6
16.04 × 5
bash × 5
ssh × 5
filesystem × 5
read-only × 5
13.04 × 4