In This Article ,We’re going to show you useful commands of useradd which helps in daily work for system administrator. We will show you how to add user using two different commands.
- Let’s add user
We have added user using two different commands adduser and useradd both works the same.
grep ravi /etc/passwd && grep raj /etc/passwd
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 –M options
useradd -M testing
4. Manually Assign UID
If you want to assign UID to user, Use –u option
useradd -u 1500 test
grep test /etc/passwd
5. Change USER home directory
If you want to change home directory, use –d option
usermod -d /opt/testing testing
grep testing /etc/passwd
6. Lock USER account
If you want to lock user account, use –L options
usermod -L raj
I have locked raj account and trying to access it.
su – raj
7. Unlock User Account
If you want to unlock the user account, use –U option
usermod -U raj