ࡱ> FHE HbjbjWW 4,==H. . qqqqq,$4>L4N4N4N4N4N4N469N4qN4qqc4vvvqqL4vL4vv23Rj;Tn384y4043M:*M:033&M:q3tvN4N44M:. 7: CIS 118 Intro to LINUX Class Exercise Week 4 Standard I/O and redirection Standard I/O: STDIN (keyboard) filehandle 0 STDOUT (display) filehandle 1 STDERR (display) filehandle 2 Redirecting output. When you redirect standard output, the data that would normally appear on the screen is stored in a file instead. Redirect output to a file using > or >> ls -l > flist stores the output from ls in flist; if flist already exists, it is overwritten ls -l >> flist appends the output from ls to the file flist; if flist does not exist, it is created Redirecting input. When you redirect standard input, any data that would normally be entered from the keyboard is obtained from a file instead. Redirect input from a file using < or | mail rjtaylor@oakton.edu < jokes cat jokes |  HYPERLINK "mailto:rjtaylor@oakton.edu" rjtaylor@oakton.edu Redirecting standard error. Redirect standard error using 2> find / -name jokes print 2> /dev/null looks for a file named jokes; sends any "permission denied" messages to /dev/null Pipes and Filters Pipes - Takes the output from one command and uses it as input to the next command. ls -l /etc | more The second command in a pipe is a filter used modify the output from other commands to answer a question. Common filters: grep, sort, wc, uniq wc: Count bytes, words and lines wc /etc/passwd Count the number of bytes, words and lines in /etc/passwd wc -l /etc/passwd Count the number of lines in /etc/passwd wc -w /etc/login.defs Count the number of words in /etc/passwd sort: sort lines in a file sort /etc/group Sort the contents of /etc/group sort -r /etc/group Sort the contents of /etc/group in reverse order ls -l | sort -k5n Sort ls -l on the size of the files. starting on field 5 in numerical order uniq: remove consecutive duplicate lines grep: search for text within a file. Exercises: Find all jokes in the system find / -name jokes print 2> /dev/null Place a directory listing ls -l /etc > ~/etc.filelist Capture who is logged on who > ~/whoson Record all root processes: ps ef | grep root > root.proc Get a list of everyone currently logged on and save the list in a file called "users "in your own home directory. Get a list of all of the processes that are running and add this list to the end of the "users" file. Typewriter cat This is a test This is a test Ctrl D Copy the below file into ~/professions grep for all Engineers grep for all non-Teachers grep for all Teachers John Smith Teacher 301-989-9283 25000 Pete Jones Engineer 301-854-2938 65000 Fred McDuff Teacher 301-993-2938 35000 Annie Tubs Teacher 301-039-9283 37000 Jeff Tolaho Engineer 301-394-0293 45000 Finlay Toms Engineer 301-392-2039 32980 Tom MacMark Teacher 301-029-2039 39482 Carl Banks Teacher 301-392-0392 39202 Warren Tu Teacher 301-039-9329 89000 Mark Zulona Teacher 220-029-1029 59343 Mike Thoman Engineer 220-923-9283 48578 Joni Tobs Engineer 220-039-9283 85968 Jean Tobb Teacher 220-203-2039 78293 Jeff Thoman Engineer 301-033-2039 38493 Jonathan Wu Teacher 220-153-2930 29102 Jenny Watasa Teacher 220-309-1029 47584 Jill Tom Teacher 220-394-2938 49302 Count the number of files in the directory var/spool/mail? ls /var/spool/mail | wc -w The number of users whose login shell is /bin/bash? grep /bin/bash$ /etc/passwd | wc -l What command will display a list of everyone who is logged on sorted by their usernames? more /etc/services This file contains a list of the port numbers used for IP network services. How many lines are in the file. wc l /etc/services Display all of the lines for tcp services. grep tcp /etc/services Count the number of lines for tcp services. grep tcp /etc/services | wc -l Display all of the lines for udp services. grep tcp /etc/services Count the number of lines for udp services. grep tcp /etc/services | wc -l Use the "last" command to display the record of all login sessions. What command counts the number of login sessions for floopy? Display a long directory listing for the /etc directory. Pipe the output of the long directory listing through a grep command that will only display the entries for directories in /etc. 2346RSj w x   : ; N O   w`ThD-hz5CJaJ-h hZc0JB*CJOJQJ^JaJphh h|T0J6jh h|T0JB*CJOJQJU^JaJphh h|T0JB*ph-h h|T0JB*CJOJQJ^JaJphh h|TB*ph h|Th|T5B*CJaJphh|Th|T5CJaJh|Th6B5CJaJh$y}h|Th-Fc-46Sbj ,  P   o gdD- & Fdd[$\$gdd & Fdd[$\$gd|T & Fdd[$\$gddgd|T @ ^@ `gd-Fcgd-Fc  o   ; I J *+K_` 䰨䰨䰒䰨䰨䰨yl^lShD-hzB*phhG|6h*@>*B*\phhG|6h*@B*\phhG|6h*@5B*\phhG|6h*@B*ph*hD-0J5B*CJOJQJ^JaJphhD-B*ph0hD-hz0J5B*CJOJQJ^JaJphhG|6hz5B*\phhD-hz5B*phhG|6hzB*ph hD-hz5B*CJaJph  ; KAMNkgdd^gdd & Fgddgdd & Fdd[$\$gdd & Fdd[$\$gdd !"@ABMNk2CteXM8XMXMXMX)h hd5B*fHphq h hdB*phh hd5B*phh hd0J5B*ph0h hd0J5B*CJOJQJ^JaJph-h hd0JB*CJOJQJ^JaJphhrmh B*ph h hd5B*CJaJphhG|6B*CJaJphhG|6hD-B*phhD-hD-B*phhD-5B*phhD-B*phhD-5B*\ph2  -<CDklS$Ygdd & Fgdd & Fdd[$\$gdd^gdd-b68N'z  H^gd h^hgd  & Fgd dd[$\$^gd*@gddC6789tuvKLMN`a'TZx͎ͧ̓v̓iv̓v_v̓vhZF5B*phh hz5B*phh h[$5B*phh h[$B*ph0h hD-0J5B*CJOJQJ^JaJph0h hz0J5B*CJOJQJ^JaJphh hz0JB*phh hzB*phh hD-B*phh h*@B*phh h B*ph h hd% Hh hzB*CJaJphh hzB*phh h[$B*phh h[$5B*ph21h:pN%g/ =!"#$% ^ 002 0@P`p2( 0@P`p 0@P`p 0@P`p 0@P`p 0@P`p 0@P`p8XV~_HmH nH sH tH @`@ NormalCJ_HaJmH sH tH ff  Heading 17$8$@&H$+5B*CJ0KH OJPJQJ\^JaJ(ph`` |T Heading 2$<@&$56CJOJPJQJ\]^JaJZZ |T Heading 3$<@&5CJOJPJQJ\^JaJDA`D Default Paragraph FontViV  Table Normal :V 44 la (k (No List e HTML Preformatted7 2( Px 4 #\'*.25@9CJOJPJQJ^JaJXX |THeading 2 Char$56CJOJPJQJ\]^JaJRR |THeading 3 Char5CJOJPJQJ\^JaJB^"B |T0 Normal (Web)dd[$\$Ng@1N |T0HTML TypewriterCJOJPJQJ^JaJBOAB |Tapple-converted-space6U@Q6 |T Hyperlink >*B*ph@@b@ Zc List Paragraph ^PK![Content_Types].xmlj0Eжr(΢Iw},-j4 wP-t#bΙ{UTU^hd}㨫)*1P' ^W0)T9<l#$yi};~@(Hu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roman5Symbol3. *Cx ArialG=  jMS Mincho-3 fg7@CambriaI. ??Arial Unicode MS?= *Cx Courier New;WingdingsA$BCambria Math"qh!lf1g !x24@@13QHP ?$2!xx5Input/Output redirection with the Utilities Practice Image v5.05P RR Donnelley0         Oh+'0( @L l x 8Input/Output redirection with the Utilities Practice Image v5.05P Normal.dotmRR Donnelley9Microsoft Office Word@ @Fcn@&j;՜.+,D՜.+,l( hp  RR Donnelley@ 6Input/Output redirection with the Utilities Practice Title 8@ _PID_HLINKSAp~Ymailto:rjtaylor@oakton.eduD  !"#$%&'()*+,-./012346789:;<>?@ABCDGRoot Entry FYj;I1Table}:WordDocument4,SummaryInformation(5DocumentSummaryInformation8=CompObjy  F'Microsoft Office Word 97-2003 Document MSWordDocWord.Document.89q