5

UNIX commands — Changing ownership – DreamHost Knowledge Base

 3 years ago
source link: https://help.dreamhost.com/hc/en-us/articles/214750918-UNIX-commands-Changing-ownership
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

UNIX commands — Changing ownership

Overview

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.

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. 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, please see Chgrp.

See also

Did this article answer your questions?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK