User Management and sudo
Beginner5 min
Create, manage, and configure user accounts with proper sudo access and security settings.
Prerequisites
- -Linux shell access
- -Root or sudo access
Steps
1
List all users with login shells
View system users that can actually log in.
$ grep -v '/nologin\|/false' /etc/passwd | cut -d: -f1,6,7
2
Create a new user with home directory
Add a new user account with a home directory and default shell.
$ sudo useradd -m -s /bin/bash -c 'Deploy User' deploy
Use -G to add the user to supplementary groups: -G docker,sudo
3
Grant sudo access to a user
Add a user to the sudo group for administrative access.
$ sudo usermod -aG sudo deploy
Always use -aG (append to group). Using -G without -a replaces all groups.
4
Check sudo permissions for a user
Verify what sudo commands a user is allowed to run.
$ sudo -l -U deploy
Full Script
FAQ
Discussion
Loading comments...