User / Groups
Last updated
Last updated
An operating system is considered as multi-user if it allows multiple people/users to use a computer and not affect each other's files and preferences. Linux based operating systems are multi-user in nature.
Users in Linux has an associated user ID called UID attached to them.
A group is a collection of one or more users.
A group makes it easier to share permissions among a group of users.
Each group has a group ID called GID associated with it.
id
command can be used to find the uid and gid associated with an user. It also lists down the groups to which the user belongs to.
The uid and gid associated with the root user is 0.
A good way to find out the current user in Linux is to use the whoami command.
"root" user or superuser is the most privileged user with unrestricted access to all the resources on the system. It has UID 0
Important files associated with users/groups
Some of the commands which are used frequently to manage users/groups on Linux are following:
useradd
- Creates a new user
passwd
- Adds or modifies passwords for a user
usermod
- Modifies attributes of a user (like home directory or shell)
One easy way of providing root access to users is to add them to a group which has permissions to run all the commands. "wheel" is a group in redhat Linux with such privileges. usermod -a -G wheel <user>
userdel
- Deletes a user
su
- Switch user
/etc/passwd | Stores the user name, the uid, the gid, the home directory, the login shell etc |
---|---|
groupadd \<group_name> | Creates a new group |
---|---|
/etc/shadow
Stores the password associated with the users. Can only be accessed by super users
/etc/group
Stores information about different groups on the system
groupmod \<group_name>
Modifies attributes of a group
groupdel \<group_name>
Deletes a group
gpasswd \<group_name>
Modifies password for group