User Management – Creating & Removing User – Set/Change Password

In this chapter, you will learn

  1. How to create user in Linux?
  2. How to set/change user's password?
  3. How to switch user account?
  4. How to delete a user?

To effectively manage a Linux VPS server, it is crucial to acquire skills in handling user accounts. This includes tasks such as adding a new user, deleting existing users, changing passwords, adding users to the sudo group, and understanding how to switch between user accounts.

A set of commands simplifies the organization of users in this context.

sudo command:

The sudo command grants superuser privileges to execute commands. It is employed for carrying out administrative tasks, including software installation or removal, system configuration, and more, eliminating the need to log in as the root user.

To initiate a process with the sudo command, you are required to enter the administrative password.

Example:
sudo apt update
$Enter password:

Adding a User:

To add a new user, the adduser command is utilized. This operation necessitates having sudo access for execution.

Example:
sudo adduser "username"

Adding/Changing User's Password:

To create a new password or change an existing password, the passwd command is employed.

Example:
sudo passwd jack
$New password:
$Retype new password:
passwd: password updated successfully

Deleting a User:

deluser commands are used for deleting a user.

Example:
sudo deluser jack
$[sudo] password for prashant:
Removing user 'jack' ... Warning: group 'jack' has no more members. Done.

Show user Information:

The finger command provides detailed information about a user, including the user's login name, real name, terminal, idle time, login time, and other relevant details.

Example:
finger jack
Login: jack Name: Directory: /home/jack Shell: /bin/bash Never logged in. No mail. No Plan.

Switch user account:

To switch user account the su command is used.

Example:
sudo su smith
$Enter password:
smith@easycodelab:/$

Summary:

In this tutorial, you have learned how to create a user, delete a user, change a user's password, switch user accounts, and display detailed user information. Moving forward, the next chapter will guide you on adding a user to the sudo group.