Chapter 3 3 Linux Linux 106
Chapter 3 1 Linux Part 1 107
Part Example> [root@kugstone /etc]# shutdown - Usage: shutdown [-akrhfnc] [-t secs] time [warning message] -a: use /etc/shutdown.allow -k: don t really shutdown, only warn. -r: reboot after shutdown. -h: halt after shutdown. -f: do a fast reboot (skip fsck). -F: Force fsck on reboot. -n: do not go through init but go down real fast. -c: cancel a running shutdown. -t secs: delay between warning and kill signal. ** the time argument is mandatory! (try now ) ** [root@kugstone /etc]# shutdown -k -t 120 disk replacing job 108
Chapter 3 Part 1 [root@kugstone /etc]# cat /etc/inittab # # inittab This file describes how the INIT process should set up # the system in a certain run-level. # # Author: Miquel van Smoorenburg, <miquels@drinkel.nl. mugnet.org> # Modified for RHS Linux by Marc Ewing and Donnie Barnes # # Default runlevel. The runlevels used by RHS are: # 0 - halt (Do NOT set initdefault to this) # 1 - Single user mode # 2 - Multiuser, without NFS (The same as 3, if you do not have networking) # 3 - Full multiuser mode # 4 - unused # 5 - X11 # 6 - reboot (Do NOT set initdefault to this) # id:5:initdefault: # System initialization. 109
Part si::sysinit:/etc/rc.d/rc.sysinit l0:0:wait:/etc/rc.d/rc 0 l1:1:wait:/etc/rc.d/rc 1 l2:2:wait:/etc/rc.d/rc 2 l3:3:wait:/etc/rc.d/rc 3 l4:4:wait:/etc/rc.d/rc 4 l5:5:wait:/etc/rc.d/rc 5 l6:6:wait:/etc/rc.d/rc 6 # Things to run in every runlevel. ud::once:/sbin/update # Trap CTRL-ALT-DELETE ca::ctrlaltdel:/sbin/shutdown -t3 -r now # When our UPS tells us power has failed, assume we have a few minutes # of power left. Schedule a shutdown for 2 minutes from now. # This does, of course, assume you have powerd installed and your # UPS connected and working correctly. pf::powerfail:/sbin/shutdown -f -h +2 Power Failure; System Shutting Down # If power was restored before the shutdown kicked in, cancel it. pr:12345:powerokwait:/sbin/shutdown -c Power Restored; Shutdown Cancelled # Run gettys in standard runlevels 1:2345:respawn:/sbin/mingetty tty1 2:2345:respawn:/sbin/mingetty tty2 3:2345:respawn:/sbin/mingetty tty3 4:2345:respawn:/sbin/mingetty tty4 5:2345:respawn:/sbin/mingetty tty5 6:2345:respawn:/sbin/mingetty tty6 # Run xdm in runlevel 5 # xdm is now a separate service x:5:respawn:/etc/x11/prefdm -nodaemon [root@kugstone /etc]# 110
Chapter 3 [root@kugstone /etc]# shutdown -y -i6 Part 1 2 Linux [kugstone@kugstone /]$ rm -r /tmp rm: remove write-protected file /tmp/install.log? y rm: cannot unlink /tmp/install.log : Operation not permitted rm: directory /tmp/.mozilla is write protected; descend into it anyway? y rm: cannot change to directory /tmp/.mozilla : Permission denied rm: directory /tmp/.gnome is write protected; descend into it anyway? y rm: cannot change to directory /tmp/.gnome : Permission denied rm: directory /tmp/.gnome_private is write protected; descend into it anyway? ~ ~ 111
Part [root@kugstone /etc]# su root password: [root@kugstone /etc]# T I P [root@kugstone /etc]# cat /etc/passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin: daemon:x:2:2:daemon:/sbin: adm:x:3:4:adm:/var/adm: lp:x:4:7:lp:/var/spool/lpd: sync:x:5:0:sync:/sbin:/bin/sync ~ ~ kugstone:x:500:500::/home/kugstone:/bin/bash [root@kugstone /etc]# [root@kugstone /etc]# cat /etc/passwd grep kugstone 112
Chapter 3 kugstone:x:500:500::/home/kugstone:/bin/bash [root@kugstone /etc]# Part 1 [root@kugstone /etc]# cat /etc/group root:x:0:root bin:x:1:root,bin,daemon ~ ~ kugstone:x:500: [root@kugstone /etc]# 113
Part 114
Chapter 3 [root@kugstone /etc]# useradd -D # GROUP=100 HOME=/home INACTIVE=-1 EXPIRE= SHELL=/bin/bash SKEL=/etc/skel [root@kugstone /etc]# useradd kug -d /home/kug # [root@kugstone /etc]# ls -al /home total 60 drwxr-xr-x 15 root root 44096 Apr 8 13:50. drwxr-xr-x 20 root root 44096 Apr 8 11:18.. drwxr-xr-x 2 root root 44096 Apr 28 2001 acrobat4 drwxr-xr-x 2 root root 4096 Apr 28 2001 hanterm drwx------ 4 kug kug 4096 Apr 8 13:50 kug # drwx------ 12 kugstone kugstone 4096 Apr 4 00:40 kugstone ~ [root@kugstone /etc]# cat /etc/passwd grep kug kugstone:x:500:500::/home/kugstone:/bin/bash kug:x:501:501::/home/kug:/bin/bash [root@kugstone /etc]# cat /etc/group grep kug kugstone:x:500: kug:x:501: [root@kugstone /etc]# Part 1 [root@kugstone /etc]# userdel kug [root@kugstone /etc]# userdel kug userdel: user kug does not exist [root@kugstone /etc]# # 115
Part 3 Linux [root@kugstone kugstone]# pwd /home/kugstone [root@kugstone kugstone]# # 116
Chapter 3 Part 1 117
Part [kugstone@kugstone bin]$ pwd # /usr/bin [kugstone@kugstone bin]$ cd $HOME # [kugstone@kugstone kugstone]$ pwd /home/kugstone [kugstone@kugstone kugstone]$ [kugstone@kugstone kugstone]$ cd $HOME/test [kugstone@kugstone test]$ pwd /home/kugstone/test [kugstone@kugstone test]$ 118
Chapter 3 Part 1 [kugstone@kugstone kugstone]$ mkdir -v test # mkdir: created directory test [kugstone@kugstone kugstone]$ mkdir test # mkdir: cannot create directory test : File exists [kugstone@kugstone kugstone]$ mkdir -p test # [kugstone@kugstone kugstone]$ [kugstone@kugstone /]$ pwd / [kugstone@kugstone /]$ mkdir $HOME/imsi # [kugstone@kugstone /]$ cd $HOME/imsi [kugstone@kugstone imsi]$ pwd /home/kugstone/imsi [kugstone@kugstone imsi]$ 119
Part T I P [root@kugstone wongo]# pwd /home/wongo [root@kugstone wongo]# cd example [root@kugstone example]# cd.. [root@kugstone wongo]# cd $HOME [root@kugstone /root]# pwd /root [root@kugstone /root]# 120
Chapter 3 Part 1 [root@kugstone imsi]# ls temp1 temp2 temp3 temp4 [root@kugstone imsi]# mv temp1 temp2 [root@kugstone imsi]# cd temp2 [root@kugstone temp2]# ls temp1 [root@kugstone temp2]# ls aa bb cc dd ee temp1 [root@kugstone imsi]# mv -b aa temp2 mv: overwrite temp2/aa? y [root@kugstone imsi]# ls bb temp2 temp3 temp4 [root@kugstone imsi]# cd temp2 [root@kugstone temp2]# ls aa aa~ bb cc dd ee temp1 [root@kugstone imsi]# cd temp2 [root@kugstone temp2]# ls aa aa~ bb cc dd ee temp1 [root@kugstone temp2]# cd.. [root@kugstone imsi]# mv -i bb temp2 mv: overwrite temp2/bb? y [root@kugstone imsi]# mv -f cc temp2 # # # -b aa~ # # 121
Part [root@kugstone /root]# pwd /root [root@kugstone /root]# cat.bashrc #.bashrc # User specific aliases and functions alias rm= rm -i alias cp= cp -i alias mv= mv -i # mv # Source global definitions if [ -f /etc/bashrc ]; then. /etc/bashrc fi [root@kugstone /root]# 122
Chapter 3 [root@kugstone imsi]# rmdir -v temp3 # rmdir: removing directory, temp3 [root@kugstone imsi]# pwd /home/wongo/imsi [root@kugstone imsi]# rmdir -pv temp1/temp2 # rmdir: removing directory, temp1/temp2 rmdir: removing directory, temp1 [root@kugstone imsi]# Part 1 4 Linux 123
Part [root@kugstone imsi]# date Mon Apr 9 13:04:28 EDT 2001 [root@kugstone imsi]# touch aa [root@kugstone imsi]# ls -al aa -rw-r--r-- 1 root root 0 Apr 9 13:04 aa [root@kugstone imsi]# touch -m aa [root@kugstone imsi]# ls -al aa -rw-r--r-- 1 root root 0 Apr 9 13:06 aa [root@kugstone imsi]# T I P [root@kugstone imsi]# cat -b aa # 1test of line 124
Chapter 3 2cat is very beautiful [root@kugstone imsi]# cat -e aa # $ test of line$ cat is very beautiful$ [root@kugstone imsi]# Part 1 [root@kugstone imsi]# cat > bb its my program [1]+ Stopped cat >bb [root@kugstone imsi]# cat bb its my program [root@kugstone imsi]# cat bb >cc [root@kugstone imsi]# cat cc its my program [root@kugstone imsi]# cat bb >>cc [root@kugstone imsi]# cat cc its my program its my program [root@kugstone imsi]# # (^z) # # # 125
Part [root@kugstone imsi]# ls -l total 8 -rw-r--r-- 1 root root 35 Apr 9 13:45 aa -rw-r--r-- 1 root root 35 Apr 9 13:45 bb [root@kugstone imsi]# cp -i aa bb # cp: overwrite bb? y [root@kugstone imsi]# ls -l total 8 -rw-r--r-- 1 root root 35 Apr 9 13:45 aa -rw-r--r-- 1 root root 35 Apr 9 16:50 bb [root@kugstone imsi]# cp -p aa bb # cp: overwrite bb? y [root@kugstone imsi]# ls -l total 8 -rw-r--r-- 1 root root 35 Apr 9 13:45 aa -rw-r--r-- 1 root root 35 Apr 9 13:45 bb [root@kugstone imsi]# 126
Chapter 3 Part 1 [root@kugstone imsi]# ls -l total 4 -rw-r--r-- 1 root root 0 Apr 9 17:00 aa -rw-r--r-- 1 root root 0 Apr 9 17:00 bb -rw-r--r-- 1 root root 0 Apr 9 17:00 cc drwxr-xr-x 2 root root 4096 Apr 9 17:00 temp [root@kugstone imsi]# rm aa [root@kugstone imsi]# ls bb cc temp [root@kugstone imsi]# rm -i bb rm: remove bb? y [root@kugstone imsi]# ls cc temp [root@kugstone imsi]# rm temp rm: temp is a directory [root@kugstone imsi]# rm -r temp [root@kugstone imsi]# ls cc [root@kugstone imsi]# 127
Part Most commands optionally preceded by integer argument k. Defaults in brackets. Star (*) indicates argument becomes new default. ------------------------------------------------------------------- <space> Display next k lines of text [current screen size] z Display next k lines of text [current screen size]* <return> Display next k lines of text [1]* d or ctrl-d Scroll k lines [current scroll size, initially 11]* q or Q or <interrupt> Exit from more s Skip forward k lines of text [1] f Skip forward k screenfuls of text [1] b or ctrl-b Skip backwards k screenfuls of text [1] Go to place where previous search started = Display current line number /<regular expression> Search for kth occurrence of regular expression [1] n Search for kth occurrence of last r.e [1] 128
Chapter 3!<cmd> or :!<cmd> Execute <cmd> in a subshell v Start up /usr/bin/vi at current line ctrl-l Redraw screen :n Go to kth next file [1] :p Go to kth previous file [1] :f Display current file name and line number. Repeat previous command ------------------------------------------------------------------- --More--(17%) Part 1 [root@kugstone example]# man more more +7 # 7 SYNOPSIS more [-dlfpcsu] [-num] [+/ pattern] [+ linenum] [file...] DESCRIPTION ~ ~ [root@kugstone example]# man more more +/Command...skipping Command line options are described below. Options are also taken from the environment variable MORE (make sure to precede them with a dash ( - )) but command line options will override them. [root@kugstone example]# 129
Part [root@kugstone example]# cat sample.c #include <stdio.h> main() { printf( Hello World\n ); } [root@kugstone example]# head -1 sample.c #include <stdio.h> [root@kugstone example]# head sample.c #include <stdio.h> main() { printf( Hello World\n ); } [root@kugstone example]# tail -2 sample.c printf( Hello World\n ); } [root@kugstone example]# # 1 # 10 # 2 [root@kugstone example]# tail -f sample.c #include <stdio.h> main() { # 130
Chapter 3 printf( Hello World\n ); } add first line... add seconf line... # Part 1 cat name.txt 1 kug jkyoung wan 302-9278 KOREA 2 KUG ji su 506-0988 USA 3 kang yan jung 123-5678 CHINA 4 li youn ju 444-4444 ENGLAND 5 chi nam su 457-9800 TILAND 6 am bi ju 566-0099 ITALY sort name.txt 1 kug jkyoung wan 302-9278 KOREA 2 KUG ji su 506-0988 USA 3 kang yan jung 123-5678 CHINA 4 li youn ju 444-4444 ENGLAND 5 chi nam su 457-9800 TILAND 6 am bi ju 566-0099 ITALY sort -r name.txt 6 am bi ju 566-0099 ITALY 5 chi nam su 457-9800 TILAND 4 li youn ju 444-4444 ENGLAND 3 kang yan jung 123-5678 CHINA 2 KUG ji su 506-0988 USA 1 kug jkyoung wan 302-9278 KOREA # # 131
Part cat name.txt 1 kug jkyoung wan 302-9278 KOREA 2 KUG ji su 506-0988 USA 3 kang yan jung 123-5678 CHINA 4 li youn ju 444-4444 ENGLAND 5 5_chi nam su 457-9800 TILAND 6 am bi ju 566-0099 ITALY 7 4_am bi ju 566-0099 ITALY sort +1-2 name.txt 7 4_am bi ju 566-0099 ITALY 5 5_chi nam su 457-9800 TILAND 6 am bi ju 566-0099 ITALY 3 kang yan jung 123-5678 CHINA 1 kug jkyoung wan 302-9278 KOREA 2 KUG ji su 506-0988 USA 4 li youn ju 444-4444 ENGLAND cat /etc/passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin: daemon:x:2:2:daemon:/sbin: 132
Chapter 3 adm:x:3:4:adm:/var/adm: lp:x:4:7:lp:/var/spool/lpd: sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/var/spool/mail: ~ ~ sort -t: +0-1 /etc/passwd adm:x:3:4:adm:/var/adm: amanda:x:33:6:amanda user:/var/lib/amanda:/bin/bash apache:x:48:48:apache:/var/www:/bin/false bin:x:1:1:bin:/bin: daemon:x:2:2:daemon:/sbin: ftp:x:14:50:ftp User:/var/ftp: games:x:12:100:games:/usr/games: gdm:x:42:42::/home/gdm:/bin/bash gopher:x:13:30:gopher:/usr/lib/gopher-data: Part 1 sort name.txt>a sort name.txt>b sort -m a b >c cat c 1 kug jkyoung wan 302-9278 KOREA 1 kug jkyoung wan 302-9278 KOREA 2 KUG ji su 506-0988 USA 2 KUG ji su 506-0988 USA 3 kang yan jung 123-5678 CHINA 3 kang yan jung 123-5678 CHINA 4 li youn ju 444-4444 ENGLAND 4 li youn ju 444-4444 ENGLAND 5 5_chi nam su 457-9800 TILAND 5 5_chi nam su 457-9800 TILAND 6 am bi ju 566-0099 ITALY 133
Part 6 am bi ju 566-0099 ITALY 7 4_am bi ju 566-0099 ITALY 7 4_am bi ju 566-0099 ITALY sort -u c 1 kug jkyoung wan 302-9278 KOREA 2 KUG ji su 506-0988 USA 3 kang yan jung 123-5678 CHINA 4 li youn ju 444-4444 ENGLAND 5 5_chi nam su 457-9800 TILAND 6 am bi ju 566-0099 ITALY 7 4_am bi ju 566-0099 ITALY 134
Chapter 3 cat name.tmp # Tug jkyoung wan 302-9278 KOREA KUG ji su 506-0988 USA am bi ju 566-0099 ITALY cat name.txt # 1 kug jkyoung wan 302-9278 KOREA 2 KUG ji su 506-0988 USA 3 kang yan jung 123-5678 CHINA 4 li youn ju 444-4444 ENGLAND 5 5_chi nam su 457-9800 TILAND 6 am bi ju 566-0099 ITALY 7 4_am bi ju 566-0099 ITALY diff name.tmp name.txt # 1,4c1,7 < Tug jkyoung wan 302-9278 KOREA < < KUG ji su 506-0988 USA < am bi ju 566-0099 ITALY --- > 1 kug jkyoung wan 302-9278 KOREA > 2 KUG ji su 506-0988 USA > 3 kang yan jung 123-5678 CHINA > 4 li youn ju 444-4444 ENGLAND > 5 5_chi nam su 457-9800 TILAND > 6 am bi ju 566-0099 ITALY > 7 4_am bi ju 566-0099 ITALY Part 1 135
Part cmp name.tmp name.txt name.tmp name.txt differ: char 1, line 1 cmp -l name.tmp name.txt 1 124 61 2 165 40 3 147 153 4 40 165 5 152 147 6 153 40 7 171 152 8 157 153 ~ comm name.tmp name.txt 1 kug jkyoung wan 302-9278 KOREA 2 KUG ji su 506-0988 USA 3 kang yan jung 123-5678 CHINA 4 li youn ju 444-4444 ENGLAND 5 5_chi nam su 457-9800 TILAND 6 am bi ju 566-0099 ITALY 7 4_am bi ju 566-0099 ITALY Tug jkyoung wan 302-9278 KOREA KUG ji su 506-0988 USA am bi ju 566-0099 ITALY 136
Chapter 3 Part 1 comm -2 name.tmp name.txt # 1, 3 Tug jkyoung wan 302-9278 KOREA KUG ji su 506-0988 USA am bi ju 566-0099 ITALY find. -name *.txt -print./name.txt 137
Part find / -name *.txt -print -depth find: /proc/1390/fd: No such file or directory /var/mars_nwe/sys/readme.txt /var/www/icons/small/readme.txt /etc/squid/mib.txt /etc/tripwire/twcfg.txt /etc/tripwire/twpol.txt /usr/share/doc/html/en/kppp/ttys-cua.txt ~ ~ T I P ls -l total 36 drwxr-xr-x 2 root root 4096 Mar 25 20:33 imsi -rw-r--r-- 1 root root 92 Mar 25 21:19 name.tmp -rw-r--r-- 1 root root 232 Mar 25 21:08 name.txt -rw-r--r-- 1 root root 84 Mar 25 20:33 sample.c find. -size +20 -print find. -size +1 -print../imsi 138
Chapter 3 find. -size -1 -print Part 1 ls -l total 16 drwxr-xr-x 2 root root 4096 Mar 25 20:33 imsi -rw-r--r-- 1 root root 92 Mar 25 21:19 name.tmp -rw-r--r-- 1 root root 232 Mar 25 21:08 name.txt -rw-r--r-- 1 root root 84 Mar 25 20:33 sample.c date Wed Apr 25 21:34:58 KST 2001 find. -mtime 31 -print../name.tmp./name.txt./imsi./sample.c find. -name *.txt -print -exec cat {} \;./name.txt 1 kug jkyoung wan 302-9278 KOREA 2 KUG ji su 506-0988 USA 3 kang yan jung 123-5678 CHINA 4 li youn ju 444-4444 ENGLAND 5 5_chi nam su 457-9800 TILAND 6 am bi ju 566-0099 ITALY 7 4_am bi ju 566-0099 ITALY./sample.txt 139
Part #include<stdio.h> main() { printf( Hello World!!\n ); } find. -name *.txt -print -ok rm {} \;./name.txt < rm..../name.txt >? n./sample.txt < rm..../sample.txt >? n find. \( -name *.c -o -name *.txt \) - 140
Chapter 3 print./name.txt./sample.c./sample.txt Part 1 ls imsi name.tmp name.txt sample.c sample.txt cat name.txt 1 kug jkyoung wan 302-9278 KOREA 2 KUG ji su 506-0988 USA 3 kang yan jung 123-5678 CHINA 4 li youn ju 444-4444 ENGLAND 5 5_chi nam su 457-9800 TILAND 6 am bi ju 566-0099 ITALY 7 4_am bi ju 566-0099 ITALY split -3 name.txt # 3 ls x* xaa xab xac # cat xaa 141
Part 1 kug jkyoung wan 302-9278 KOREA 2 KUG ji su 506-0988 USA 3 kang yan jung 123-5678 CHINA compress name.txt ls -al name* -rw-r--r-- 1 root root 92 Mar 25 21:19 name.tmp -rw-r--r-- 1 root root 188 Mar 25 21:08 name.txt.z uncompress name.txt.z compress * 142
Chapter 3 ls *.Z name.tmp.z name.txt.z sample.c.z sample.txt.z xaa.z xab.z uncompress * ls imsi name.tmp name.txt sample.c sample.txt xaa xab xac Part 1 compress sample.txt ls -al sam* -rw-r--r-- 1 root root 84 Mar 25 20:33 sample.c -rw-r--r-- 1 root root 73 Apr 25 21:35 sample.txt.z zcat sample.txt.z #include<stdio.h> main() { printf( Hello World!!\n ); } cat sample.c #include<stdio.h> main() { printf( Hello World!!\n ); 143
Part } wc sample.c 5 6 58 sample.c # ls a.out imsi name.tmp name.txt sample.c sample.txt.z ls wc -l # 6 144
Chapter 3 cat cut.txt first second third cut -c1-3 cut.txt # 1-3 fir cut -f1 cut.txt # first Part 1 cat /etc/passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin: daemon:x:2:2:daemon:/sbin: adm:x:3:4:adm:/var/adm: ~ ~ cut -f1 -d: /etc/passwd root bin daemon adm ~ ~ 145
Part who root :0 Mar 25 19:44 root pts/0 Mar 25 19:44 root pts/1 Mar 25 19:55 root pts/2 Mar 25 20:47 who cut -c1-4 sort uniq -c 4 root cat a kug kang li cat b 111-1234 222-1234 333-1234 paste a b kug 111-1234 kang 222-1234 li 333-1234 paste -d* a b kug*111-1234 # 146
Chapter 3 kang*222-1234 li*333-1234 *444-1234 Part 1 paste -s a b kug kang li 111-1234 222-1234 333-1234 444-1234 cat c kug 111-1234 kang 222-1234 li 333-1234 cut -f1 c>c1 cut -f2 c>c2 paste c2 c1 111-1234 kug 222-1234 kang 333-1234 li # 1 # 2 147
Part cat c kug 111-1234 kang 222-1234 li 333-1234 tr k A <c Aug 111-1234 Aang 222-1234 li 333-1234 cat c kug 111-1234 kang 222-1234 li 333-1234 tr a-z A-Z <c KUG 111-1234 KANG 222-1234 LI 333-1234 tr \[a-z\] \[A-Z\] <c KUG 111-1234 KANG 222-1234 LI 333-1234 # cat c kug 111-1234 kang 222-1234 li 333-1234 tr -d [0-9] <c 148
Chapter 3 kug - kang - li - Part 1 cat c kug 111-1234 kang 222-1234 li 333-1234 tr -cd [0-8] <c 111123422212343331234 5 Linux cat name.txt 1 kug jkyoung wan 302-9278 KOREA 2 kug ji su 506-0988 USA 3 kang yan jung 123-5678 CHINA 4 li youn ju 444-4444 ENGLAND 5 chi nam su 457-9800 TILAND 6 am bi ju 566-0099 ITALY # 149
Part grep am name.txt # am chi nam su 457-9800 TILAND am bi ju 566-0099 ITALY cat name.txt 1 kug jkyoung wan 302-9278 KOREA 2 kug ji su 506-0988 USA 3 kang yan jung 123-5678 CHINA 4 li youn ju 444-4444 ENGLAND 5 chi nam su 457-9800 TILAND 6 am bi ju 566-0099 ITALY grep -v am name.txt # 1 kug jkyoung wan 302-9278 KOREA 2 kug ji su 506-0988 USA 3 kang yan jung 123-5678 CHINA 4 li youn ju 444-4444 ENGLAND grep -n am name.txt # 5:5 chi nam su 457-9800 TILAND 6:6 am bi ju 566-0099 ITALY 150
Chapter 3 grep -c kug name.txt 2 Part 1 ls imsi name.tmp name.txt sample.c grep -l kug * grep: imsi: Is a directory name.tmp name.txt grep -l kug / grep: /: Is a directory cat name.txt 1 kug jkyoung wan 302-9278 KOREA 2 KUG ji su 506-0988 USA 3 kang yan jung 123-5678 CHINA 4 li youn ju 444-4444 ENGLAND 5 chi nam su 457-9800 TILAND 151
Part 6 am bi ju 566-0099 ITALY grep -y kug name.txt 1 kug jkyoung wan 302-9278 KOREA 2 KUG ji su 506-0988 USA grep KUG name.txt 2 KUG ji su 506-0988 USA # # grep -w ku name.txt grep -w kug name.txt 1 kug jkyoung wan 302-9278 KOREA 152
Chapter 3 grep ^k name.txt grep ^k name.txt grep ^4 name.txt 4 li youn ju 444-4444 ENGLAND grep a$ name.txt grep A$ name.txt 1 kug jkyoung wan 302-9278 KOREA 2 KUG ji su 506-0988 USA 3 kang yan jung 123-5678 CHINA grep ^$ name.txt Part 1 grep k.. name.txt 1 kug jkyoung wan 302-9278 KOREA 3 kang yan jung 123-5678 CHINA grep I... name.txt # I 5 chi nam su 457-9800 TILAND 6 am bi ju 566-0099 ITALY 153
Part grep [LMN] name.txt 3 kang yan jung 123-5678 CHINA 4 li youn ju 444-4444 ENGLAND 5 chi nam su 457-9800 TILAND 6 am bi ju 566-0099 ITALY grep [L-N] name.txt 3 kang yan jung 123-5678 CHINA 4 li youn ju 444-4444 ENGLAND 5 chi nam su 457-9800 TILAND 6 am bi ju 566-0099 ITALY grep ^[K4] name.txt 4 li youn ju 444-4444 ENGLAND w 8:59pm up 2:21, 4 users, load average: 0.04, 0.07, 0.08 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root pts/0-7:44pm 1:15m 0.00s 0.00s /bin/catroot pts/1-7:55pm 0.00s 0.28s 0.01s w root pts/2-8:47pm 9:14 0.07s 0.07s /bin/bas w grep sh root pts/2-8:47pm 9:22 0.07s 0.07s /bin/bash w grep sh 154
Chapter 3 root pts/2-8:47pm 11:43 0.07s 0.07s /bin/bash w grep sh wc -l 1 Part 1 Q u i z 155
>> Q uestion 1. 5. 2. 3. 4. 6. 7. 157
Part 8. 9. 10. 11. 14. 15. 16. 17. 12. 13. 18. 19. 158
Chapter 3 20. 21. 26. 27. Part 1 22. 28. 23. 24. 25. 29. 30. 31. 159
Part 32. 38. 33. 34. 35. 36. 37. 39. 40. 41. 42. 160
Chapter 3 43. 44. 45. 46. 49. 50. 51. Part 1 47. 52. 48. 53. 161
Part 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 162
Chapter 3 64. 65. 66. 70. 71. 72. Part 1 67. 68. 69. 73. 74. 75. 163