ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
There is less than 24 hours left to vote in the 2015 LinuxQuestions.org Members Choice Awards. Click here to go to the polls. Vote now and make sure your voice is heard!
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Soon I will be asked to add multiple users on our Linux server, I will have a text file with a 30 names, I need a script that will add the 30 users+permission, can anyone help me or guide me to that, also what about the permission, can the permission be input from the text file, Thanks for your help.
What's the format of the names file? You'll need to know the name you want to use as the user's ID (the name they'll login with, and (not essential) their full name for the GECOS (comment) field. Your script can read the information from the name file with code like
cat namefile | while read user
# do the useradd
man useradd to see what you have to specify to create the user entry. Use $user for the ID of the user you're adding.
As to permissions, you can use chmod to change that if you're not happy with the defaults - you can refer to the user's home directory as ~username so you don't need to know the actual home directory path.
ok this is what i did, new text file and saved as users.sh
cat names | while read first last user
# do the useradd
/usr/sbin/useradd -c "$first $last" -m $user
i run the scpript i did
cat /etc/passwd | cut -d ":" -f1
and the new user was added + $Home.
but i still have problem understanding this line:
while read first last user
last and user are just simple text how does the system knows that first would be the name of the user...etc!! am just trying to understand, and $first $last $user are dynamic var?, how they are connected with first last and user, what am trying to say how does the system knows the order of content of the file?
when i tried adding more users on my text it would only add the first line
test test1 test2
alex alex1 alex2
only test2 will be added!