Add, Remove, and Manage Users on a Cloud Server Running Linux

Table of Contents

Introduction

Learn how to add and remove users on a 1&1 Cloud Server running Linux. This article also covers how to perform common user management tasks such as changing a user's password and granting a user sudo permissions.

Requirements

  • A 1&1 Cloud Server running Linux (any distribution)
  • SSH connection to the server.

For more information on connecting to a Linux server using SSH, see our article How to Log In To A Cloud Server Using PuTTY For Windows.

Add a User

The command to add a user is:

adduser [username]

For example, to add the user jdoe the command is:

adduser jdoe

On Ubuntu systems, you will be prompted to add the user's password, and fill out several other items of information.

On CentOS systems, you will need to set the user's password with the command:

passwd [username]

For example, to set the password for jdoe the command is:

passwd jdoe

This command will add the user to the system, and will also create a home directory (/home/username) for the user's use.

Remove a User

The command to remove a user is:

userdel [username]

For example, to remove the user jdoe the command is:

userdel jdoe

Note: This will not remove the user's home directory and files. To remove those files as part of the command, use the -r flag:

userdel -r jdoe

Grant Sudo Permissions to a User

Sudo permissions let a user run commands as if they were logged in as root. Due to the potential security issue, be sure to only grant sudo permissions to trusted users.

Note: It is considered "best practices" for Linux to set up a sudo user for yourself, to use when you are working on your server. This will decrease the likelihood that you will accidentally damage or destroy your server.

To give a user sudo permissions, the command is:

  • Ubuntu systems: usermod -aG sudo [username]
  • CentOS systems: usermod -aG wheel [username]

Change a User's Password

The command to change a user's password is:

passwd [username]

For example, to change the password for the jdoe account the command is:

passwd jdoe

On CentOS systems, you will be prompted to enter the new password twice. On Ubuntu systems, you will be prompted to enter the user's existing password, followed by the new password twice.

Comments

Tags: Linux