chown
What is chown?
The chown
command-line tool allows you to change the user and/or group ownership of a given file, directory, or symbolic link.
In Linux, all files are associated with an owner and a group and assigned with permission access rights for the file owner, the group members, and others. For more information about this, checkout the following link
How to use chown
USER
is the user name or the user ID (UID) of the new owner. GROUP
is the name of the new group or the group ID (GID). FILE(s)
is the name of one or more files, directories or links. Numeric IDs should be prefixed with the +
symbol.
USER
- If only the user is specified, the specified user will become the owner of the given files, the group ownership is not changed.USER:
- When the username is followed by a colon:
, and the group name is not given, the user will become the owner of the files, and the files group ownership is changed to user’s login group.USER:GROUP
- If both the user and the group are specified (with no space betwen them), the user ownership of the files is changed to the given user and the group ownership is changed to the given group.:GROUP
- If the User is omitted and the group is prefixed with a colon:
, only the group ownership of the files is changed to the given group.:
If only a colon:
is given, without specifying the user and the group, no change is made.
By default, on success, chown
doesn’t produce any output and returns zero.
Use the ls -l
command to find out who owns a file or what group the file belongs to:
Last updated
Was this helpful?