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

  1. 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

  1. 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.

    1. 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

💡
command: sudo apt install openssh-client
  • After installation is complete you can use command to restrict the specific user for SSH login
💡
command: sudo vim /etc/ssh/sshd_config

/# 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

💡
command: DenyUsers Username

example: DenyUsers devops_user1.

You can also restrict multiple users by adding their username following space.