| PLEX86 | ||
|
Script to add multiple user account in LinuxHere is my shell script to add multiple user account (batch mode) in my linux box. I hope you like it, and if you have any suggestions please let me know. #!-bin-sh ## SCRIPT TO ADD MULTIPLE USERS TO A LINUX SYSTEM ## ## The script will add users, generate secure pbuttword and mail ## info to the users. Also a log file is made! ## ## You need to make it work: ## ## mailx - traditional command-line-mode mail user agent ## pwgen - pbuttword generator ## ## userlist format: USERNAME NAMES LASTNAME CLbutt EMAIL ## ## (c) 2005 Manuel de la Torre ## # Modify this variables if you need MINDAYS=0 # Change pbuttword at anytime MAXDAYS=45 # Max days pbuttword is valid WARNDAYS=10 # Warning message before expire pbuttwd EXPDAYS=180 # Days to expire account from now INACTIVE=45 # Days to lock after pbuttwd expires # Calculte days from Epoch YEARSFROMEPOCH="$((($(date +%G) - 1970 ) * 365 ))" DAYSTHISYEAR="$((($(date +%j))))" DAYSFROMEPOCH=$(( $YEARSFROMEPOCH + $DAYSTHISYEAR + 8 )) # Define some colors first: red='-e0;31m' RED='-e1;31m' blue='-e0;34m' BLUE='-e1;34m' cyan='-e0;36m' CYAN='-e1;36m' NC='-e0m' # No Color # Ensure that root is running the script WHOAMI=`-usr-bin-whoami` if $WHOAMI != "root" ; then echo "Sorry. You must be root to add new users" exit 1 fi # Ensure proper format of the command thiscmd=`basename $0` if "$#" -ne 1 ; then echo "USAGE: $thiscmd userfile" && exit 1 fi USRFILE=$1 # Remove blank lines from input file # Used this solution because of problems # with the IFS in a if -n statement # # Check if buffer file exist, then remove if -atmp-buffer then rmtmp-buffer fi # Read input file, and delete blank lines cat $USRFILE while read TEMP Been a While What Distro do I get 4825 Many Linux distros are available via free download. Unfortunately, HatRed (Red Hat) as we knew it is no longer available in that form. They... do if -n "$TEMP" ; then fi done # Copy temporal file to input file Ext3 Filesystem on Windows Paragon's EXT2FS Anywhere Isn't Working Good evening, all... I have a dual boot machine with Windows XP SP2 and Fedora Core 3 with EXT3 filesystem. I wanted to be... cptmp-buffer $USRFILE rmtmp-buffer # # Save the current value of the IFS ifs="$IFS" Wireless in linux the same topic as always I have a Linksys WUSB11 v1.1 802.11b adapter that I have been using to connect a main (win98) computer... # Define the separator (TAB) between fields # if your input has tabs between fields #IFS=`echo t tr t '-t'` # Define the separator (COMMA) between fields # if your input has spaces between fields IFS="," # buttumning the file has one line per user, in a layout like: # # USERNAME NAMES LASTNAME CLbutt EMAIL # # Configure the useradd program globaly: # useradd -D -b $DEFHOME -e $EXPIRE -g $GROUP cat $USRFILE while read USERNAME NAMES LASTNAME CLbutt EMAIL do USERNAME=`echo $USERNAME tr A-Z a-z` #lower case FULLNAME="$NAMES $LASTNAME" COMMENT="$FULLNAME,$CLbutt" # Check if users exists in system NOEXISTE=`cut -d: -f1etc-pbuttwd grep -i $USERNAME` if -n "$NOEXISTE" ; then echo -e "Creating user $USERNAME:t ${RED}FAILED${NC}" else # Some output to keep you happy echo -e "Creating user $USERNAME:t ${CYAN}SUCCESS${NC}" # Add the user useradd $USERNAME -c "$COMMENT" -m # Set the initial pbuttword PbuttWORD=`pwgen -s` echo $USERNAME:$PbuttWORD chpbuttwd # Change expitation of pbuttwords Been a While What Distro do I get 4826 On Sun, 18 Sep 2005 08:49:19 +0200, Michael Heiming I'm using FC3 and FC4, I also keep an old machine with Whitebox 3 (free version of RHEL 3) which I use for installing distribution sensitive... chage -m $MINDAYS -M $MAXDAYS -E $(( $EXPDAYS + $DAYSFROMEPOCH )) -I $INACTIVE -d 0 $USERNAME # Mail pbuttword echo -e "login: $USERNAMEnpbuttw: $PbuttWORD" mail -s "Account Info" # Log the results userscreatedlog fi done
|
||||
Been a While What Distro do I get 4825 Linux groups from Newsgroups The #1 Usenet Provider on the Internet
|
||||