Edited 3 weeks ago by ExtremeHow Editorial Team
UsersGroupsUbuntuLinuxAdministrationOperating SystemsSystemCommand LinePermissionsManagement
This content is available in 7 different language
Managing users and groups in Ubuntu is an essential skill for both administrators and users. It allows effective management of system access and permissions. In Linux systems, including Ubuntu, everything revolves around users and groups. This comprehensive guide will introduce you to various ways to manage users and groups on Ubuntu systems.
Before diving into user and group management, it is important to understand what users and groups are and why they are important.
A user in Ubuntu is an entity that can access system resources and has permissions defined by the system administrator. Each user has a unique user ID (UID), a username, and user-specific settings that are stored in their home directory.
A group in Ubuntu is a collection of users. Groups are used to simplify the management of permissions. Instead of setting individual permissions for each user, an administrator can set them for a group and assign them to users.
To create a new user in Ubuntu, you can use adduser
command. This is a user-friendly command that will ask for information such as the user's full name, room number, and other optional details.
Open the terminal and type the following command:
sudo adduser newusername
Replace newusername
with the name of the new user you want to create. You will be asked to set a password and provide additional information.
To delete a user, use the deluser
command. Be careful when using this command as it will delete the user's login without confirmation.
To delete a user, use the following command:
sudo deluser username
If you want to delete the user's home directory and mail spool, use:
sudo deluser --remove-home username
Modifying user information includes changing the user's password and other details. Here are the commands you need:
passwd
command to change a user's password.
sudo passwd username
chfn
command.
sudo chfn username
To create a new group in Ubuntu use addgroup
command:
sudo addgroup newgroupname
Replace newgroupname
with the desired group name.
Once groups are created, you can add users to them using usermod
command with the -aG
option. This adds the user to the group without removing them from other groups.
sudo usermod -aG groupname username
Replace groupname
with the name of the group and username
with the user you want to add.
If you need to remove a user from a group, use the gpasswd
command:
sudo gpasswd -d username groupname
This will remove the specified user from the specified group.
User and group information on a Linux system is stored in specific files. Understanding these files is important to effectively manage users and groups.
Understanding permissions and ownership is important in user and group management. In Ubuntu, every file and directory has three types of permissions:
Permissions are assigned to three different classes of users:
To change file permissions, use the chmod
command. This command modifies the permission settings of a file or directory. Its syntax is:
chmod permissions filename
To change file ownership, use the chown
command. The syntax of chown
is:
sudo chown user:group filename
System users are special types of users that are used to run services and applications. They often do not have login rights. To create a system user, use useradd
command with options to disable the home directory and login shell:
sudo useradd -r -s /usr/sbin/nologin sysusername
Groups can also be given specific permissions using the chmod
command. For example, to give a group write permissions, you could use:
sudo chmod g+w filename
Default user settings are stored in /etc/default/useradd
and /etc/login.defs
files. Administrators can modify these files to change the default UID, GID, and other user account settings.
There are many utilities available for managing users and groups in Ubuntu. Some of these widely used utilities are as follows:
id username
groups username
finger username
Managing users and groups in Ubuntu may initially seem complicated, but with familiarity, it becomes second nature. Understanding how to create, modify, and delete users and groups, modify permissions and ownerships, and effectively manage the system allows for robust and secure system administration. By mastering the commands and concepts outlined in this guide, you will be equipped to efficiently handle user and group management on Ubuntu.
Remember that careful management and planning is vital to ensure the safety and efficiency of the systems you administer. Always double-check your orders and make sure the operation is necessary before executing them.
Happy managing!
If you find anything wrong with the article content, you can