To add a user in a Linux environment, you can use the useradd command. Here’s a concise guide on how to do it:
Basic Command
sudo useradd -m username
sudo: Runs the command with administrative privileges.useradd: Command to add a new user.-m: Creates a home directory for the user.username: Replace this with the desired username.
Example
To add a user named john:
sudo useradd -m john
Setting a Password
After creating the user, you should set a password:
sudo passwd john
You will be prompted to enter and confirm the new password.
Adding to Groups
If you want to add the user to specific groups (e.g., sudo, ssl-cert), you can do so with the -G option:
sudo useradd -m -G sudo,ssl-cert john
Summary
- Create the user:
sudo useradd -m john - Set the password:
sudo passwd john - (Optional) Add to groups:
sudo useradd -m -G sudo,ssl-cert john
If you have any further questions or need additional details, feel free to ask!
