User & Group Management : Commands and Concepts
Linux user in short
Root User: The admin with full control over the system.
Regular Users: Everyday users with limited permissions.
System Users: Special users for running background services.
Commands for User Creation and Management
- Create a User:
Command: sudo adduser username
Example: sudo adduser devops_user
What it does: Creates a new user named "devops_user" and sets up their home directory
- Add User to a Group:
Command: sudo usermod -aG groupname username
Example: sudo usermod -aG devops_team devops_user
What it does: Adds the user "devops_user" to the "devops_team" group.
- Set Password and grant sudo access
command: sudo passwd devops_user or passwd -e devops_user
sudo usermod -aG sudo devops_user
Command to create a group in Linux:
command: sudo groupadd groupname
example sudo groupadd devops_teams
Restricting SSH login for certain users in /etc/ssh/sshd_config
To Perform this operation in Linux you need to first install sshd using command
- After installation is complete you can use command to restrict the specific user for SSH login
/# This command is used to open the sshd_config file using sudo access in vim editor to modify user permission in a SSH
Once you edit the vim editor reach to the end of lines in editor and use command
example: DenyUsers devops_user1.
You can also restrict multiple users by adding their username following space.