[email protected]Support 24/7 · Billing 09:00 – 00:00LinkedInXFacebook
NexonHost
Netherlands Dedicated ServersAmsterdam · Equinix AM6Germany Dedicated ServersFrankfurt · Equinix FR4Romania Dedicated ServersBucharest · VoxilityAustria Dedicated ServersVienna · Interxion VIEBulgaria Dedicated ServersSofia · TelepointFrance Dedicated ServersParis · Interxion PAR — Marseille · Digital Realty MRS3Ireland Dedicated ServersDublin · Equinix DB2Italy Dedicated ServersMilan · Irideos AvalonPoland Dedicated ServersWarsawSpain Dedicated ServersMadrid · Equinix MD2United States Dedicated ServersAshburn · Equinix DC
All articles
Getting startedJune 12, 2023

How to Add and Delete Users on CentOS 7.

How To Add And Delete Users On CentOS 7.

In this tutorial, we will explain how to add and remove users on CentOS 7 systems.

 

How To Add User in CentOS

In CentOS, you can create a new user account using the useradd command-line utility.

To create a new user account named “username” you would run:

sudo adduser username

The command above displays no output. It will create the new user’s home directory (/home/username) and files from /etc/skel directory to the user’s home directory. Within the home directory, the user can write, edit, and delete files and directories.

Next, you’ll need to set a password for the new user so that the user can log in. To do so, use the passwd command:

sudo passwd username

You will be prompted to enter and confirm the password. Make sure you use a strong password.

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

By default on CentOS, members of the group wheel are granted with sudo access.

If you want the newly created user to have administrative rights, add the user to the wheel group :

sudo usermod -aG wheel username

If you’re logged in as root, you don’t have to prepend each command with sudo.

 

How To Delete a User in CentOS

If the user account is no longer needed, you can delete it using the deluser command-line tool.

To delete the user, without deleting the user files, run:

sudo userdel username

If you want to delete and the user’s home directory and mail spool use the -r flag:

sudo userdel -r username

On success, the userdel command doesn’t produce any output.

If the user was granted sudo privileges, it will be removed from the wheel group, as well as from any other groups the user was a member of.

 

Conclusion

In this tutorial, you learned how to add and remove users in CentOS. The same commands apply for any other Linux distribution.

Keep reading
How to use tac command in Linux.
September 13, 2023

How to use tac command in Linux.

What is tac command: tac command in Linux is used to concatenate and print files in reverse. This command will write each FILE to standard output, the last line first. When no file is specified then this command will read the standard input. Syntax: tac [OPTION]… [FILE]… Options: tac -b: This…

Read article
How to use and install neofetch.
September 13, 2023

How to use and install neofetch.

How To Use And Install Neofetch. Neofetch displays an ASCII logo of your Linux distribution along with information related to your system in the terminal. Many Linux users will use it in screenshots of their desktops just because they think it’s cool. And they’re right. You can use it to show off…

Read article
How to use whatis command in Linux.
September 13, 2023

How to use whatis command in Linux.

How To Use Whatis Command. The whatis command is used to get brief information about Linux commands or functions. It displays the manual page description in a single line of the command that passes with the whatis command. It searches for the strings that have been passed with it from its index…

Read article
Get in Touch

Together, Let’s Build a Faster, Safer Internet.

Build scalable infrastructure with NexonHost — high-performance dedicated servers, VPS hosting, cloud hosting, and DDoS protection across Europe.

Get Started →Contact Us
[email protected]Support 24/7 · Billing 09:00 – 00:00