Solved

how to creat linux users without interact with the console?

Posted on 2013-01-04
1
538 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 77

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
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 several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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 …

770 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