2009年8月1日 星期六

shell

#! /bin/bash
echo "Please Input [a-z]"

#! /bin/bash
# argcount() is function, in objective 9
echo $0
echo $1
echo $2
echo $3
echo $4
echo $5
echo $@
echo $*
argcount() {
echo "Number of arguments: $#"
echo '$1:' "$1"
}
echo 'argcount "$@"'
argcount "$@"
echo 'argcount "$*"'
argcount "$*"
echo OVER
echo "Total argu is $#"
#! /bin/bash
# [] is the test command in objective 4, -f --> file

[ -f /home/joe/dir1 ] && echo "/home/joe/dir1 is a File"
exit

#! /bin/bash
[ -f /home/joe/dir1 ] || touch /home/joe/dir1
ls -l /home/joe
exit

#! /bin/bash
# if is in objective 4,
# -d --> directory
if [ -d /home/joe/dir ]; then
echo "the Dir exist"
exit
else
echo "the Dir non-exist"
mkdir /home/joe/dir
fi
#! /bin/bash
# -e --> exist
if [ -e /home/joe/dir/file1 ]; then
rm -rf /home/joe/dir/file1
echo "File deleted"
elif [ -d /home/joe/dir ]; then
echo "the dir exist"
touch /home/joe/dir/file1
exit
else
echo "the dir non-exist"
mkdir /home/joe/dir
fi
#! /bin/bash
# -n --> nonzero
[ -n $USER -a "$USER" = "root" ] && echo "you are root"
exit

#! /bin/bash
# for is the command in objective 4
for i in $( cat /home/joe/userlist )
do
echo "Add user $i "
useradd -m $i
echo 1234 | passwd --stdin $i
echo "done"
done
#! /bin/bash
for (( i=100 ; i < 120 ; i=i+1 ));
do
echo "Add user x$i"
useradd -m x$i
echo 1234 | passwd --stdin x$i
echo "done"
done
#! /bin/bash
# read is the command in objective 6
echo "Please Input your choice"
read CHOICE
echo "Your choice is $CHOICE"
#! /bin/bash
#let, $(( )), is the command in objective 5
a=100
b=200
c=$a+$b
d=$(( $a+$b ))
echo $c
echo $d
let e=$a+$c
echo $e
#!/bin/bash
#while is the command in objective 4
while [ -n "$1" ]; do
echo "\$1 is $1"
echo "\$2 is $2"
echo "Total arg is $#"
shift
done
#!/bin/bash
#case is the command in objective 4

echo "Enter yes or no"
read yesno
case "$yesno" in
y*|Y*)
echo "Your answer is YES"
;;
[nN]*)
echo "Your answer is NO"
;;
*)
echo "You type wrong word"
esac
#!/bin/bash
# until is the command in objective 4

secret=''
until [ "$secret" = "linux" ]; do
echo -n "Enter your favorite OS name"
read secret
done
echo "I love linux"
#!/bin/bash
# array in objective 7

#set value to array
sample[0]="zero"
sample[1]="one"
sample[2]="three"

#show value
for i in 0 1 2; do
echo "sample[$i]=${sample[$i]}"
done
#!/bin/bash
#sed is the command in objective 10

English="She sales seashells in the seashore, the seashells she sales in the seashore is not seashell I am sure."

echo "$English" | sed 's/sales/buy/'
echo "$English" | sed 's/sales/buy/g'
#!/bin/bash
#tr is the command in objective 10

English="She sales seashells in the seashore, the seashells she sales in the seashore is not seashell I am sure."

result=`echo "$English" | tr 'a-z' 'A-Z' `
echo "\$result is $result"
#!/bin/bash
# cut is the command in objective 10

yourip=`ifconfig | grep Bcast | cut -d : -f 2 | cut -d ' ' -f 1 `
echo "Your IP is $yourip"

2009年7月29日 星期三

vmwaresn.txt

Thank You for Registering!

Thank you for your interest in VMware(TM) Server. We are pleased to help you begin enjoying the benefits of virtualization.

The following serial number(s) have been issued for you: [Print this page]

9ANHJ-YFEF2-1E31K-4CKVW
9AHR5-YF8D2-15P9P-4CJ8X

2009年7月27日 星期一

suse_command

ls -il
ls -F
ls /
ls -R aaaa
alias
cp -i test test2
su max -c "touch test3"
mv test3 test6
mkdir -p aaa/bbb/ccc
rm -r abc
=======================
grep -i max /etc/*
grep -w max /etc/*
grep -v '^#' httpd.conf | grep -v '^$' | wc -1
egrep -v '^#|^$' httpd.conf
==========================
echo $?
ls /12345 2> test2
date > df.txt
date >> df.txt
mail root -s "disk free" < df.txt
mail
Lab: &&, ||
#ls / && echo “novell”
#ls /123 && echo “novell”
#ls / || echo “novell”
#ls /123 || echo “novell”
=================================
useradd -m john
tail -n 2 /etc/passwd
tail -n 2 /etc/shadow
ls -a /etc/skel
ls -a /home/john
passwd max
echo 1234 | passwd --stdin max
userdel
userdel -r
usermod -L test
usermod -U test
userdel test
ls -l /home
mv /home/test /root
chown root.root /root/test
===================================
groupadd mis
groupmod -A max mis
groupmdo -R max mis
tail -n 2 /etc/group
groupdel mis
=============================
du -sh /etc
du -h --max-depth=1 /home
nl /etc/passwd
head -n 20 /etc/passwd | tail
tail -n 14 /etc/passwd | head
============================
yast -i findutils-locate
updatedb
locate whatis
whereis whatis
which whatis
=====================
:1,100s/httpd.conf/http.bak/gc
:151,156s/^/#/g
:set nu
:set nonu
:set hlsearch
:set backspace=2
syntax on
vi /etc/inittab
id:3:initdefault