You may need to create separate account for every user want to connect this system. For adding new users in system there are two commands available in your system, useradd and adduser. adduser command is the enhanced version of useradd command. adduser command uses useradd command in backend. This tutorial will help you to add and delete user on CentOS, RHEL, Fedora and CoreOS operating systems.

Advertisement

1. Add New User

For this tutorial we are using adduser command for examples. Following command will create new user named ‘rahul’ on your system

# adduser rahul

Still you can’t login to your system with this account. You need to set a password to account to active it. Use this command to set new password.

# passwd rahul

Changing password for user rahul.
New password: **************
Retype new password: **************
passwd: all authentication tokens updated successfully.

By default above command will create users home directory as /home/. But you can specify home directory at any other location using following command.

# adduser rahul --home=/var/home/rahul

You can also specify any other shell for user in place of default, use –shell switch followed by shell name as below.

# adduser rahul --shell=/bin/bash

If you don’t want to create users home directory. You can use –no-create-home switch with adduser command as below.

# adduser rahul --no-create-home

2. Delete User from System

Now its good to lock or delete any user from system which is no longer required. Use the following command to delete any user from system.

# userdel rahul

The above command will not delete users home directory. If you also want to delete users home directory use -r or –remove-home parameter with command, For example below command will delete user rahul and their home directory permanently.

# userdel rahul --remove-home
Share.
Leave A Reply

Exit mobile version