Title: ??Linux?? Author:Lyn.ma@hotmail.com
1??Linux??AuthorLyn.ma_at_hotmail.com
2????? shell??
- ????Shell
- ---Bourne shell(sh)
- ---C shell(csh)
- ---Kom shell(ksh)
- ---Bourne Again shell(bash) ??????
3??????????
- ??reboot??
- ??shutdown -k
- shutdown -r Time
- shutdown -h Time
- shutdown c
- ??ls a ????????,??????
- ls l ????????????
- ls F ?????????????????,,/
- ??cd?mkdir?rmdir?cp?rm?mv?
- ??cat ?? ???????????ASCII????
- cat text
- cat file1 file2
- cat file1 file2 gtfile3
- ??more ??
4??????????
- ??useradd
- ??useradd ???
- ????
- useradd ??? g ?? G ?? d Home??? p ??
- ?useradd oracle g oinstall G dba d
/Home/oracle ora1234 - ??userdel?groupadd?groupdel?password
- userdel ???? groupadd ???? groupdel
??? - password? password ???
- ??su??
- ??????????????????????
- su ???
- ??chmod??
- ?????????????????
- ? chmod rx text
- chmod urwx,gr,o text
5?????????
- ??ps??
- ps
- ps e ????????????
- ps ef ???? ps ef grep oracle
- ps el ???
- ??top ??????
- ??kill ????
- kill -s ?? ???
- kill l ??????
- ??cron????
- cron -l
6???????????
- ??df??
- ???????????????,????-k
- df k
- ??mount ?umount
- ??mount?? ?? ??
- -a ?/etc/fstab?????????????
- ?mount /mnt/cdrom ????
- mount /mnt/floppy ????
- umount ???????? ????
- ????umount -f directory
- ?umount f /mnt/cdrom ????
7??????
- ??tar??
- ?
- tar czf oracle.tar.gz /u01/app/oracle
/etc/oracle /home/oracle - tar tzf oracle.tar.gz
- tar xzvf oracle.tar.gz
- ??rpm??(RPM Redhat Package Manager)
- 1.?? rpm I tomcat.rpm
- 2.?? rpm U tomcat.rpm
- 3.????????? rpm qa grep tomcat rpm
qf filename - rpm qi packagename
- 4.?????????
- rpm e packagename
-
8????/??????
1.Cat?? 2.Vi?? 3.Head /Tail??
9????/??????
1.Cat?? ???????? ??Dos??Type cat file1 cat
file1 file2 cat n file1 ????
10????/??????
2.vi?? ?Visual Interface??? ?????????Dos??Edit
????????,??,??,??? ???????? ????? i ,a, o,
c, u, d, r,s, dd, dx, w,Esc, q,q!, qw,
h,j,k,l ???? ????,???Esc,???,?????? ????
vi example.txt vi n example.txt set number
(??nu)????
11????/??????
2.1 Vi ?????? h j k l h
????????n,????n?? j ????????n,????n??
k ????????n,????n?? l ????????n,????n??
0 ? ??????? - ??????? H ????? L
????? CtrlG ????????? M
?????? n ?????????n? nG ????n?
???????????? w/W ??????????
b/B???????? e/E????????
12????/??????
2.2 Vi ?????? 1.??(Insert)?? i?I
2.??(append)?? a?A 3.??(Open)?? o?O 2.3 Vi
?????? 1.?????? x?X 2.??????
dd?D,d,d0,dw 3.?????? yy p 4.??????
u U 5.?????? . 6.????????? / ?
13????/??????
3.Head ?tail ?????????? ? head exeample.txt
?????? head n 20 example.txt??????? tail
example.txt????? tail n 20 example.txt????????
head -f example.txt?????,??????????????????
14??????
1.?????? ifconfig ?route 2.??????
netstat/nslookup/host/finger/Ping 3.?????????? 4.?
??????? ftp/telnet/ r-????
15??????
1.?????? ifconfig ?route ifconfig eth0
192.168.0.1 ???????????192.168.0.1 ifconfig
eht0 down/up ??/??????? ifconfig eth0 netmask
255.255.255.0 ???????????? ifconfig eth0
??eth0 ?? ??ifconfig ifconfig s ????????
route add net 192.168.0.0 netmask 255.255.255.0
dev eth0 ??????? route add 0.0.0.0 gw ????
route del 0.0.0.0 gw ????
16??????
2.?????? netstat/nslookup/host/finger/Ping
netstat a c -I n -r t u -v nslookup /
Exit host a ?host baidu.com finger root
ping c count IPAddress
17??????
3.?????????? /etc/sysconfig /network ??????
/etc/hosts IP???????? service network restart
/etc/services ????????????? /etc/ resolv.conf
DNS???? /etc/ host.conf ??????? /etc/
nsswitch.conf ??????? ?????????,??Sun?????
/etc/xinetd.conf ?inetd??? /etc/ module.conf
???????????????? /etc/ sysconfig/network-scripts
/ ifcfg-ethN ????????
18??????
4.???????? ftp/telnet/ r-???? ftp IP??????? ls
cd lcd ascii binary(Bin) close hash get mget put
mput quit ? ! telnet IP??????? rlogin host
rlogin host command
19??????
- ????????????????
- /sbin/hwclock --show
- /sbin/hwclock --hctosys
- /sbin/hwclock --systochc
- 2. ???????????
- /proc/cpuinfo meminfo modules mounts
- df k ????KB???????????
- df a ??????,?????0???
- df T ??????Ext2??Ext3?
- du b /home ????????/home??????????
- du -ks /home ?????????/home??????
- top d 1 ??Top???????? ??,M,N,P ,c,? ,q
20??????
2. ??????????? iostat c ??CPU?????????
iostat d ??????????????? iostat d 2
???????????????,2????? 3.??/????tar tar czf
tmp.tar.gz /tmp ??/tmp?? tar xzf tmp.tar.gz
C /home ???/home???? tar t tmp.tar.gz
??gz????? 4.?????????? find . name 1.txt
????????? find /tmp name 1.txt ????
grep cams test.txt ???? grep r cams
/cams/test.txt ??????????????? ps ef grep
ora
21??????
5.???????? ????????????? /etc/ rc.d /
init.d??? service cams stop/start ??/????
???? 1???????/etc/ rc.d /
init.d?????,???????? 2????chkconfig??????????
chkconfig add camsd ???? 1chkconfig del
camsd ???????? chkconfig level 35
camsd on chkconfig level 35 camsd off
chkconfig list camsd ???????????
22Apt-get????
- ??
- apt-get ?? ??
- apt-get ?? installremove pkg1 pkg2 ...
- apt-get ?? source pkg1 pkg2 ...
- apt-get ???????????????????
- ???????update(??)?install(??)?
- ??
- update - ????????? upgrade - ????
install - ???????(pkg ? libc6 ??? libc6.deb)
remove - ????? autoremove - ?????????????
purge - ?????????? source - ?????? build-dep
- ?????????? dist-upgrade - ?????, ??
apt-get(8) dselect-upgrade - ?? dselect ?????
clean - ????????? autoclean - ?????????????
check - ?????????? - ??
- -h ?????? -q ????? - ????? -qq ?????,????
-d ??? - ?????????? -s ???????????? -y
??????????,??? -f ??????????? -m ????????,????
-u ???????????? -b ???????? -V ???????? -c?
??????? -o? ?????????,? -o dircache/tmp
23GCC ??
gcc help man gcc gcc p g test.c
???test.c????profile?????????????????? gcc pg
test.c ??gprof???????? gcc test.c ??a.out?? gcc
-o count conut.c ???????count?????? -c
?????????????????????????? -S ???????????????,????
??.s -E ????????????????,????????????????????????
-o -O2 ???????,??????,??????,??????,???????? -g
??GCC????GNU??????????????????
24GDB ??
gdb h file ?????? Kill ????????? List
??????? Next ??????,??????? Step??????,?????? Run
??????????,?run?watch Quit ??gdb Watch
???????????????? watch Mastering Print
??????? Break ????,???? break 26 Make
???gdb??,?????????????? Shell ???gdb??,?????UNIX
shell
25GDB ??
gdb h ?????core??,???gdb hello
core????????? gcc gp -o test test.c Gprof ???
gt???????????????????????
????????????,??????????????
26Makefile??
??Target components ????/????,????????,???? ??TA
B rule
Main main.o file1.o file2.o Gcc o _at_
????,?????? Main.o main.c file1.h file2.h Gcc c
lt ??????? File1.o file1.c file1.h Gcc c
lt File2.o file2.c file1.h Gcc c lt
Main main.o file1.o file2.o Gcc o main main.o
file1.o ifle2.o Main.o main.c file1.h
file2.h Gcc c main.c File1.o file1.c
file1.h Gcc c file1.c File2.o file2.c
file1.h Gcc c file2.c
??
??
Main main.o file1.o file2.o Gcc o _at_
????,?????? ..c.o ???o???????c?? Gcc c lt
27