In this article, We’re going to show you useful commands of useradd which helps in daily work for the system administrator. We will show you how to add a user using two different commands. We can adduser and create a user with a password in Linux using the single command.
Check Out: Create User & Group Using Command line
Useful Commands of Useradd In Linux To Manage Using CLI:
We have added users using two different commands adduser and useradd both works the same.
grep ravi /etc/passwd && grep raj /etc/passwd
Check Out: How To Send Root Mail To existing User
2. Let’s set a full name
If you want to specify the full name of a user, this is also possible in Linux using “–c“ options.
useradd raj -c "Raj sinha"
grep raj /etc/passwd
3. USER with No Home directory
if you want to create a user with no home directory then use the “–M” options.
useradd -M testing
Check Out: How To Create SSh Key With OpenSSH For User
4. Manually Assign UID
If you want to assign UID to the user, Use the “–u” option
useradd -u 1500 test
grep test /etc/passwd
5. Change USER home directory
If you want to change the home directory, use the “–d” option.
usermod -d /opt/testing testing
grep testing /etc/passwd
Check Out: How To Delete Existing Users In Ubuntu
6. Lock USER account
If you want to lock a user account, use “–L” options.
usermod -L raj
you can verify the user status.
I have locked a raj account and trying to access it.
su - raj
Check Out: Force User to Change Password At first
7. Unlock User Account
If you want to unlock the user account, use the “–U” option.
usermod -U raj
You’re done add user in linux linux create user with password adduser