|
||||||
| Forums FAQ | Members List | Search | Today's Posts | Mark Forums Read |
| ARCHIVES - Security Want to know if you should really apply the latest kernel patch? Want to know how to configure your firewall? Discuss any Security related topics in here! |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hello all,
I am doing an assignment for school and I need to add 123 users at the same time as part of the assignment. They have to meet the follwoing requirements thier user id has to be from 3001 - 3123. their home directory has to be /home/user001 - /home/user123 pass must change in 28 days GID: 9999 GroupName: clients I know scripting is involved but i have no idea :blink: Can anyone plz help me out? Thanks Alot! |
|
|||
|
Something to get you started. You will need to check the commands. BTW the following doesn't set a password for the user accounts.
#!/bin/bash # # # START_UID=1000 END_UID=1050 HOME_DIR_BASE=/home/user USERADD=/usr/sbin/useradd PASSWD=/usr/bin/passwd GROUPADD=/usr/sbin/groupadd GROUP="clients" PASSWORD_CHANGE=28 count=$START_UID while [ $count -le $END_UID ] do $USERADD -d $HOME_DIR_BASE$count -u $count -g $GROUP -m "user{$count}" if [ $? -gt 0 ];then echo "Error adding $count" fi $PASSWD -n 28 "user${count}" if [$? -gt 0 ];then echo "Error setting password expiry for $count" fi done |
|
|||
|
Quote:
Education = learning, and you won't learn a thing if someone else just hands you the answer. |
|
|||
|
Quote:
|
|
|||
|
I have to disagree that this is cheating. Personally I've found that writing code cold when you have little or no experience daunting and seeing examples or parts of code highly beneficial.
I believe the OP stated that they didn't know where to start. The code I wrote isn't complete and has some minor issues. I dare say if the OP troubleshoots the code and modifies it to suit they will gain a better understanding. It really is up to the individual to get what they can from examples and it’s not our place to judge. If it’s just a straight copy into an assignment then it’s of little benefit, however if the OP is more inquiring then they will benefit. The type of person who gets ahead in IT is the type of person with an inquiring mind. However everyone needs somewhere to start. Obviously the OP isn’t familiar with scripting and may not have seen many examples. If the OP copies this code verbatim there is a good chance the OP will be caught out. Teachers are increasingly using software that checks the internet for plagiarism. |
|
|||
|
Quote:
It is only by standing on shoulders of giants that we can push the boundary of human history wider. I am constantly seeking help in this forum asking various questions (many thanks to those kind experts and sorry if I bothered you too much!) and also wish if I could provide some help to others. I truly believe that every enquiry has a valid reason and we should give a hand whenever we can. |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|