UNIX commands — Changing ownership

This article is a brief summary of permissions that can be assigned to files and folders at DreamHost. If necessary, view the SSH article for instructions on how to log in to your server depending on your operating system.

User and Group

Every file in a Unix system is assigned both a user and a group. The following sections detail the ownership of each.

User

Every file in Unix is assigned a user.

This user:

  • is the owner of the file.
  • has permission to change the group and mode of the file.

No one else (but the administrator) is able to make these changes, and only the administrator can change the owner of a file.

The command to change the owner is chown:

[server]$ chown exampleuser file.txt

The user named "exampleuser " now owns "file.txt". This only works if you’re the superuser.

The work-around to change the file owner for non-superusers is to copy the file(s) to a new location where, as the user, you wish to own the files. The files are owned by this user in the new location. It's not much of a work-around, but it's occasionally useful.

More information regarding the chown command can be found here.

Group

Every file in Unix is assigned a group. This is the "group owner" of the file. Unix groups allow you to grant access to a number of users. You can create Unix Groups in your panel on the (Panel > ‘Users’ > ‘Unix Groups’) page.

The command to modify the group is chgrp. You may only modify the group of files you own, and you can only set the group owner to the name of a group of which you are a member:

[server]$ chgrp examplegroup file.txt

The group named " examplegroup" now owns "file.txt".

For more information on:

  • groups, please see Unix Groups.
  • what this command is and how it could be used, please see Chgrp.

See also

Internal links

External links

Did this article answer your questions?

Article last updated .