news
Serverspace has added a new Rocky Linux OS
WB
May 12, 2020
Updated May 30, 2023

Managing users on Ubuntu and Debian

Debian Ubuntu

The instructions describe creating, deleting, and modifying users of the Ubuntu or Debian operating system.

Initial Debian System Requirements

Many of the commands in this guide require superuser privileges. If the following error appears when using the sudo command:

bash: sudo: command not found

You need to activate superuser mode, install the sudo command, and add your user to the sudo group:

su -
apt-get install sudo -y
usermod -aG sudo yourusername

How to add a new user?

Ubuntu and Debian have two command-line tools that you can use to create a new user account: useradd and adduser.

useradd is a low-level utility for adding new users, and adduser is a friendly interactive interface for useradd written in Perl.

To create a new operating system user account named username using the adduser command, run the following command:

sudo adduser username

As a result, a dialogue appears in which you must enter the password and additional information:

Adding user `username' ...
Adding new group `username’ (1000) …

Adding new user `username’ (1000) with group `username’ …

Creating home directory `/home/username’ …

Copying files from `/etc/skel’ …

Enter new UNIX password:

Retype new UNIX password:

passwd: password updated successfully

Changing the user information for username

Enter the new value, or press ENTER for the default

Full Name []: Name

Room Number []: 100

Work Phone []: 123-45-45

Home Phone []:

Other []:

Is the information correct? [Y/n] Y

The command creates the home directory for the new user and copies the files from the /etc/skel directory there.

By default, sudo members are granted sudo access.
If you want the newly created user to have administrator rights, add him to the sudo group:

sudo usermod -aG sudo username

How to delete a user?

There are two command-line tools that you can use to delete a user account: userdel and deluser. We recommend using the deluser command, as it is more friendly than the low-level userdel.

To delete a user without deleting user files and directories, do:

sudo deluser username

If you need to delete the user's home directory and its contents, use the –remove-home flag:

sudo deluser --remove-home username

As a result, the following message appears:

Looking for files to backup/remove ...

Removing files …

Removing user `username’ …

Warning: group `username’ has no more members.

Done.

How to change the user password?

To change your password, use the passwd command with no additional arguments:

passwd

In the system dialogue, you will need to enter the old password and specify a new one:

Changing password for username.

(current) UNIX password:

Enter new UNIX password:

Retype new UNIX password:

passwd: password updated successfully

To change the password for another user, you must have administrator rights and username:

sudo password username

Vote:
5 out of 5
Аverage rating : 5
Rated by: 4
1101 CT Amsterdam The Netherlands, Herikerbergweg 292
+31 20 262-58-98
700 300
ITGLOBAL.COM NL
700 300
We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.