filmov
tv
How to Create Users in Linux useradd Command | How to Create/Add Users in Linux | with Examples
Показать описание
To create users in Linux using the useradd command, you must have root privileges. To create a user, simply run the following command:
useradd username
This will create a new user with the specified username. You can also specify additional options with the useradd command, such as:
-m: Create a home directory for the user.
-g: Set the user's primary group.
-s: Set the user's default shell.
-c: Set the user's comment.
For example, to create a user named john with the primary group developers and the default shell /bin/bash, you would run the following command:
useradd -m -g developers -s /bin/bash john
Once you have created a user, you can set their password using the passwd command. To set the password for the user john, you would run the following command:
passwd john
You will be prompted to enter and confirm the new password.
Once the password has been set, the user can log in to the system using the su or sudo command.
Here are some additional tips for using the useradd command:
You can create multiple users at once by passing a list of usernames to the useradd command. For example, to create the users john, mary, and peter, you would run the following command:
useradd -m john mary peter
You can create a user with a specific user ID (UID) by using the -u option. For example, to create the user john with the UID 1000, you would run the following command:
useradd -m -u 1000 john
You can create a user with a specific group ID (GID) by using the -g option. For example, to create the user john with the GID 1001, you would run the following command:
useradd -m -g 1001 john
The useradd command is a powerful tool for creating and managing users on Linux systems. By learning how to use the useradd command, you can efficiently manage your users and their permissions.
useradd username
This will create a new user with the specified username. You can also specify additional options with the useradd command, such as:
-m: Create a home directory for the user.
-g: Set the user's primary group.
-s: Set the user's default shell.
-c: Set the user's comment.
For example, to create a user named john with the primary group developers and the default shell /bin/bash, you would run the following command:
useradd -m -g developers -s /bin/bash john
Once you have created a user, you can set their password using the passwd command. To set the password for the user john, you would run the following command:
passwd john
You will be prompted to enter and confirm the new password.
Once the password has been set, the user can log in to the system using the su or sudo command.
Here are some additional tips for using the useradd command:
You can create multiple users at once by passing a list of usernames to the useradd command. For example, to create the users john, mary, and peter, you would run the following command:
useradd -m john mary peter
You can create a user with a specific user ID (UID) by using the -u option. For example, to create the user john with the UID 1000, you would run the following command:
useradd -m -u 1000 john
You can create a user with a specific group ID (GID) by using the -g option. For example, to create the user john with the GID 1001, you would run the following command:
useradd -m -g 1001 john
The useradd command is a powerful tool for creating and managing users on Linux systems. By learning how to use the useradd command, you can efficiently manage your users and their permissions.