Solved

how to creat linux users without interact with the console?

Posted on 2013-01-04
1
531 Views
Last Modified: 2013-01-17
Dear experts,
I have following requirements:
I must create much users in the centos linux server.
I can do it manually with useradd and passwd command.
But since i have this action done hundreds of times, is there any script who can create the
user and set his password without any interact with console?

Thanks a lot for your valuable information.

Best Regards,
Robert
0
Comment
Question by:matiascx
1 Comment
 
LVL 76

Accepted Solution

by:
arnold earned 500 total points
ID: 38746357
You have a file with username encrypted_password group
cat filename | while read a b c ; do
If  ( grep "$a" "/etc/passwd" >/dev/null) ; then
 echo alread exists
else
echo useradd -g $c -m -d /home/$a -p "$b" $a
fi
done

If the output is in the correct format, remove echo and let it run
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Join & Write a Comment

Suggested Solutions

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now