Hack The Sec - Leading Resource Of Linux Tutorial
How To Add and Delete Users on CentOS, RHEL & Fedora

How To Add and Delete Users on CentOS, RHEL & Fedora

Add & Delete Users on CentOS, RHEL & Fedora
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.


1. Add New User

 Following command will create new user named ‘hackthesec’ on your system
# adduser hackthesec
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 hackthesec

Changing password for user hackthesec.
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 hackthesec --home=/var/home/hackthesec
You can also specify any other shell for user in place of default, use –shell switch followed by shell name as below.
# adduser hackthesec --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 hackthesec --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 hackthesec
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 hackthesec and their home directory permanently.
# userdel hackthesec -r





www.hackthesec.co.in
www.twitter.com/hackthesecurity
H

About the author

I am a Linux Administrator and Security Expert. Through this site I share Linux tutorials, hardening guides and security news.

Comments