วันอาทิตย์ที่ 28 มีนาคม พ.ศ. 2553

20 Linux System Monitoring Tools Every SysAdmin Should Know

http://www.cyberciti.biz/tips/top-linux-monitoring-tools.html

Linux shell script สำหรับ add user ทีละหลายๆ user

#!/bin/bash
# Script to add a user to Linux system

for (( i = 1 ; i <= 50; i++ ))
do

if [ $(id -u) -eq 0 ]; then
egrep "^user$i" /etc/passwd >/dev/null
if [ $? -eq 0 ]; then
echo "$username exists!"
exit 1
else
pass=$(perl -e 'print crypt($ARGV[0], "password")' "123456")
useradd -m -p $pass user$i
[ $? -eq 0 ] && echo "user$i has been added to system!" || echo "Failed to add a user!"
fi
else
echo "Only root may add a user to the system"
exit 2
fi

done