the linux utilities n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
The Linux Utilities PowerPoint Presentation
Download Presentation
The Linux Utilities

Loading in 2 Seconds...

play fullscreen
1 / 35
chastity-everett

The Linux Utilities - PowerPoint PPT Presentation

98 Views
Download Presentation
The Linux Utilities
An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. The Linux Utilities Chapter 5

  2. Overview • Special Characters • Basic Utilities • Less is more • Working with files • Compressing and Archiving files • Obtaining User and System information

  3. Special Characters • Some characters have a meaning to the shell • These should be avoided in a filename • & ; | * ? ‘ “ ` [ ] ( ) $ < > { } # / \ ! ~ • Whitespace • RETURN, SPACE, and TAB also have special meanings to the shell.

  4. Basic Utilities • Advantage of command line utilities • Linux has 1000’s • Designed to do just about anything • Disadvantage of command line utilities • Linux has 1000’s • Little or No consistency for naming command line options • Each command will have its own set of unique command line options

  5. Basic Utilities • ls • Lists the names of files • Equivalent of “dir” in DOS • cat • Displays the content of a text file • Derived from catenate • e.g. cat practice

  6. Basic Utilities • rm • Deletes a file • -i causes rm to prompt for confirmation • e.g. rm -i practice

  7. Basic Utilities • more OR less • Causes the output to the screen to pause after displaying a screen of text. • At the end of the file “less” displays EOF and waits for you to press “q” while “more” returns directly to the shell • e.g. less /etc/termcap more /etc/termcap • hostname • displays the system name

  8. Working with Files • cp • Copies a file • syntaxcp source-file destination-file

  9. Working with Files • mv • changes the name of a file • moves a file to another directory

  10. Working with Files • lpr • Places a file(s) in a print queue for printinge.g. lpr report • To display the available printers use: lpstat -p • To send to a specific printer use: lpr -P mailroom report • where “mailroom” is the name of a printer and report is the name of the file to print • To display the queue contents use: lpstat -o OR lpq • To cancel a queued print job use: lprm job-number

  11. Working with Files • grep • Searches for a string • Displays each line in the target file that contains the string • “-w” option causes grep to search for only whole words • head • Displays the first n lines of a file • Default is to display 10 lines

  12. Working with Files • tail • Displays the last n lines of a file • Default is to display the last 10 lines • e.g. tail -f logile • causes the lines in the file “logfile” to be displayed as they are added to the file.

  13. Working with Files • diff • compares 2 files and displays a list of differences between them

  14. Working with Files • file • tests the contents of a file • displays the type of data contained in a file • | (pipe) • communicates between processes • takes the output of one utility and sends it as the input to another utility • e.g. cat months | head • this will take the output of “cat months” and send it as the input to the “head” utility

  15. Working with Files • echo • copies anything after the word “echo” to the screen

  16. Working with Files • date • displays the time and date • e.g. $ date Thu Jan 20 10:24:00 PST 2005 • e.g. $ date +”%A %B %d” Thursday January 20

  17. Working with Files • script • records a shell session • e.g. $ script Script started, file is typescript $ date Thu Jan 20 10:28:56 PST 2005 $ who am I alex pst/4 Jan 8 22:15 $ $ apropos mtools mtools (1) - utilities to access DOS disks in Unix mtools.conf [mtools] (5) - mtools configuration files mtoolstest (1) - tests and displays the configuration $ exit Script done, file is typescript $

  18. Working with Files • unix2dos • converts Linux and Macintosh files to Windows format

  19. Compressing and Archiving Files • bzip2 • compresses a file • e.g.$ ls -l-rw-rw-r-- 1 sam sam 584000 Mar 1 22:31 letter_e$ bzip2 -v letter_eletter_e: 11680.00:1, 0,001 bits/byte, 99.99% saved, 584000 in 50 out.$ ls -l-rw-rw-r-- 1 sam sam 50 Mar 1 22:31 letter_e.bz2

  20. Compressing and Archiving Files • bunzip2 & bzcat • decompress a file that has been compressed with bzip2 • e.g.$ bunzip2 letter_e.bz2$ ls -l -rw-rw-r-- 1 sam sam 584000 Mar 1 22:31 letter_e • bzcat diplays a file that has been compressed with bzip2 • e.g.$ bzcat letter_e.bz2 | head -2eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee

  21. Compressing and Archiving Files • gzip • compresses a file • older and less efficient than bzip2 • tar (tape archive) • packs and unpacks archives • originally used to create and read tape archives • creates a single file from multiple files or directory hierarchies

  22. Compressing and Archiving Files -c (create)-v (verbose)-f (write/read to/from a file • tar (cont.) • e.g.$ ls -l g b d-rw-r--r-- 1 jenny jenny 1302 Aug 20 14:16 g-rw-r--r-- 1 jenny other 1178 Aug 20 14:16 b-rw-r--r-- 1 jenny jenny 3783 Aug 20 14:17 d$ tar -cvf all.tar g b dgbd$ ls -l all.tar -rw-r--r-- 1 jenny jenny 9728 Aug 20 14:17 all.tar$ tar -tvf all.tar-rw-r--r-- jenny/jenny 1302 2005-08-20 14:16 g-rw-r--r-- jenny/other 1178 2005-08-20 14:16 b-rw-r--r-- jenny/jenny 3783 2005-08-20 14:17 d -t (display table of contents)*use -x to extract

  23. Compressing and Archiving Files • tar (cont) • use file compression to make .tar files easier to deal with • be careful using the -x option • tar files may contain large number of files and you may only need one • -x will overwrite existing files with the same name

  24. Locating Commands • which & whereis • locate a utility • only looks in the search path • whereis searches for files related to a utility • e.g.$ whereis tartar: /bin/tar /usr/include/tar.h /usr/share/man/man1/tar.1.gz

  25. Locating Commands • apropos • searches for a keyword • searches in the short description line of all man pages • same as “man -k” • uses a database called “whatis” • the whatis database is built and maintained by cron using “makewhatis” • /etc/cron.weekly/makewhatis.cron • use the utility “makewhatis -w” as root if you don’t want to wait for cron or incorrect results are reuturned

  26. Locating Commands • apropos (cont.) • e.g.$ apropos whoat.allow [at] (5) - determin who can submit jobs via at or batchat.deny [at] (5) - determin who can submit jobs via at or batchjwhois (1) - client for the whois serviceldapwhoami (1) - LDAP who am i? toolw (1) - show who is logged on and what they are doingwho (1) - show who is logged onwhoami (1) - print effective userid • whatis • similar to apropos but finds only complete word matches • e.g.$ whatis whowho (1) - show who is logged on

  27. Locating Commands • locate • searches for a file • the updatedb utility builds the database • run by cron • e.g.$ locate motd/etc/motd/lib/security/pam_motd.so/usr/share/man/man5/motd.5.gz

  28. Obtaining User and System Information • who • lists users on the system • “who am i “ • tells you which terminal you are using and what time you logged in

  29. Obtaining User and System Information • finger • lists users on the system • supplies • user’s full name • information about the device the user is connected to • how recently the user typed something on the keyboard • when the user logged in • what contact information is available

  30. Obtaining User and System Information

  31. Obtaining User and System Information • w • lists users on the system

  32. Obtaining User and System Information

  33. Communicating with Other Users • write • sends a message • write username [terminal] • mesg • denies or accepts messages • “mesg n” would prevent others from being able to send you a message

  34. Lab time! • See the FTP Site: • Ch4-5 –Commands and Utils.doc • Ch5 – Command Line Demonstrations.doc • Demos are a hand-in assignment