Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 © 2001 John Urrutia. All rights reserved. Chapter 3 An Introduction to the Utilities.

Similar presentations


Presentation on theme: "1 © 2001 John Urrutia. All rights reserved. Chapter 3 An Introduction to the Utilities."— Presentation transcript:

1

2 1 © 2001 John Urrutia. All rights reserved. Chapter 3 An Introduction to the Utilities

3 2 © 2001 John Urrutia. All rights reserved. Topics File Operations File Compression and Archive Obtaining User & System Information Communicating with Other Users Daily Miscellany

4 3 © 2001 John Urrutia. All rights reserved. File Operations  c o p y - m o v e  head - tail  file - uniq - diff  sort - grep  lpr - more - less Topics

5 4 © 2001 John Urrutia. All rights reserved. File Operations cp - Copy a file or directory  cp [options ] srce-file dest-file srce-filelist dest-directory -i Interactive - prompts for overwrites -r Recursive - copies all subdirectories

6 5 © 2001 John Urrutia. All rights reserved. File Operations mv - Move or re-name a file or directory (creates new link if on the same file system)  mv [options --] filenames -f Force - moves the file regardless of access permissions. -i Interactive - prompts for overwrites

7 6 © 2001 John Urrutia. All rights reserved. File Operations head - Display the first X records in file(s) head [-number] [file-list] if a number is not specified the first 10 records of each file are displayed

8 7 © 2001 John Urrutia. All rights reserved. File Operations tail - Display the last X records in file tail [± [number]] [options] [file] + count from the beginning - count from the end [options] b blocks, c characters, l lines f follow-monitors the file until killed

9 8 © 2001 John Urrutia. All rights reserved. File Operations file - Display file content classification. file [option] [file-list] [option] - f file Input taken from file.

10 9 © 2001 John Urrutia. All rights reserved. File Operations uniq - Display unique records from files uniq [options] [input file] [output file] c – count occurrences d – display repeated records s n – skip first n characters f n – skip first n space delimited fields u – display only non-repeated lines

11 10 © 2001 John Urrutia. All rights reserved. File Operations diff - Display file differences line by line diff [options] [file1|directory1] [file2|directory2] b – ignore blanks c – display in context ( ) i – ignore case q – report if files are different r – recurse sub-directories

12 11 © 2001 John Urrutia. All rights reserved. diff Example Output from diff is a series of instructions to make the files the same  a – append  c – change  d – delete Surrounding the instruction are the line ranges to convert file1 to file2

13 12 © 2001 John Urrutia. All rights reserved. diff Example Append  line1aline2,line3 Change  line1,line2cline3,line4 Delete  line1,line2dline3

14 13 © 2001 John Urrutia. All rights reserved. diff Example line1,line2 – Range from file 1 line3,line4 – Range from file 2 cat xcat y aaaaabbbbbbbbbb cccccddddd dddddeeeee eeeeefffff fffffggggg diff x y 1d0 bbbbb 6a6 > ggggg diff y x 0a1 > aaaaa 2c3 ccccc 6d6 < ggggg

15 14 © 2001 John Urrutia. All rights reserved. File Operations sort – sorts or merges text files sort [options] [field-specifier-list] [file-list]  f upper and lower case considered the same  u duplicate entries are eliminated from output  r reverse order (ie, z to a)  b ignores leading blanks  k n defines the field to start sort comparison. Count starts with 1 (replace n with a number)

16 15 © 2001 John Urrutia. All rights reserved. What is a ‘field’ Contains ascii data delimited by ‘whitespace’ whitespace is:  tab  blank  carriage return Example  the day the earth stood still

17 16 © 2001 John Urrutia. All rights reserved. Example

18 17 © 2001 John Urrutia. All rights reserved. Sorting Examples  sort myfile  sort -r myfile  sort file1 file2  sort file1 file2 > file3  sort –k2 myfile  (skip a field, then start comparisons)

19 18 © 2001 John Urrutia. All rights reserved. Sorting sort -k1,2 myfile  skip a field (start sort in field number 2)  end sort at end of field 2 sort -b –k3.1,3  -b ignore blanks  +2 skips first two fields .1 skip 1 character in field 3  3 ends sort key at end of field 3

20 19 © 2001 John Urrutia. All rights reserved. File Operations Searching for patterns with grep g lobal r egular e xpression p rint grep [options] pattern [file-list]  sends all lines with that pattern to std out  options  -v display lines which do NOT have pattern  -i ignore case  -c count lines  -n print line numbers  -l print file names only

21 20 © 2001 John Urrutia. All rights reserved. Example cat animal Bat Bird Cat Dog Lizard Turtle grep ‘r’ animal Bird Lizard Turtle grep –v ‘r’ animal Bat Cat Dog TRUE grit !grep !

22 21 © 2001 John Urrutia. All rights reserved. lpr (Lilliputian Practical guide to Romance) line printer – places a filelist into the print queue for printing Syntax lpr [-options] filelist -Pprintername -h suppress burst or header page -m send e-mail when job is complete

23 22 © 2001 John Urrutia. All rights reserved. lprm (Lilliputian PRevious Manual) line print remove – removes jobs from the print queue Syntax lprm [-option] job-identifier number(s) – remove all jobs from the print queue

24 23 © 2001 John Urrutia. All rights reserved. lpq (Lilliputian mind your P’s and Q’s) line print queue – display jobs in the print queue Syntax lpq job-identifier number(s)

25 24 © 2001 John Urrutia. All rights reserved. more or less more  Displays a screen full of data at a time.  Starts at the beginning and proceeds to the end  Enter Key – scroll one line  Space bar – scroll one screen

26 25 © 2001 John Urrutia. All rights reserved. more or less less – more functionality than more  Displays a screen full of data at a time.  Enter Key – scroll one line  Space bar – scroll one screen  Starts at the beginning and provides commands to control scrolling

27 26 © 2001 John Urrutia. All rights reserved. more of less less – more functionality than more  Provides interactive help panels  Will search forward or backward for matching patterns  Will jump to beginning or end  Provides bookmarks  Can invoke vim with current file  Over 40 invocation options

28 27 © 2001 John Urrutia. All rights reserved. Topics File Operations File Compression and Archive Obtaining User & System Information Communicating with Other Users Daily Miscellany

29 28 © 2001 John Urrutia. All rights reserved. gzip – Squish the snot out of it gunzip – Put the snot back in zcat – view compressed files tar – archive or retrieve files Compression and Archive

30 29 © 2001 John Urrutia. All rights reserved. gzip – compress gzip [options] file-list  Compresses file contents appends.gz  options  -# set level of compression 1- fast, 9 - best  -d de-compress  -r recurse directories  -c send output to stdout, don’t overwrite file  -v show filename and compression amount

31 30 © 2001 John Urrutia. All rights reserved. tar option [modifier] [dev or file] [file-list]  Create, add to or retrieve from an archive  option (only one at a time)  -x extract file-list from archive  -f use a file not a device  -c create new archive (overwrites existing)  -r appends file to end of archive (dups OK?)  -u update the archive with file-list  -t list table of contents in archive tar - the stuff archives are made of

32 31 © 2001 John Urrutia. All rights reserved. Topics File Operations File Compression and Archive Obtaining User & System Information Communicating with Other Users Daily Miscellany

33 32 © 2001 John Urrutia. All rights reserved. Obtaining User & System Information  apropos  whereis - which  w – who - finger Topics

34 33 © 2001 John Urrutia. All rights reserved. apropos keywords  Search the “whatis” database for keywords and displays suggested commands [student@linux1 student]$ apropos alarm alarm (2) - set an alarm clock for delivery of a signal [student@linux1 student]$ apropos death death: nothing appropriate 50¢ word of the day

35 34 © 2001 John Urrutia. All rights reserved. whereis the exit & which one? whereis & which  whereis – locates utilities by looking in the standard locations  which – locates utilities by looking in the path [student@linux1 student]$ whereis exit exit: /usr/share/man/man1/exit.1.gz /us … [student@linux1 student]$ which exit /usr/bin/which: no exit in (/usr/local/bin: …)

36 35 © 2001 John Urrutia. All rights reserved. What the owl says? who Identifies the users currently logged in and when they logged in [astudent@linux1 astudent]$ who jurrutiapts/0Aug 18 07:55 astudentpts/1Aug 18 09:38 calouisepts/2Aug 18 10:10

37 36 © 2001 John Urrutia. All rights reserved. w W Like who but more [astudent@linux1 astudent]$ w 10:17am up 8 days, 17:12, 3 users, load average: 0.00, 0.01, 0.00 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT jurrutia pts/0 ts-25.solano.cc. 7:55am 2:03m 0.15s 0.09s -bash astudent pts/1 ts-34.solano.cc. 9:38am 29:35 0.14s 0.09s -bash calouise pts/2 ts-37.solano.cc. 10:10am 0.00s 0.14s 0.03s w

38 37 © 2001 John Urrutia. All rights reserved. finger this out! Provides.project and.plan info for users online  Login name – Full name – Home directory location – Login Shell  Last Login date & time  Last time mail was read  Plan: if present  Project: if present

39 38 © 2001 John Urrutia. All rights reserved. The short finger Short version of finger [astudent@linux1 astudent]$ finger LoginNameTtyIdle Login Time Office Office Phone jurrutia pts/02:04 Aug 18 07:55 (ts-25.solano.cc.ca.us) astudent pts/1 30 Aug 18 09:38 (ts-34.solano.cc.ca.us) calouise pts/2 Aug 18 10:10 (ts-37.solano.cc.ca.us)

40 39 © 2001 John Urrutia. All rights reserved. The long finger Long version of finger [astudent@linux1 astudent]$ finger -l astudent@Linux1 Login: astudentName: Alouitious Purcevil Student Directory: /home/astudentShell:bash On since Sat May 19 07:00 (PDT) on tty1, idle 2400:04:59 Last login Sat May 19 07:00 (PDT) on tty1 Mail last read Sat May 19 07:10 1999 (PDT) Plan: Finish homework and final for CIS52.

41 40 © 2001 John Urrutia. All rights reserved. Topics File Operations File Compression and Archive Obtaining User & System Information Communicating with Other Users Daily Miscellany

42 41 © 2001 John Urrutia. All rights reserved. Communicating with Other Users  mesg  write  talk  pine Topics

43 42 © 2001 John Urrutia. All rights reserved. mesg y Please mesg is used to turn on or off your ability to receive messages from other users. mesg [y|n] When mesg is set to n all messages are denied.

44 43 © 2001 John Urrutia. All rights reserved. The write stuff Using write to send a message (or Henny Youngman – eat your heart out) Syntax: [root@linux1 root]$ write gburns Who was that blonde I saw you with? o

45 44 © 2001 John Urrutia. All rights reserved. The write Woman! [gburns@linux1 gburns]$ Message from root@linux1 on pts/0 at 8:30… Who was that blonde I saw you with? o Message from gburns@linux1 on ttpy3 at 8:30… That’s no blonde – that’s my wife. oo EOF

46 45 © 2001 John Urrutia. All rights reserved. talk’n talk’n talk’n, Happy talk talk initiates and carries on a two-way conversation. It splits the users screen into two sections. During the talk session you cannot use your terminal for other tasks.

47 46 © 2001 John Urrutia. All rights reserved. [root@linux1root]$talk bdaddy talk session

48 47 © 2001 John Urrutia. All rights reserved. [waiting for your party to respond] ======================================== [root]talk session

49 48 © 2001 John Urrutia. All rights reserved. [bdaddy@linux1 bdaddy]$ Message from Talk_Daemon@linux1 at 8:43 … talk: connection requested by root@linux1 talk: respond with: talk root@linux1 talk root@linux1 [bdaddy]talk session

50 49 © 2001 John Urrutia. All rights reserved. [connection established] ======================================== [bdaddy]talk session

51 50 © 2001 John Urrutia. All rights reserved. [connection established] ======================================== [root]talk session Big Daddy - Did you add that blower to your windows rod? Put up the pink and let my linux relieve you from that piece of junk.

52 51 © 2001 John Urrutia. All rights reserved. [connection established] ======================================== [bdaddy]talk session Big Daddy - Did you add that blower to your windows rod? Put up the pink and let my linux relieve you from that piece of junk. root – windows is going to wash you right out of the race no problem!

53 52 © 2001 John Urrutia. All rights reserved. [connection established] ======================================== [root]talk session Big Daddy - Did you add that blower to your windows rod? Put up the pink and let my linux relieve you from that piece of junk. root – windows is going to wash you right out of the race no problem! Did I tell you I wash windows for living! Bye. Ctrl - G

54 53 © 2001 John Urrutia. All rights reserved. [connection established] ======================================== [bdaddy]talk session Big Daddy - Did you add that blower to your windows rod? Put up the pink and let my linux relieve you from that piece of junk. root – windows is going to wash you right out of the race no problem! Did I tell you I wash windows for living! Bye. [connection closing. Exiting]

55 54 © 2001 John Urrutia. All rights reserved. mail - now you’ve got it Provides email and to Linux users Supports address books and attachments User-friendly interface And now a short demo

56 55 © 2001 John Urrutia. All rights reserved. Topics File Operations File Compression and Archive Obtaining User & System Information Communicating with Other Users Daily Miscellany

57 56 © 2001 John Urrutia. All rights reserved. Daily Miscellany  echo  cal  date Topics

58 57 © 2001 John Urrutia. All rights reserved. Daily Miscellany echo - Display a message.  Default displays on the standard output device

59 58 © 2001 John Urrutia. All rights reserved. Daily Miscellany cal - Display a calendar month or full year  cal [[month] year]  no parms = current month  [month] specific month to display  year the calendar year to display.

60 59 © 2001 John Urrutia. All rights reserved. Daily Miscellany date - Display or set the date & time  date [option] [‘+format’] newdate  [option] [-u] - (UTC) universal time  [‘+format’] {a d D h H j m M r y s T w} date & Time {n t} formatting characters


Download ppt "1 © 2001 John Urrutia. All rights reserved. Chapter 3 An Introduction to the Utilities."

Similar presentations


Ads by Google