Professional Documents
Culture Documents
..................................................................................5
2010.12 - 2011.01.............................................................................................10
Linux .............................................................................................................11
.........................................................................................................14
Linux ......................................................................................................16
51CTO
http://g.51cto.com/linuxops
groups.google.com/group/linuxops-cn
linuxops-cn+subscribe@googlegroups.com
................................................................................................23
B Linux Shell 2....................................................................................26
http://os.51cto.com/art/201011/233915.htm
http://down.51cto.com/zt/71
yangsai@51cto.com
People
Linux CDN
51CTO Linux
03 linux
LinuxTone.org CDN
07
http://liuyu.blog.51cto.com/
51CTO
51CTO
LinuxTone
51CTO
http://g.51cto.com/linuxops/
http://os.51cto.com/linux/
yangsai@51cto.com
People
51CTO
allcommands cyberciti
CU 51CTO LinuxTone
08
51CTO
/
~
51CTO LinuxTone.org
Linux
2008 netseek
LinuxTone
IT
51CTO Linux
README
WIKI INSTALL
OK GOOGLE
51CTO
51CTO
2011
http://os.51cto.com/art/201012/240498.htm
Tom Limoncelli
http://os.51cto.com/art/201010/229500.htm
howtoforge
4
http://g.51cto.com/linuxops/
http://os.51cto.com/linux/
yangsai@51cto.com
Interact
15
/Dormando
rm
-rf /
Linux
Linux
V3 V4 V4
V5
http://g.51cto.com/linuxops/
http://os.51cto.com/linux/
yangsai@51cto.com
Interact
NFS
1000
TCP
500 Web
Rsync DRBD
rrd
http://g.51cto.com/linuxops/
http://os.51cto.com/linux/
yangsai@51cto.com
Interact
DBA
starling Gearman
MySQL
master slave
slave
NFS
slave
slave
MogileFS
slave
Oracle
DBA
IO
RAID 10
RAM RAM
SSD
DBA
RAM
Web
CPU apache
http://g.51cto.com/linuxops/
http://os.51cto.com/linux/
yangsai@51cto.com
Interact
memcached
HTTP /
job systems
Schwartz
10
OK
Memcached
squid
MySQL
SSH
passphrase
SSH
- IM -
http://g.51cto.com/linuxops/
http://os.51cto.com/linux/
yangsai@51cto.com
Interact
PHP
http://dormando.livejournal.com/484577.html
http://os.51cto.com/art/201101/241769.htm
http://os.51cto.com/art/201012/241108.htm
2010 Linux
http://os.51cto.com/art/201012/238961.htm
http://g.51cto.com/linuxops/
http://os.51cto.com/linux/
yangsai@51cto.com
News
2010 12 2011 1
NovellAttachmate 22
Novell Novell
2010.12 - 2011.01
882 4.5
CPTN Holdings LLC
/51CTO
CPTN
Holdings LLC
EMC
Linux Dan
LibreOffice Ubuntu
Rosenberg C 200
Linux Econet 3
http://os.51cto.com/art/201012/237990.htm
for
Linux
iPadiPhoneAndroid
Testing
Ubuntu
http://os.51cto.com/art/201101/242171.htm
Debian
Linux Mint
2012 64
Hotmail Hotmail
FBI
12 30
http://os.51cto.com/art/201101/242496.htm
http://os.51cto.com/art/201012/239221.htm
Mint
LibreOffice
http://os.51cto.com/art/201012/239047.htm
http://os.51cto.com/art/201012/241115.htm
Linux
Apache 2010
2010 1.52
http://os.51cto.com/art/201101/241932.htm
http://os.51cto.com/art/201012/239006.htm
http://os.51cto.com/art/201012/240558.htm
10
http://g.51cto.com/linuxops/
http://os.51cto.com/linux/
yangsai@51cto.com
Special
Linux
Linux
/
-Bottleneck
A C
http://polymorphicpodcast.com/shows/webperformance/
11
http://g.51cto.com/linuxops/
http://os.51cto.com/linux/
yangsai@51cto.com
Special
CPU
/ CPU
Memory
IO
Network
IO IO
IO
CPU
CPU
CPU CPU
CPU web/mail
CPU
$ vmstat 1
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----r b
swpd
free
buff cache
si
so
bi
bo
in
cs us sy id wa st
0 4
140 1962724 335516 4852308 0
0
388 65024 1442 563 0 2 47 52 0
0 4
140 1961816 335516 4853868 0
0
768 65536 1434 522 0 1 50 48 0
0 4
140 1960788 335516 4855300 0
0
768 48640 1412 573 0 1 50 49 0
0 4
140 1958528 335516 4857280 0
0 1024 65536 1415 521 0 1 41 57 0
0 5
140 1957488 335516 4858884 0
0
768 81412 1504 609 0 2 50 49 0
$ vmstat 1
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----r b
swpd
free
buff cache
si
so
bi
bo
in
cs us sy id wa st
4 0
140 3625096 334256 3266584 0
0
0
16 1054 470 100 0 0 0 0
4 0
140 3625220 334264 3266576 0
0
0
12 1037 448 100 0 0 0 0
4 0
140 3624468 334264 3266580 0
0
0
148 1160 632 100 0 0 0 0
4 0
140 3624468 334264 3266580 0
0
0
0 1078 527 100 0 0 0 0
4 0
140 3624712 334264 3266580 0
0
0
80 1053 501 100 0 0 0 0
id
CPU id
50 CPU id
12
http://g.51cto.com/linuxops/
http://os.51cto.com/linux/
yangsai@51cto.com
Special
VPSee RAID0
RAID0 IO
top
RAID0 IO
vmstat
RAID0
Linux
CPU
mpstat
iptraf
tcpdump
tcptrace
RAID0 IO
sar
netstat
IO
iostat
CPU
netperf
dstat
vmstat,
iostat,
ifstat,
http://www.vpsee.com/2009/11/linux-systemperformance-monitoring-introduction/
netstat
VPSee
13
http://g.51cto.com/linuxops/
http://os.51cto.com/linux/
yangsai@51cto.com
Special
3.
RAID
I/O I/O
/Kenneth Hess
CPU 75%
CPU
CPU
100%CPU
1.CPU
4.
2.
CPU
CPU
14
5.
http://g.51cto.com/linuxops/
http://os.51cto.com/linux/
yangsai@51cto.com
Special
6.
8.
9.
LAMPLinuxApacheMySQLPHP
KVW
OpenVZ Parallels Solaris
Zones
JFS
CPUXFS NTFS
EXT4
7.
10.
http://www.serverwatch.com/trends/article.ph
p/3912821/Uncover-Your-10-Most-PainfulPerformance-Bottlenecks.htm
http://os.51cto.com/art/201011/233490.htm
x86
http://os.51cto.com/art/201008/220004.htm
15
http://g.51cto.com/linuxops/
http://os.51cto.com/linux/
yangsai@51cto.com
Special
Linux df du fdisk
df du fdisk
/dev/hda2
24130460
/dev/hda6
232729
27474876
1948772 93% /usr
256667
10686 96% /var
Linux
2
1024
/
34
3 4
Linux
dfdu
fdisk
Linux
1df
-t
-x
t
-T
df
//
df #df
1k-blocks
Filesystem
Used
Available Use% Mounted on
i
/dev/hda5
381139
332921
28540 93% /
df
/dev/hda1
46636
-a
6871
37357 16% /boot
0 block/proc /dev/hda3
10041144
-k k
6632528
2898556 70% /home
none
127372
-i i
0
127372
0% /dev/shm
16
Use%
100%
Mounted on
// i
#df -ia
Filesystem
Inodes
IUsed
IFree IUse% Mounted on
/dev/hda5
98392
23919
74473
25% /
http://g.51cto.com/linuxops/
http://os.51cto.com/linux/
yangsai@51cto.com
Special
none
0
0
0
- /proc
/dev/hda1
12048
38
12010
1% /boot
none
0
0
0
- /dev/pts
/dev/hda3
1275456 355008
920448
28% /home
none
31843
1
31842
1% /dev/shm
/dev/hda2
3489792 133637
3356155
4% /usr
/dev/hda6
66264
9876
56388
15% /var
//
#df -T
Filesystem
Type
1k-blocks
Used Available Use% Mounted on
/dev/hda5
ext3
381139
332921
28540 93% /
/dev/hda1
ext3
46636
6871
37357 16% /boot
/dev/hda3
ext3
10041144
6632528
2898556 70% /home
none
tmpfs
127372
0
127372
0% /dev/shm
/dev/hda2
ext3
27474876
24130460
1948772 93% /usr
/dev/hda6
ext3
256667
232729
10686 96% /var2
2 du
du
1024
df
-s Names
-a
-s
-a Names
-b
k
-k 1024
-c
-l
-x
du
///mnt
#du abk /mnt
1
/mnt/cdrom
1
/mnt/floppy
17
3
/mnt
//
#du
3684
./log
84
./libnids-1.17/doc
720
./libnids-1.17/src
32
./libnids-1.17/samples
1064
./libnids-1.17
4944
.
1
2
du -s
#du s /mnt
3
/mnt
// a
b
#du ab /root/mail
6144
mail/sent-mail
1024
mail/saved-messages
8192
mail
3fdisk
fdisk
http://g.51cto.com/linuxops/
http://os.51cto.com/linux/
yangsai@51cto.com
Special
#fdisk /dev/had
///dev/had
Linux p
d
n
n
Command (m for help): n
Command action
e
extended
p
primary partition (1-4)
p
Partiton number(1-4):1
First cylinder(1-1023):1
Last cylinder or + size or +sizeK or
+ sizeM(1-1023):+258M
p e
Linux Native
Linux Swap FAT32
t
l
Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): 82
Changed system type of partition 1 to
82 (Linux swap)
w
q
http://os.51cto.com/art/201012/240726.htm
18
http://g.51cto.com/linuxops/
http://os.51cto.com/linux/
yangsai@51cto.com
Special
load average 0 10 20
Linux load
/
unix linux
load average 0
Unix/Linux load
10 20
load
load average 1
5 15
linux kernel
linux 2.6.36
/**
* spu_calc_load update the avenrun
load estimates.
*
* No locking against reading these
values from userspace, as for
19
Special
load
CPU load
load
Unix/Linux cpu
active_tasks
100% load
cpu
CPU
load
load cpu
IO cpu
cpu cpu
cpu
load 8 cpu
load 8 8 over
cpu
load
cpu
cpu
cpu
4 cpu
http://selboo.com.cn/post/885/
4 CPU.
Linux uptime
http://os.51cto.com/art/201005/200703.htm
Linux
http://os.51cto.com/art/201005/201618.htm
20
http://g.51cto.com/linuxops/
http://os.51cto.com/linux/
yangsai@51cto.com
Tips
expect
/Balakrishnan Mariyappan
/
expect
expect Expect
thegeekstuff.com
1 -c
expect
expect -c
expect
-c expect
expect
-i
linux expect
Linux
2-i expect
\n enter
pressed enter
21
expect
3 expect
-d
$ cat sample.exp
# !/usr/bin/expect -f
http://g.51cto.com/linuxops/
http://os.51cto.com/linux/
yangsai@51cto.com
Tips
expect "\n";
send "pressed enter";
$ expect -d sample.exp
expect version 5.43.0
argv[0] = expect argv[1] = -d argv[2]
= sample.exp
set argc 0
set argv0 "sample.exp"
set argv ""
executing commands from command file
sample.exp
expect: does "" (spawn_id exp0) match
glob pattern "\n"? no
expect: does "\n" (spawn_id exp0) match
glob pattern "\n"? yes
expect: set expect_out(0,string) "\n"
expect: set expect_out(spawn_id) "exp0"
expect: set expect_out(buffer) "\n"
send: sending "pressed enter" to { exp0
pressed enter}
4-D expect
-D
-D
expect
$ expect print_cmdline_args.exp -d -c
argv0 : -d
argv1 : -c
5 expect
expect
-b
expect
expect
$ expect -b
6 expect
expect
http://www.thegeekstuff.com/2010/12/5expect-script-command-line-argumentexamples/
http://os.51cto.com/art/201012/240260.htm
Hotmail
http://os.51cto.com/art/201101/242496.htm
Perl
http://os.51cto.com/art/201012/240483.htm
Linux Shell
http://os.51cto.com/art/201010/229129.htm
$ cat print_cmdline_args.exp
#!/usr/bin/expect
$ expect -D 1 script
puts 'argv0 : [lindex $argv 0]';
puts 'argv1 : [lindex $argv 1]';
22
http://g.51cto.com/linuxops/
http://os.51cto.com/linux/
yangsai@51cto.com
Tips
Linux iptables
SSH
loader
* da0s1x x
/boot
kernel
/boot/kernel
ok load kernel/kernel
FreeBSD
kernel
ok boot
Linux
FreeBSD 8.1
chinaunix
FreeBSD
2G For /
4G For swap
mount root>ufs:/dev/da0s1a
boot bsd
/boot
/boot FreeBSD
boot: 0:da(0,e)/loader
23
/boot Linux
2048M For /
4096M For swap
For /usr
http://g.51cto.com/linuxops/
http://os.51cto.com/linux/
yangsai@51cto.com
Tips
root
SSH
windows
2003
Linux /etc/fatab
passwd root
Emergency
crontab 5
root
mount o remount,rw /
Linux root
sudo
root
firestop.sh :
service iptables stop
root
ctrl+shift+F2 F3-F8
F1
SSH
Linux iptables
/
/etc/fatab#
sudoer root
FreeBSD 8.1
sudo
Emergency
Linux
RHEL5
Emergency
24
/etc/sudoer
.
sudoer sudo
root
FreeBSD8.1 Linux
root
http://g.51cto.com/linuxops/
http://os.51cto.com/linux/
yangsai@51cto.com
Tips
root
Linux/FreeBSD root
root
root
2
root
sudo
sudo root
root
jail 192.168.21.36
root shell bash
libintl.so.8 root
:w !sudo tee %
:w !sudo tee %
(
)
fsck -y
FreeBSD Debian (
root ) very nice.
mount -a
http://os.51cto.com/art/201101/241510.htm
root shell sh
chsh -s sh
FreeBSD Linux
http://os.51cto.com/art/201012/236797.htm
FreeBSD
su
http://os.51cto.com/art/201012/236729.htm
vi nginx.conf
Root
Permission
25
http://g.51cto.com/linuxops/
http://os.51cto.com/linux/
yangsai@51cto.com
Tips
cat
reset
:>file.txt :
B Linux Shell 2
bash
$touch
/Peteris Krumins
/BOY PT
file.txt touch
1.
vi
3. ssh
<ESC v>
ssh -N -L2001:remotehost:80
user@somemachine
<CTRL-x CTRL-
e> vim
~/.bashrc
$EDITOR
EDITOR=nano
mencoder/ffmpeg 34
readline
bash emacs
<CTRL-x CTRL-e>
export
fc
Fix Command
^foo^bar^
fc fc -s foo=bar
2.
> file.txt
> shell
26
2001
2001 somemachine
remotehost 80
3
somemachine
localhost
IP 80
ssh web
http://g.51cto.com/linuxops/
http://os.51cto.com/linux/
yangsai@51cto.com
Tips
IP
ssh -f -N -L
0.0.0.0:443:twitter.com:443
shell.cjb.net
ssh -f -N -L 0.0.0.0:80:twitter.com:80
shell.cjb.net
/etc/hosts 127.0.0.1
twitter.com
printf("\033c\033(K\033[J\033[0m\033[?
25h");
Shell
\033c: ESC c ;
\033(K: ESC ( K ;
\033[J: ESC [ J ;
\033[0m: ESC [ 0 m
;
\033[?25h: ESC [ ? 25 h ;
1G
fstab
/dev/shm
Firefox
FF
Shellex tmpfs Firefox
tmpfs
5.
Firefox II
4.
reset
cat
at cron
at
cron
at
reset
man at
reset
BusyBox reset
6.
mount -t tmpfs -o size=1024m tmpfs
/mnt/ram
27
http://www.catonmat.net/blog/top-ten-oneliners-from-commandlinefu-explained
http://www.isspy.com/most_useful_linux_com
mands_2/
http://g.51cto.com/linuxops/
http://os.51cto.com/linux/
yangsai@51cto.com
Linux
1
/
ahttp://g.51cto.com/linuxops
blinuxops-cn@googlegroups.com
cyangsai@51cto.com
2
Linux
1
linuxops-cn@googlegroups.com
2 51CTO Linux
http://os.51cto.com/linux/
IT
Linux
yangsai@51cto.com
3
Linux
yangsai@51cto.com
Linux 51CTO
Linux/Unix
Linux
51CTO
&
yangsai@51cto.com