Useful Commands of Useradd To Manage Using CLI In Linux

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.

useradd ravi

adduser raj

add user in linux

Verify

grep ravi /etc/passwd && grep raj /etc/passwd

linux create user with password

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

adduser linux

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

linux add user with password one line

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

linux useradd add home directory

grep test /etc/passwd

how to add users in linux command line

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

Share on:

I'm the founder of Curious Viral. I hope this blog will provide you complete information about Linux Technology & I would like to share my technical knowledge with you which I have learned during this period.

Other Posts You May Like...

Leave a comment