a guide to unix using linux fourth edition
DESCRIPTION
A Guide to Unix Using Linux Fourth Edition. Chapter 8 Exploring the UNIX/Linux Utilities. Objectives. Understand many of the UNIX/Linux utilities that are available and how they are classified Use the dd utility to copy and convert files Monitor hard disk usage Use system status utilities - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/1.jpg)
A Guide to Unix Using Linux Fourth Edition
Chapter 8Exploring the UNIX/Linux Utilities
![Page 2: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/2.jpg)
A Guide to Unix Using Linux, Fourth Edition 2
Objectives
• Understand many of the UNIX/Linux utilities that are available and how they are classified
• Use the dd utility to copy and convert files
• Monitor hard disk usage
• Use system status utilities
• Monitor and manage processes
• Check the spelling of text in a document
![Page 3: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/3.jpg)
A Guide to Unix Using Linux, Fourth Edition 3
Objectives (continued)
• Use the cmp command to compare the contents of two files
• Format text to create and use a man page
• Use the dump command to back up a system
• Send and receive e-mail
• Use basic network commands and utilities
![Page 4: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/4.jpg)
A Guide to Unix Using Linux, Fourth Edition 4
Understanding UNIX/Linux Utilities
• UNIX/Linux utilities are classified into:– File processing– System status– Networking– Communications– Security– Programming– Source code management– Miscellaneous
![Page 5: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/5.jpg)
A Guide to Unix Using Linux, Fourth Edition 5
Classifying UNIX/Linux Utilities
• Several categories– Network tasks– Programming tasks– File-processing utilities
• Make up the largest category
• Display and manipulate files
![Page 6: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/6.jpg)
A Guide to Unix Using Linux, Fourth Edition 6
![Page 7: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/7.jpg)
A Guide to Unix Using Linux, Fourth Edition 7
![Page 8: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/8.jpg)
A Guide to Unix Using Linux, Fourth Edition 8
Classifying UNIX/Linux Utilities (continued)
![Page 9: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/9.jpg)
A Guide to Unix Using Linux, Fourth Edition 9
Classifying UNIX/Linux Utilities (continued)
![Page 10: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/10.jpg)
A Guide to Unix Using Linux, Fourth Edition 10
Classifying UNIX/Linux Utilities (continued)
![Page 11: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/11.jpg)
A Guide to Unix Using Linux, Fourth Edition 11
Classifying UNIX/Linux Utilities (continued)
![Page 12: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/12.jpg)
A Guide to Unix Using Linux, Fourth Edition 12
Classifying UNIX/Linux Utilities (continued)
![Page 13: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/13.jpg)
A Guide to Unix Using Linux, Fourth Edition 13
Using the dd Command
![Page 14: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/14.jpg)
A Guide to Unix Using Linux, Fourth Edition 14
Checking Hard Disk Usage
• Basic strategies used to maintain adequate free space:– Be vigilant against running dangerously low on free
space• Use df command
– Watch for conspicuous consumption• Use du command
– Follow a routine schedule for “garbage” collection and removal
• Use a combination of find and rm commands
![Page 15: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/15.jpg)
A Guide to Unix Using Linux, Fourth Edition 15
Using the df Utility
• If entered without specifying file system, shows information for all mounted file systems
![Page 16: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/16.jpg)
A Guide to Unix Using Linux, Fourth Edition 16
Using the df Utility (continued)
![Page 17: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/17.jpg)
A Guide to Unix Using Linux, Fourth Edition 17
Using the du Utility
• With no options, report is based on all file usage– Starts at current directory – By default, output is in number of 512-byte blocks
![Page 18: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/18.jpg)
A Guide to Unix Using Linux, Fourth Edition 18
![Page 19: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/19.jpg)
A Guide to Unix Using Linux, Fourth Edition 19
Removing Garbage Files
• Garbage files are temporary files that lose their usefulness after several days– Remove to free space– Example: core files, compilation output
• Core file: created when executing program attempts to do something illegal– Example: accessing another user’s memory
• Use find and rm to find and remove garbage files:find . "(" -name a.out -o -name core ")" -exec rm {} \;
![Page 20: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/20.jpg)
A Guide to Unix Using Linux, Fourth Edition 20
Using System Status Utilities
• System status commands reflect system’s performance
• You can redirect the output of these commands to a file– File can later be:
• Printed
• Forwarded to system administrator and system tune-up specialists
![Page 21: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/21.jpg)
A Guide to Unix Using Linux, Fourth Edition 21
Using the top Command
![Page 22: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/22.jpg)
A Guide to Unix Using Linux, Fourth Edition 22
Using the uptime Command
• Example: use it to track how long system has been up since last problem requiring a reboot
![Page 23: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/23.jpg)
A Guide to Unix Using Linux, Fourth Edition 23
Using the free Command
• Swap space is disk space that acts like an extension of memory
![Page 24: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/24.jpg)
A Guide to Unix Using Linux, Fourth Edition 24
Using the free Command (continued)
![Page 25: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/25.jpg)
A Guide to Unix Using Linux, Fourth Edition 25
Forwarding top and free Output
• You may forward output of top and free to a computer support person for analysis– Example:
top n 3 > topdata
lpr topdata
![Page 26: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/26.jpg)
A Guide to Unix Using Linux, Fourth Edition 26
Managing Processes
• When you run a program, it starts one or more processes– Processes are identified through a unique number
• Process id or PID
• UNIX and Linux offer utilities to:– Manage how a program is run– Monitor processes– Kill processes
![Page 27: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/27.jpg)
A Guide to Unix Using Linux, Fourth Edition 27
Running Processes in the Background
• UNIX/Linux is a multitasking OS– You can run processes in the background
• To run a process in background:– Append the & character
• Example:top&
![Page 28: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/28.jpg)
A Guide to Unix Using Linux, Fourth Edition 28
Monitoring Processes
• If used with no options, shows a list of processes associated with the current login session
![Page 29: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/29.jpg)
A Guide to Unix Using Linux, Fourth Edition 29
Monitoring Processes (continued)
![Page 30: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/30.jpg)
A Guide to Unix Using Linux, Fourth Edition 30
Killing Processes
• System administrator may want to kill a user’s process because:– Associated program is malfunctioning– Associated program is using too many system
resources• A user may want to kill a process that is running in
the background
![Page 31: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/31.jpg)
A Guide to Unix Using Linux, Fourth Edition 31
Checking the Spelling of a Document
• ispell– Scans a text document– Displays errors on screen– Suggests other words with similar spellings as
replacements for unrecognized words
![Page 32: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/32.jpg)
A Guide to Unix Using Linux, Fourth Edition 32
Checking the Spelling of a Document (continued)
![Page 33: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/33.jpg)
A Guide to Unix Using Linux, Fourth Edition 33
Comparing Files
• If the contents are identical, there is no output
• Otherwise, output specifies first byte (character) that is different between the files
![Page 34: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/34.jpg)
A Guide to Unix Using Linux, Fourth Edition 34
Formatting Text in UNIX/Linux
![Page 35: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/35.jpg)
A Guide to Unix Using Linux, Fourth Edition 35
Archiving and Backing Up Files
• Good practice to periodically archive or back up files
• You can back up files to:– CD, DVD, tape, or another removable medium
• For backup to CD/DVD, consider using a GUI tool– Example: GNOME CD/DVD Creator GUI software
• Part of Nautilus
![Page 36: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/36.jpg)
A Guide to Unix Using Linux, Fourth Edition 36
Using the dump Command
![Page 37: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/37.jpg)
A Guide to Unix Using Linux, Fourth Edition 37
Using the restore Command
• Restores from a backup medium created via dump – By default, copies back to current working directory
• Example: restore -r -f /dev/st0
![Page 38: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/38.jpg)
A Guide to Unix Using Linux, Fourth Edition 38
Using mail to Send Mail
• Press Ctrl+d to exit the text mode
• To leave the mail utility, type q and press Enter
![Page 39: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/39.jpg)
A Guide to Unix Using Linux, Fourth Edition 39
Using mail to Send Mail (continued)
![Page 40: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/40.jpg)
A Guide to Unix Using Linux, Fourth Edition 40
Using mail to Send Mail (continued)
![Page 41: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/41.jpg)
A Guide to Unix Using Linux, Fourth Edition 41
Using Networking Utilities
• UNIX and Linux offer many utilities to accommodate a connection to the network– ifconfig– ping– traceroute– netstat
![Page 42: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/42.jpg)
A Guide to Unix Using Linux, Fourth Edition 42
Using the ifconfig Utility
• Internet Protocol (IP) is used to help ensure that information on a network goes to the right place– IP address uses a dotted decimal notation
• Consists of four octets separated by periods
• Identifies a computer/device and the network it is on
![Page 43: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/43.jpg)
A Guide to Unix Using Linux, Fourth Edition 43
Using the ping Utility
• Examples:– ping [email protected]– ping redhat.com
![Page 44: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/44.jpg)
A Guide to Unix Using Linux, Fourth Edition 44
Using the traceroute Utility
• Sample use:– To ensure your computer is connected and working– To ensure your network is working from point to
point
![Page 45: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/45.jpg)
A Guide to Unix Using Linux, Fourth Edition 45
Using the netstat Utility
• Information provided by netstat includes:– Network protocol communications– Network connections established by host computer– Network routing information– Information about remotely logged computers
![Page 46: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/46.jpg)
A Guide to Unix Using Linux, Fourth Edition 46
Sharing Resources Using Network File System
• Network File System (NFS): used for resource sharing over a network– Once partition is mounted, access is transparent
• mount bluefin:/home/mpalmer/shared /mnt/shared
– Three versions typically supported:• NFSv2, NFSv3, and NFSv4
– Client and host communicate via RPCs• RPC: Remote Procedure Call
• Portmap service:– Handles RPC request to mount a partition– Makes computer act like a server for NFS file access
![Page 47: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/47.jpg)
A Guide to Unix Using Linux, Fourth Edition 47
Sharing Resources Using Network File System (continued)
• To start a service, use service command– service portmap
• NFS security handled through entries in:– /etc/hosts.allow, /etc/hosts.deny, and /etc/exports
/home/mpalmer/shared 192.168.0.72(ro) 192.168.0.84(ro)/home/mpalmer/docs 192.168.0.72(rw) 192.168.0.41(rw)
![Page 48: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/48.jpg)
A Guide to Unix Using Linux, Fourth Edition 48
Accessing Microsoft Windows Systems Through Samba
• Samba: utility that uses the SMB protocol– Server Message Block (SMB) is used by Windows
systems for sharing folders and printers
• Typical configuration file:– /etc/samba/smb.conf file
• Some ways to access Windows shared drives:– Network Servers Windows Network– Computer More Applications Network Servers
File Browser Windows Network– K menu KNOPPIX Utilities Samba Network
Neighborhood
![Page 49: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/49.jpg)
A Guide to Unix Using Linux, Fourth Edition 49
Summary
• Some useful utility programs are:– dd, df, and du for converting files, checking free space,
and checking disk usage, respectively– find and rm can be used together to remove garbage
files– top and free provide detailed views of system internals– uptime shows how long a system has been up– ps and kill to display and kill processes– ispell to check for spelling errors in a file– nroff, troff, and groff for formatting output
![Page 50: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/50.jpg)
A Guide to Unix Using Linux, Fourth Edition 50
Summary (continued)
• Other useful utility programs are:– dump and restore to archive and restore backups– mail to send and retrieve mail– ifconfig, ping, traceroute, and netstat for viewing
information about the network connection and for troubleshooting the connection
• Services for sharing resources over network:– Network File System (NFS) to access resources in
another UNIX/Linux computer– Samba to access resources in a Windows computer
![Page 51: A Guide to Unix Using Linux Fourth Edition](https://reader035.vdocuments.net/reader035/viewer/2022062717/56812a67550346895d8de71c/html5/thumbnails/51.jpg)
A Guide to Unix Using Linux, Fourth Edition 51
Command Summary