User management is a critical aspect of Linux administration. Each user in a Linux system has specific permissions, roles, and files associated with their account. Understanding how to manage users efficiently ensures system security and organized access control.
In Linux, users are divided into three main categories:
All user information is stored in the /etc/passwd
file, while passwords are stored securely in /etc/shadow
.
To create a new user, use the useradd
or adduser
command:
sudo useradd username
After creating the user, set a password:
sudo passwd username
This ensures the account is ready for login.
If you need to change user details such as the home directory or shell, use:
sudo usermod -d /home/newpath username
or
sudo usermod -s /bin/bash username
To lock or unlock an account:
sudo passwd -l username
sudo passwd -u username
When a user account is no longer needed, remove it safely with:
sudo userdel username
To delete the user’s home directory and mail files as well:
sudo userdel -r username
To list all users:
cat /etc/passwd | cut -d: -f1
For detailed information about a specific user:
id username
Efficient user management in Linux ensures security and proper access control. By mastering commands like useradd
, usermod
, and userdel
, administrators can create a secure and well-organized environment.
Linux offers powerful command-line tools for system administrators to view and manage user accounts. Knowing…
Managing users is an essential part of Linux system administration. Knowing how to list all…
Nmap (Network Mapper) is a free tool that helps you find devices on a network,…
Introduction to the Model Context Protocol (MCP) The Model Context Protocol (MCP) is an open…
While file extensions in Linux are optional and often misleading, the file command helps decode what a…
The touch command is one of the quickest ways to create new empty files or update timestamps…