Syntax of `useradd` command in Linux

The basic syntac for the `useradd` command is as follows.

useradd [options] [User_name]

How to add User in Linux | useradd Command

useradd is a command in Linux that is used to add user accounts to your system. It is just a symbolic link to adduser command in Linux and the difference between both of them is that useradd is a native binary compiled with the system whereas adduser is a Perl script that uses useradd binary in the background. It makes changes to the following files:

  • /etc/passwd
  • /etc/shadow
  • /etc/group
  • /etc/gshadow
  • creates a directory for new user in /home

Table of Content

  • Syntax of `useradd` command in Linux
  • Working with `useradd` Command
  • 1. How to Add a User in Linux
  • 2. How to Add User by Specifying a home directory path for the new user
  • 3. How to Create a User with a Specific User ID (UID)
  • 4. How to Create a User with a Specific Group ID (GID)
  • 5. How to Create a User Without a Home Directory
  • 6. How to Create User with an Expiry Date
  • 7. How to Create User with a Comment
  • 8. How to Create a User with Changed Login Shell
  • 9. How to Set an Unencrypted Password for the User
  • 10. Displaying Help

Similar Reads

Syntax of `useradd` command in Linux

The basic syntac for the `useradd` command is as follows....

Working with `useradd` Command

1. How to Add a User in Linux...

1. How to Add a User in Linux

This command will add the user named “test_user”....

2. How to Add User by Specifying a home directory path for the new user

To give a home directory path for new users, we use the following command in Linux....

3. How to Create a User with a Specific User ID (UID)

To create a new user with a custom UID, we use the following command....

4. How to Create a User with a Specific Group ID (GID)

To create a new user and assign a specific group ID, use the following command...

5. How to Create a User Without a Home Directory

To create a user without a home directory, we use the following command....

6. How to Create User with an Expiry Date

To set an expiry date for a user account, we use the following command....

7. How to Create User with a Comment

To add a comment or description for a user, we use the following command....

8. How to Create a User with Changed Login Shell

To create a user with a different login shell, we use the following command....

9. How to Set an Unencrypted Password for the User

To set an unencrypted password for the user, we use the following command....

10. Displaying Help

To display help, we use the following command....

Conclusion

In this article we have discussed the `useradd` command in Linux which is a powerful tool for creating user accounts with various customizations. Overall, we can say that by understanding its options and syntax, system administrators can efficiently manage user accounts on their Linux system....