類 Linux BASH shell (, VBird) 2008/03/29 Linux 1
Bash Shell 令 vi vim 料流 令 / 令 理 (job control) 例 2008/03/29 Linux 2
Bash shell 2008/03/29 Linux 3
什 Shell Shell shell 2008/03/29 Linux 4
什 Shell Linux shell Linux shell /etc/shells /bin/sh /bin/bash /sbin/nologin /bin/ksh /usr/bin/ksh /bin/tcsh /bin/csh /bin/zsh shell /bin/bash shell chsh s shellname 2008/03/29 Linux 5
Bash bash 令 力 類 DOS doskey 令 令 (alias) (jobs) Shell scripts 2008/03/29 Linux 6
Bash bash [Tab] [Tab] 串 令 令 [Tab] 串 令 [Ctrl]-c 行 [Ctrl]-d [Shift]-[Pageup]/[Shift]-[Pagedown] / 2008/03/29 Linux 7
Bash bash 數 數 數 = 數 數 數 數 = 來連 兩 不 數 數 數 不 來 數 來 數 \ 來 令 令 ` command` $(command) export 來 數 數 export PATH 數 unset 數 2008/03/29 Linux 8
Bash 數 / 數 echo $var echo ${var} 數 mkdir ~dmtsai 立 ~dmtsai 錄 echo $PATH PATH 數 kversion=$(uname r) kversion echo \$PATH $PATH set 數 2008/03/29 Linux 9
Bash bash 數 數 HOME MAIL HISTSIZE LANG PATH PS1 $? 錄 ~ 錄 mail ( ) history 錄 數 料 ( locale a) 令 行 錄 令 (man bash) shell PID 令 行 (0 ) 2008/03/29 Linux 10
Bash 數 數 shell shell 數 利 export 數 ( 數 ) shell ( 離 了 ) shell shell 數 數 2008/03/29 Linux 11
Bash bash 令 bash 令 cd, pwd echo jobs, fg, bg history type man cd ( ) 2008/03/29 Linux 12
Bash 歷 令 令 history [-n] history 錄 ~/.bash_history 令!!!vi!50!-5 2008/03/29 Linux 13
Bash 令 立 令 alias ll= ls al alias h=history unalias h 2008/03/29 Linux 14
Bash 令 行 若 令 ls, echo 路 / 路 行 令 (alias) bash 令 PATH 令 type a 令來 2008/03/29 Linux 15
Bash 參數 login-shell 讀 /etc/profile ~/.bash_profile, ~/.bash_login, ~/.profile non-login-shell bash 例 X bash 行 bash 行 script ~/.bashrc 不 立. ~/.bashrc source ~/.bashrc 2008/03/29 Linux 16
Bash 見 bash * 0? [a-c] [^a-c] 不 例 3 數 /etc/??? /etc/*[0-9]* /etc/*[[:upper:]]* 2008/03/29 Linux 17
Bash 切 bash 量不 root 不 切 su root su ( root ) 離 su - exit 來 切 su username 行 root 不 2008/03/29 Linux 18
令 2008/03/29 Linux 19
來 令 cat tac nl more less head tail od 行 行 行 more 類 行 行 讀 2008/03/29 Linux 20
cat nl 2008/03/29 Linux 21
head tail tail +5 /etc/man.config 行 料 來 tail f /var/log/messages 2008/03/29 Linux 22
2008/03/29 Linux 23
vi vim 2008/03/29 Linux 24
vi vim vi 什 vi vim vi Unix like vi 例 crontab vim vi vim 2008/03/29 Linux 25
vi vim vi 1G k ^ h l $ j G 離 ZZ 行 行 dd yy Pp 串 x X dw 復 u. [ctrl]-r 兩行 J / nn v y p d I i a A O o R r : [ESC] 令 離 利 :w :w! :q :q! :wq! :sp newfile, [ctrl]-w +s, [ctrl] +v [esc] :set :n1,n2s/old/new/g[c] 2008/03/29 Linux 26
vi vim vim vim :set nu ( 行 ) :set autoindent( ) :set textwidth=80( 行 ) :set hlsearch( 亮度 ) :syntax {on off}( ) ~/.vimrc 2008/03/29 Linux 27
料流 2008/03/29 Linux 28
料流 令 令 行 料 料 Standard Output (STDOUT) 料 Standard Error Output(STDERR) 令 讀 料 料 Standard Input 來 2008/03/29 Linux 29
料流 STDOUT STDERR >, >> STDOUT / 2>, 2>> STDERR / < 讀 料 2008/03/29 Linux 30
料流 例 > 2> 料 list_right list_error 不 2008/03/29 Linux 31
料流 (/dev/null) 不 2>&1 2008/03/29 Linux 32
料流 <<keyword 來 2008/03/29 Linux 33
料流 料流 來 行 不 例行 令 例 /etc/crontab 行 來 行 令 2> /dev/null 2008/03/29 Linux 34
料流 連 令 行 令 cmd1 ; cmd2 ; cmd3 令 0 行 cmd1 && cmd2 令 0 行 cmd1 cmd2 理 cmd1 && cmd2 cmd3 2008/03/29 Linux 35
令 2008/03/29 Linux 36
令 令 令 理來 令 STDOUT 不 理 STDERR cat, more, less 令 ls, cp 令 2008/03/29 Linux 37
令 cut 2008/03/29 Linux 38
令 grep 2008/03/29 Linux 39
令 sort 2008/03/29 Linux 40
令 uniq wc 2008/03/29 Linux 41
令 tee 2008/03/29 Linux 42
令 參數 xargs 令 令 讀 STDOUT 參數 (argument) 2008/03/29 Linux 43
/ 令 2008/03/29 Linux 44
/ 令 令 令 來 令 type command ex> type a echo PATH 令 which command 2008/03/29 Linux 45
/ 令 料 料 updatedb 料 /var/lib/slocate locate keyword locate r { } man page makewhatis 立 料 whatis keyword keyword man page 2008/03/29 Linux 46
/ 令 find 令 find [ 錄 ] [ 類 ] [ ] 例 24 更 (mtime) 列 [root@linux ~]# find / -mtime 0 /etc /etc/passwd 列 [root@linux ~]# find /etc -newer /etc/passwd /home dmtsai [root@linux ~]# find /home -user dmtsai passwd [root@linux ~]# find / -name passwd 1MB [root@linux ~]# find / -size +1000k 2008/03/29 Linux 47
2008/03/29 Linux 48
來 行 行 理 令 grep sed awk 2008/03/29 Linux 49
2008/03/29 Linux 50
理 (job control) 2008/03/29 Linux 51
理 (job control) Job control command & 行 jobs fg %n n bg %n n 行 kill %n n [ctrl]-z 2008/03/29 Linux 52
例 2008/03/29 Linux 53
bash && 什 例 ls foo cd /tmp; ls&& cd /tmp AB (A) 令若 行 令 不 行 令 行 令 行 (B) 令若 行 令 行 令 行 令 不 行 (C) 令若 行 令 行 令 行 令 不 行 (D) 令若 行 令 不 行 令 行 令 不 行 2008/03/29 Linux 54
Linux shell 列 ABD (A) alias (B) <tab> 令 (C) 令 ls /? (D) history 歷 令 便 令串 cat n < test1 > test2 D (A) test1 test2 (B) test1 test2 (C) test2 test1 (D) test1 列 test2 2008/03/29 Linux 55
令 cat /etc/passwd grep vincent B (A) 列 /etc/passwd (B) /etc/passwd vincent 串 列 (C) 列 /etc/passwd vincent 串 (D) vincent 串 su 令 AB (A) 切 (B) 切 切 root (C) 切 若 切 行 su 令 行切 (D) 論 若 切 切 利切 2008/03/29 Linux 56
program1 tee /tmp/logfile A (A) 行 /tmp/logfile (B) 行 (C) /tmp/logfile (D) 令 program tee > /tmp/logfile 令 列 /etc 錄 AB (A) ls lr /etc (B) find /etc -print (C) dump R /etc (D) search l /etc 2008/03/29 Linux 57
david 行 cd ~david C (A) 切 錄 david $HOME 錄 (B) 切 錄 ~david 錄 (C) 切 錄 ~david 錄 (D) 切 錄 david 錄 列 令行 錄 ( 不 錄 ) 連 A (A) ls l grep ^l awk {print $NF} (B) ls type l (C) find type l (D) ls -ll 2008/03/29 Linux 58
錄 1 2 列 令 2 B (A) /bin/false echo $? xargs ls (B) /bin/false echo $? xargs cat (C) /bin/false xargs echo (D) /bin/false xargs cat 數 兩 數 (Global) 數 (Local) 列 ACD (A) Global 數 Local 不行 (B) local 數 env (C) local 數 global export 令 (D) 令 set local global 數 2008/03/29 Linux 59
find / -name java* > msg1 2>msg2 列 C (A) 令 錄 java (B) 令 行 了 兩 (C) 令 行 msg1 行 msg2 (D) msg2 /home/peter/ibm_java 串 2008/03/29 Linux 60
bash [ctrl]-z 什 A (A) 令 (B) 令 (C) (D) 復 2008/03/29 Linux 61