Linux create new user

To create a new user in Linux, you can use the useradd command. Here are the basic syntax and options:

Basic Syntax:

useradd [options] username

Options:

Example:

useradd -m -s /bin/bash -g users newuser

This command creates a new user named newuser with a home directory, sets the default shell to /bin/bash, and assigns the user to the users group.

Alternative Method: You can also use the adduser command, which is a more user-friendly alternative to useradd. Here's an example:

adduser newuser

This command will prompt you to enter the password for the new user, and then create the user with default settings.

Additional Options:

Example with additional options:

useradd -m -s /bin/bash -g users -d /home/newuser -c "New User" -e 2023-12-31 newuser

This command creates a new user named newuser with a home directory, sets the default shell to /bin/bash, assigns the user to the users group, specifies a custom home directory, sets a custom comment, and sets an expiration date for the account.

Remember to replace newuser with the desired username, and adjust the options as needed for your specific use case.