UNIX-programming-userident
#UserID
The user ID from our entry in the password file is a numeric value that identifies us to the system.
This user id is assigned by system admin when our login name is assigned, and we cant change it.
If the ID of user is 0 we call this user as root or superuser.
The entry in the password file normally has a login name of root, and we refer to the special privileges, most of this user as superuser priviliges.
If a file has a superuser privileges most file permission checks are bypassed.
FunFact : Client versions of Mac OS X ship with the superuser account disabled and server versions ship with the account already enabled.
#GroupID
Our entry in the password file also specifies our numeric group ID. Groups are normally used to collect users together into projects or departments. Tjis allows to share smth like files or some resources yk. In UNIX systems there is also a group file that maps group names into numeric group IDs. The group file is usually /etc/group.
Early UNIX systems used 16-bit integers to represent user and group IDs. Contemporry UNIX systems use 32-bit integesr.
We call functions getuid and getgid to return the user ID and the group ID. Running the program yields.
its like:
// using getgid and getuid
#include <apue.h>
int main(void){
printf("User id : %d\nGroup id: %d\n", getuid(),getgid());
exit(0);
}