Your cart is currently empty!
How to Create Multiple Users and Set Password for each User in Linux
Managing user accounts is a core task for any Linux system administrator. Whether you’re setting up a shared server, managing student logins in a lab, or configuring access for a development team, knowing how to create multiple users efficiently — and set unique passwords for each — is essential.
Here’s how to get it done, step-by-step.
🔧 Option 1: Create Users One by One
This is good for when you only need to add a few users.
sudo adduser username1
sudo passwd username1
Repeat for each user:
sudo adduser username2
sudo passwd username2
You’ll be prompted to enter and confirm a password for each user. Done.
🚀 Option 2: Create Multiple Users from a Text File
If you’re adding a bunch of users, automate it. Create a text file with usernames and passwords.
Step 1: Create a user list
nano users.txt
Add entries like this:
alice:Password123
bob:Secure456
charlie:Pass789
Each line is username:password
.
Step 2: Run a script to create them
#!/bin/bash
while IFS=: read -r user pass; do
sudo useradd -m "$user"
echo "$user:$pass" | sudo chpasswd
done < users.txt
Save the script as create_users.sh
, then run:
chmod +x create_users.sh
./create_users.sh
This will:
- Create each user with a home directory (
-m
) - Set their password using
chpasswd
🛡️ Tips for Security
- Enforce strong passwords — use a password generator or
pwgen
. - Lock accounts you don’t need active with
sudo usermod -L username
. - Use
passwd -e username
to force users to change passwords at first login.
✅ Final Check
To verify the users were created:
cut -d: -f1 /etc/passwd
To check login settings:
sudo chage -l username
Conclusion
Creating and managing users on Linux doesn’t need to be tedious. For small batches, manual entry works. For larger deployments, automate the process with a script and a text file.
It’s fast, clean, and scalable.
Have questions or need a custom script for your setup? Drop a comment below or contact me directly.
Tech enthusiast and content creator passionate about making technology simple for everyone. I share practical tips, guides, and reviews on the latest in computers, software, and gadgets. Let’s explore the digital world together!