Difference between revisions of "Linux: File Ownership"
Jump to navigation
Jump to search
(Created page with "== Users and Groups == Linux makes use a users and groups. When looking at /etc/passwd you can see the user and group ids of all users on the system. <syntaxhighlight> redhat:x:30582:...") |
|||
| (One intermediate revision by the same user not shown) | |||
| Line 9: | Line 9: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| − | Each user is assigned a user Id and group id. The default group in Redhat is a group | + | Each user is assigned a user Id and group id. The default group in Redhat is a group with the same name as the user. |
| + | |||
| + | The groups are defined in /etc/group. A user may be a member of more than one group. | ||
| + | |||
| + | <syntaxhighlight> | ||
| + | redhat:x:30583: | ||
| + | manali:x:30584: | ||
| + | armtest:x:30585: | ||
| + | </syntaxhighlight> | ||
==File Ownership == | ==File Ownership == | ||
| − | Files have a User and Group Owners. The test file is owned by user michael and group | + | Files have a User and Group Owners. The test file is owned by user michael and group test. In this case the file cna be read and edited by michael and all members of the root group. |
<syntaxhighlight> | <syntaxhighlight> | ||
| Line 19: | Line 27: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| + | Directories can also be assigned to a group. This allows the files stored in it, to be shared by a group. | ||
== Change the User Owner == | == Change the User Owner == | ||
Latest revision as of 19:44, 15 August 2013
Users and Groups
Linux makes use a users and groups. When looking at /etc/passwd you can see the user and group ids of all users on the system.
redhat:x:30582:30583::/home/redhat:/bin/bash
manali:x:30583:30584::/home/manali:/bin/bash
armtest:x:30584:30585::/home/armtest:/bin/bashEach user is assigned a user Id and group id. The default group in Redhat is a group with the same name as the user.
The groups are defined in /etc/group. A user may be a member of more than one group.
redhat:x:30583:
manali:x:30584:
armtest:x:30585:File Ownership
Files have a User and Group Owners. The test file is owned by user michael and group test. In this case the file cna be read and edited by michael and all members of the root group.
-rw-rw-r-- 1 michael root 0 Aug 15 20:41 testDirectories can also be assigned to a group. This allows the files stored in it, to be shared by a group.
Change the User Owner
chown <newuser> <file>Change the Group Owner
chgrp <new_group> <file>