cancel
Showing results for 
Search instead for 
Did you mean: 

UID & GID

SOLVED
Go to solution
Ragni Singh
Super Advisor

UID & GID

Can someone pelase explain to me the concept of UID and GID and how it works. Also which files control the GID and UID mapping. Your help will be greatly appreciated.
7 REPLIES
harry d brown jr
Honored Contributor
Solution

Re: UID & GID

Userid (UID) is a number assigned to a user, which you will find in the /etc/passwd file.

Groupid (GID) is a number assigned to a user, and usually a group of users will share this number, which can be found in /etc/group. In /etc/passwd, you actually have both a UID and a GID. Now a user can belong to many groups.

It allows the system to have something to base security rules on.


live free or die

harry
Live Free or Die
harry d brown jr
Honored Contributor

Re: UID & GID

In /etc/passwd you will find a structure like this:


username : passwd : UID : GID : description : home directory : login shell

in /etc/group:

groupname : passwd : group number : usernames separated by commas

Live Free or Die
Roger Baptiste
Honored Contributor

Re: UID & GID

Sanman,

/etc/passwd file contains
the username->uid mappings.
It also contains the Groupid
to which the user belongs.
The Groupid->groupname mapping
is in the /etc/group file.

The userid is assigned by
the system, when a user is
created, as per the serial order. BUT, we have the
choice of assigning a specific
user id , during its creation.
We can also change the userid
of a user at any time. (but
one has to be careful in doing this).

We also have the choice of
assigning the group(s) to
which a user belongs during
creation or at any time.
A user can belong to more than
one group.

Userful commands related to
Userid/groupid is
""id"" , ""usermod""
""useradd"" ""userdel""

If you would like to dive
deeper, look at man inode.
Inode is the system structure
which holds the details of
the file.

HTH
raj

Take it easy.
James Beamish-White
Trusted Contributor

Re: UID & GID

To build on the excellent answers above, note that the permissions on files and directories are based on user, group and other permissions:

-rwxrwxrwx 2 root sys 96 Dec 4 2000 myfile

shows us that it (r)ead, (w)rite and e(x)ecutable for user, group and everyone, while

-rwxr-x--- 2 root sys 96 Dec 4 2000 myfile

shows us that it (r)ead, (w)rite and e(x)ecutable for user, (r)ead and e(x)ecutable group and no permissions for everyone.

Cheers,
James
GARDENOFEDEN> create light
Ragni Singh
Super Advisor

Re: UID & GID

Thanks for the help. Now let me ask you all this. If the write permission is set on others, what would the affect be on the group and owner.
David Lodge
Trusted Contributor

Re: UID & GID

Permissions are used in the order owner, group, other...

eg If I have the file:
-rwx------ dave sys foobar

Only the user dave (or root) can access the file.

If the permissions are:
----rwx--- dave sys foobar

Only the members of the group sys (or root) can access the file.

If the permission are:
-------rwx dave sys foobar

Only users who *aren't* a member of sys or dave can access the file

There are some special cases:
1. root can access everything.
2. As the owner of a file, even if you don't have permissions on the file you can still alter the file.

Directories are a special cases to the above, for each of owner, group, others the rwx means:
r - can read contents of directory
w - can create or delete files within the directory
x - can go into the directory

just to confuse you :-)

dav
Darrell Allen
Honored Contributor

Re: UID & GID

Hi,

I believe you'll find that other permissions really give permissions to everyone. For example, a file with ------rw- (chmod 006) permissions can be written to by anyone regardless of their id or group.

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)