0

I'm curious to know what the chown command does. In the manual page it says the chown command changes the file owner and group. I know the owner is the one that created the file(unless changed), but what are groups and when do we create a group?

Bukks
  • 101

1 Answers1

0

This command is used to change the ownership of a file or a folder. We can change the ownership of a single folder or multiple folders included in it.

Mostly there will be two users.

  1. root
  2. customuser

NB: 'customuser' is your username. It will be vary with each system. You can check your username with typing whoami in terminal.

sometimes you can't copy/move/delete a file from certain folders. Because of the ownership problem. You can check the ownership of a folder by ll command (ll foldername).

To use chown, you should aware of what you gonna do. Else your system got busted. So aware of it.

Here is an example: I have a folder in home folder named 'test'. And its owner is 'root'. I have many files/folders in 'test' folder. I need to change the ownership of entire 'test' folder and its sub folders to 'customuser'. I can change the permission by typing:

sudo chown -R customuser:customuser /home/customuser/test

-R means recursive. first customuser used for owner. second customuser used for group.

muru
  • 197,895
  • 55
  • 485
  • 740
  • 1
    WARNING Many disaster scenarios begin with sudo chown -R (or sudo chmod -R). Please do not use sudo chown -R in an answer to a fairly new user. – waltinator Jun 05 '17 at 16:27