Add or remove a user on the Linux servers of DC3 and DC2 tariffs | INTROSERV
EUR
european

EUR

usa

USD

English En
Ex. VAT Ex. VAT 0%

Add or remove a user on the Linux servers

Info

These instructions cover adding and removing users on a Linux server. The process may differ between RHEL-based and Debian-based distributions, where you may be prompted for a password and additional user information. It is not recommended to work under the root account on a regular basis. Any mistake or account compromise gives full control over the server. Instead, create a dedicated user and grant only the permissions required for their tasks (principle of least privilege). Use sudo to run individual commands with elevated privileges instead of logging in directly as root.

To add a user, for example "introserv", the procedure differs between Debian-based and RHEL-based distributions.

For Debian-based systems (Debian, Ubuntu)

Use the interactive adduser script. It creates the user, sets the password, and prompts for additional information in a single step:

adduser introserv

For RHEL-based systems (RHEL, AlmaLinux, RockyLinux, CentOS)

In RHEL-based distributions, adduser is a symlink to useradd and is not interactive. Running adduser introserv is equivalent to running useradd introserv, and the password must be set separately.

Create a user:

useradd -m introserv

Set a password for the user:

passwd introserv

The useradd command creates a new user with system defaults specified in the /etc/default/useradd file.

The following actions are performed when a user is created:

  • a new user with the name "introserv" is created
  • a group with the same name is created
  • a home directory is created in /home/introserv
  • files from the /etc/skel directory are copied to the home directory (this directory contains files used as a template for all new users)

To add a new user to the sudo group, run the following command:

For Debian-based systems:

usermod -aG sudo introserv

For RHEL-based systems:

usermod -aG wheel introserv

The changes take effect after the user logs out and logs back in.

To remove a user from the sudo group, run the following command:

For Debian-based systems:

gpasswd -d introserv sudo

For RHEL-based systems:

gpasswd -d introserv wheel

To delete a user, run the following command:

For Debian-based systems:

deluser --remove-home introserv

For RHEL-based systems:

userdel -r introserv

Both commands remove the user along with their home directory. Files owned by the user outside the home directory will not be removed automatically. Without the --remove-home flag (Debian-based) or -r flag (RHEL-based), the home directory will remain on the server.

Before deleting a user, make sure they have no active running processes:

ps -u introserv

VAT

  • Other

    Ex. VAT

    0%
  • austria

    Austria

    20%
  • Belgium

    Belgium

    21%
  • Bulgaria

    Bulgaria

    20%
  • Croatia

    Croatia

    25%
  • Cyprus

    Cyprus

    19%
  • Czech Republic

    Czech Republic

    21%
  • Denmark

    Denmark

    25%
  • Estonia

    Estonia

    22%
  • France

    France

    20%
  • Finland

    Finland

    24%
  • Germany

    Germany

    19%
  • Greece

    Greece

    24%
  • Hungary

    Hungary

    27%
  • Ireland

    Ireland

    23%
  • Italy

    Italy

    22%
  • Latvia

    Latvia

    21%
  • Lithuania

    Lithuania

    21%
  • Luxembourg

    Luxembourg

    17%
  • Malta

    Malta

    18%
  • Netherlands

    Netherlands

    21%
  • Poland

    Poland

    23%
  • Portugal

    Portugal

    23%
  • Romania

    Romania

    19%
  • Slovakia

    Slovakia

    20%
  • Slovenia

    Slovenia

    22%
  • Spain

    Spain

    21%
  • Sweden

    Sweden

    25%
  • USA

    USA

    0%
european
states
  • germany
  • Español
  • Italiano
  • Poland
  • Русский
  • Slovenski
  • Türkçe
  • ukraine
  • kingdom
  • French
  • Hrvatska
  • Other
  • Austria
  • Belgium
  • Bulgaria
  • Croatia
  • Cyprus
  • Czech Republic
  • Denmark
  • Estonia
  • Finland
  • France
  • Germany
  • Greece
  • Hungary
  • Ireland
  • Italy
  • Latvia
  • Lithuania
  • Luxembourg
  • Malta
  • Netherlands
  • Poland
  • Portugal
  • Romania
  • Slovakia
  • Slovenia
  • Spain
  • Sweden
  • USA