
- Operating System Tutorial
- OS - Home
- OS - Overview
- OS - Components
- OS - Types
- OS - Services
- OS - Properties
- OS - Processes
- OS - Process Scheduling
- OS - Scheduling algorithms
- OS - Multi-threading
- OS - Memory Management
- OS - Virtual Memory
- OS - I/O Hardware
- OS - I/O Software
- OS - File System
- OS - Security
- OS - Linux
- OS - Exams Questions with Answers
- OS - Exams Questions with Answers
- Operating System Useful Resources
- OS - Quick Guide
- OS - Useful Resources
- OS - Discussion
How to Create Multiple User Accounts in Linux?
Adding a single new user to a Linux system can be achieved through the useradd command. But system admins often get request to add many users. So Linux provides a different to do a bulk addition of many users to a system.This is the newusers command.
Synatx
sudo newusers user_deatils.txt user_details.txt is the file containing the details of all the usernames to be added.
User Details
Below we see the structure of user_details.txt file.
UserName:Password:UID:GID:comments:HomeDirectory:UserShell
So we create a file with below details to add many usres.
~$ cat MoreUsers.txt uname1:pwd#@1:2112:3421:storefront:/home/uname1:/bin/bash uname3:pwd#!@3:2112:3525:backend:/home/uname3:/bin/bash uname4:pwd#$$9:9002:4721:HR:/home/uname4:/bin/bash
Giving Permissions to the User Details File
Before we sue the user details file to add new users, we should give permission to it to be read by other processes.
sudo chmod 0600 MoreUsers.txt
Lets verify the existing users in the system by going to the /etc/passwd file.
ubuntu@ubuntu:~$ tail -5 /etc/passwd
Running the above code gives us the following result −
pulse:x:117:124:PulseAudio daemon,,,:/var/run/pulse:/bin/false rtkit:x:118:126:RealtimeKit,,,:/proc:/bin/false saned:x:119:127::/var/lib/saned:/bin/false usbmux:x:120:46:usbmux daemon,,,:/var/lib/usbmux:/bin/false ubuntu:x:1000:1000:ubuntu16LTS,,,:/home/ubuntu:/bin/bash
Run newusers Command
next we run the newusers command to add these usernames.
sudo newusers MoreUsers.txt
Verify Added Users
Now we verify that indeed those users are added , by going again to the /etc/passwd file.
cat /etc/passwd
Running the above code gives us the following result −
……….. …………. ubuntu:x:1000:1000:ubuntu16LTS,,,:/home/ubuntu:/bin/bash uname1:x:2112:3421:storefront:/home/uname1:/bin/bash uname3:x:2112:3525:backend:/home/uname3:/bin/bash uname4:x:9002:4721:HR:/home/uname4:/bin/bash
- Related Articles
- How can we create user accounts in MySQL database server?
- Create manage user accounts using utility netplwiz
- How to get a list of MySQL user accounts?
- How to find the locked local user accounts using PowerShell?
- How to get the disabled local user accounts using PowerShell?
- Best option for locking bulk user accounts in SAP
- How to add a user to the group on linux
- How to Run a Command Multiple Times in Linux?
- How to Find User Account Info and Login Details in Linux?
- How to create a process in Linux?
- How to Force User to Change Password at Next Login in Linux?
- How to Copy a File to Multiple Directories in Linux?
- How to create a user in MongoDB v3?
- How to create user defined exceptions in C#?
- How to create a User Menu in PowerShell?
