In this tutorial you will learn how to create and delete users on Ubuntu Server using useradd and userdel commands and also to check the new user values.
Code used during this tutorial:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# Create and delete a user on Ubuntu Server # Create a new user # -m Create the user's home directory if it does not exist # -s The name of the user's login shell # -g The group name or number of the user's initial login group # -c It is generally a short description of the login, and is currently used as the field for the user's full name sudo useradd -m -s /bin/bash -g www-data -c "Liviu Balan" liviu.balan # User account information vi /etc/passwd # Change user ID sudo su liviu.balan # Check home dir cd ~/ pwd # Check default group groups exit # Delete a user account and related files # -r Files in the user's home directory will be removed along with the home directory itself and the user's mail spool # -f This option forces the removal of the user account, even if the user is still logged in sudo userdel -rf liviu.balan |