Questions tagged [chown]

chown is an abbreviation of "change owner". This command is used to change the owner and group owner of a file or directory

In Linux file permissions are set in three categories:

permissions

Since the owner, group and others may have different permissions, it is sometimes necessary to change the owner and group to control file access. This is done with the chown command, which can set user and group ownership at the same time:

chown pixie file1          # make pixie owner of file1
chown pixie: file1         # make pixie owner and pixie group of file1
chown :sprites file1       # make sprites group of file1
chown pixie:sprites file1  # make pixie owner and sprites group of file1

chown also has a -R recursive flag, but to make future created files in a directory inherit the same group ownership rather than the creating user's group, the setgid bit should be added to the directory with chmod.

301 questions
133
votes
12 answers

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

I have run following command accidentally sudo chown [username] -hR / Now sudo su getting error: sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set How to Solve This?
Pandya
  • 37,289
89
votes
1 answer

Changing Ownership: "Operation not permitted" - even as root!

I am trying to help a user solve an issue with a bootable USB drive, but there seems to be a file whose ownership cannot be edited. I thought it would have been possible with: sudo chown user:user ldlinux.sys When that is executed, however,…
David
  • 3,487
70
votes
6 answers

What is the main difference between chmod and chown?

In some examples, I saw that some used chown instead of chmod. I do not know where to use chmod and chown. Please explain to me the difference between them, when and why I should use either.
40
votes
1 answer

chown recursively changed permissions

I ran the chown command in a directory: chown -R user:user {.,}* The {.,}* is used with mv and cp to include both hidden and listed files. Now this command went through and changed those two files in my directory, but I had to break it to stop since…
nicoX
  • 1,160
39
votes
6 answers

Sudo doesn't work: "/etc/sudoers is owned by uid 1000, should be 0"

When I type a sudo command into the terminal it shows the following error: sudo: /etc/sudoers is owned by uid 1000, should be 0 sudo: no valid sudoers sources found, quitting sudo: unable to initialize policy plugin How do I fix this?
37
votes
5 answers

Is it possible to change ownership of a file without root access?

If a User A owns file.txt, can User A change the ownership of the file to User B without root access? When i run a chown B file.txt as user A, I get a Operation not permitted error. It seems to me that since User A owns the file, they ought to be…
Daniel
  • 513
32
votes
3 answers

chown - Difference between user and user:user

What is the difference between: sudo chown $USER:$USER and sudo chown $USER Why is it 2 times? Is the one user wrong? When I look at permissions with namei -l, I often see things like root root or proxy proxy. Why does the owner have to be…
John K
  • 455
31
votes
2 answers

Recursive chown starting with the directory above current directory

I couldn't log in to my "admin" account and Alt+Ctrl+F1 showed all my files were owned by my "standard" user. Odd. So I carefully changed to /home/admin and did a sudo chown -R admin:admin * (and .* too). Great. Then I couldn't log in as my…
DavidP
  • 313
26
votes
1 answer

Permissions and ownership of /var/www

I am using Ubuntu 13.04 VPS and have installed LAMP (apache2). Now I have uploaded my web files (WordPress) in /var/www. But I dont have permissions to write in files. When I run WordPress install, it says that it could not write on wp-config php…
26
votes
4 answers

Is there documentation for chown that is easier to understand?

I am relatively knew to Ubuntu and I want to learn about the chown command, so I tried to read the man chown but I find it very difficult to understand. Is there a document for this that is simpler and easier to understand?
23
votes
3 answers

Inadvertently nuked my disk permission structure - why?

I was trying to chown within /opt and for some reason chown jumped up to the parent and chowned everything. Can anyone suggest why/how this might happen, and how to avoid doing it in future? It's a bit concerning that running a command in a given…
Duke Dougal
  • 1,581
19
votes
3 answers

change ownership of all files from root to user

i'm new to Ubuntu and was wondering if there is a way to remove the ownership of all files and scripts from root to user even if i have to re-install Ubuntu? i do know about the command 'chown -v username foldername', although it doesn't work on all…
rgr
  • 2,089
18
votes
2 answers

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

I have a strange issue with the following command: # chown -R myuser:mygroup * chown: invalid option -- 'i' Try 'chown --help' for more information. the command is not aliases # type chown chown is hashed (/bin/chown) Where I can look further?
Marco Marsala
  • 353
  • 1
  • 2
  • 8
17
votes
4 answers

Is it safe to chown `/usr/local`?

I know what /usr/local is for - installing software for the local machine. By default, root owns the directory. This means that to install there, you need to use sudo. For a single-user or developer machine, this seems like unnecessary extra use of…
PR3x
  • 183
16
votes
4 answers

Make owner of newly create files AND folders www-data instead of superuser/admin

I've been struggling with permissions so far, and posted another question but identified what the problem was, without any way to fix it yet. My setup: Ubuntu Desktop with LAMP stack 5 "users" I created users I've create in the ubuntu server using…
1
2 3
20 21