Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

46
Chapter Eight Chapter Eight Exploring the UNIX Exploring the UNIX Utilities Utilities

Transcript of Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

Page 1: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

Chapter EightChapter Eight

Exploring the UNIX UtilitiesExploring the UNIX Utilities

Page 2: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

22

Lesson ALesson A

Using the UNIX UtilitiesUsing the UNIX Utilities

Page 3: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

33

ObjectivesObjectives

Understand what UNIX utilities are Understand what UNIX utilities are available and the classifications of utilitiesavailable and the classifications of utilities

Make a bootable floppy disk to boot the Make a bootable floppy disk to boot the system in case of an emergencysystem in case of an emergency

Duplicate files on a floppy diskDuplicate files on a floppy disk

Page 4: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

44

ObjectivesObjectives

Determine hard disk usage and available Determine hard disk usage and available free spacefree space

Locate and remove unnecessary files from Locate and remove unnecessary files from the hard diskthe hard disk

Display the CPU status and internal Display the CPU status and internal memory usagememory usage

Page 5: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

55

Understanding UNIX UtilitiesUnderstanding UNIX Utilities

UNIX utilities let you create and manage files, UNIX utilities let you create and manage files, run programs, produce reports, and generally run programs, produce reports, and generally interact with the systeminteract with the system

They also offer a full range of services that let They also offer a full range of services that let you monitor and maintain the system and you monitor and maintain the system and recover from a wide range of errorsrecover from a wide range of errors

Utility programs are vital for working through an Utility programs are vital for working through an OS and new utilities are continually being added OS and new utilities are continually being added in order to make UNIX run more efficientlyin order to make UNIX run more efficiently

Page 6: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

66

Understanding UNIX UtilitiesUnderstanding UNIX Utilities

UNIX utilities are classified into seven major UNIX utilities are classified into seven major function areas dictated by user needs function areas dictated by user needs – File processingFile processing– System statusSystem status– NetworkingNetworking– CommunicationsCommunications– ProgrammingProgramming– Source code managementSource code management– MiscellaneousMiscellaneous

Page 7: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

77

Page 8: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

88

Page 9: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

99

Page 10: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

1010

Page 11: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

1111

Page 12: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

1212

Page 13: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

1313

Page 14: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

1414

Page 15: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

1515

Using theUsing theFile Processing UtilitiesFile Processing Utilities

The dd command allows you to copy a file and The dd command allows you to copy a file and change the format of the destination filechange the format of the destination file

The dd command possesses a rich set of The dd command possesses a rich set of options that allow it to handle copies when other options that allow it to handle copies when other methods are inappropriatemethods are inappropriate

An advantage to using the dd command over cp An advantage to using the dd command over cp is that all users, not just the administrator, can is that all users, not just the administrator, can copy files to and from the floppy drivecopy files to and from the floppy drive

Page 16: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

1616

Making a Bootable Floppy Making a Bootable Floppy DiskDisk

It is a good idea to make a bootable floppy disk, It is a good idea to make a bootable floppy disk, because a computer problem may prevent you because a computer problem may prevent you from starting UNIX from the systemfrom starting UNIX from the system

To make a bootable floppy disk, use four utility To make a bootable floppy disk, use four utility programs: rdev, mkfs, fdformat, ddprograms: rdev, mkfs, fdformat, dd

Page 17: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

1717

Making a Bootable Floppy Making a Bootable Floppy DiskDisk

The rdev command queries and sets the root device, The rdev command queries and sets the root device, which is the hard disk partition that houses UNIX’s root which is the hard disk partition that houses UNIX’s root file systemfile system

The mkfs command builds a UNIX or Linux file system The mkfs command builds a UNIX or Linux file system on a device such as a floppy disk or a hard disk partitionon a device such as a floppy disk or a hard disk partition

The fdformat command formats a floppy at low levels to The fdformat command formats a floppy at low levels to ensure the media is clear of defects and is writeableensure the media is clear of defects and is writeable

Use the dd command to make a back-up copy of a Use the dd command to make a back-up copy of a floppy diskfloppy disk

Page 18: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

1818

Making a Bootable Floppy Making a Bootable Floppy DiskDisk

The file system type determines how UNIX reads and writes information from or onto the device

Page 19: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

1919

Making a Bootable Floppy Making a Bootable Floppy DiskDisk

After creating a bootable disk, it can be used to start the system

Page 20: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

2020

Checking Hard Disk Checking Hard Disk UsageUsage

To maintain adequate hard disk free space, use To maintain adequate hard disk free space, use these strategies:these strategies:– Be vigilant against running dangerously low on free Be vigilant against running dangerously low on free

space by using the df commandspace by using the df command– Watch for conspicuous consumption using the du Watch for conspicuous consumption using the du

commandcommand– Follow a routine schedule for “garbage” collection and Follow a routine schedule for “garbage” collection and

removal by using the rm commandremoval by using the rm command

Page 21: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

2121

Using the df UtilityUsing the df Utility

The df utility reports on the status of1024-byte blocks

Page 22: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

2222

Using the df UtilityUsing the df Utility

The df –h option causes the block data to display in human-readable form

Page 23: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

2323

Using the df UtilityUsing the df Utility

The du utility summarizes disk usage, expressed in 512-byte blocks (default) or by the number of bytes(-b option)

Page 24: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

2424

Using the df UtilityUsing the df Utility

...the second screen resulting from using | more

Page 25: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

2525

Removing Garbage FilesRemoving Garbage Files

Garbage files are temporary files that lose Garbage files are temporary files that lose their usefulness after several daystheir usefulness after several days

Two examples of garbage files are core Two examples of garbage files are core files (named core) and a.out filesfiles (named core) and a.out files

Use the find command to assist you in Use the find command to assist you in locating these files and the rm command locating these files and the rm command to remove themto remove them

Page 26: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

2626

Applying System Status Applying System Status UtilitiesUtilities

System engineers primarily use the data System engineers primarily use the data related to system statusrelated to system status

One of the most effective utilities for One of the most effective utilities for auditing system performance is the top auditing system performance is the top commandcommand

The top command displays a listing of the The top command displays a listing of the most CPU-intensive tasks, such as the most CPU-intensive tasks, such as the processor state processor state

Page 27: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

2727

Applying System Status Applying System Status UtilitiesUtilities

The top utility run without any options specified

Page 28: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

2828

Applying System Status Applying System Status UtilitiesUtilities

To kill the top utility process, enter k and specify the PID to terminate

Page 29: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

2929

Applying System Status Applying System Status UtilitiesUtilities

You cannot killthe top utility when run in secure mode

Page 30: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

3030

Page 31: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

3131

Applying System Status Applying System Status UtilitiesUtilities

The free utility displays the amount of free and used memory in the system

Page 32: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

3232

Applying System Status Applying System Status UtilitiesUtilities

The ps command shows a list of processes associated with the current login session that are currently running

Page 33: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

3333

Applying System Status Applying System Status UtilitiesUtilities

The ps command with the –A option shows a list of all system processes currently running

Page 34: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

3434

Lesson BLesson B

Working with theWorking with the

Text-Formatting File Utilities Text-Formatting File Utilities

Page 35: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

3535

ObjectivesObjectives

Check the spelling of text in a documentCheck the spelling of text in a document

Use the cmp command to compare the Use the cmp command to compare the contents of two filescontents of two files

Format text to create a man pageFormat text to create a man page

Use the groff utility to test a man page you Use the groff utility to test a man page you have createdhave created

Use the man utility to view a man page you Use the man utility to view a man page you have createdhave created

Page 36: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

3636

Checking the SpellingChecking the Spellingof a Documentof a Document

Ispell scans a document, displays errors on the screen and suggests alternative spellings

Page 37: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

3737

Comparing FilesComparing Files

Use the cmp utility to compare the Use the cmp utility to compare the contents of two files, and report the first contents of two files, and report the first difference between themdifference between them

The cmp command displays the character The cmp command displays the character position and line number of this differenceposition and line number of this difference

If there are no differences, the cmp If there are no differences, the cmp command displays nothingcommand displays nothing

Page 38: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

3838

Formatting Text in UNIXFormatting Text in UNIXText formatting in UNIX involves preparing a text Text formatting in UNIX involves preparing a text file with embedded typesetting commands and file with embedded typesetting commands and then processing the marked-up text file with a then processing the marked-up text file with a computer programcomputer program

UNIX’s nroff and troff commands are often used UNIX’s nroff and troff commands are often used to process the embedded typesetting commands to process the embedded typesetting commands to format the outputto format the output

An embedded code is a special sequence of An embedded code is a special sequence of characters that is included with the regular text characters that is included with the regular text of the fileof the file

Page 39: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

3939

Formatting Text in UNIXFormatting Text in UNIX

Linux introduced groff, which implements the features of both nroff and troff

Page 40: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

4040

Formatting Text in UNIXFormatting Text in UNIX

Groff can be used to produce a man page that contains the standard man page sections

Page 41: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

4141

Formatting Text in UNIXFormatting Text in UNIX

Man pages are made available to others by having a supervisor user copy it to one of the man page directories

Page 42: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

4242

Chapter SummaryChapter Summary

UNIX utilities are classified into seven major UNIX utilities are classified into seven major functional areas dictated by user needs: file functional areas dictated by user needs: file processing, networking, communications, processing, networking, communications, system status, programming, source code, system status, programming, source code, management, and miscellaneous tasksmanagement, and miscellaneous tasks

Utility programs are distinguished from other OS Utility programs are distinguished from other OS programs, because they are add-ons and not a programs, because they are add-ons and not a part of the UNIX shells part of the UNIX shells

Because utility programs are executed by Because utility programs are executed by entering names on the command line, they are entering names on the command line, they are commonly referred to as commandscommonly referred to as commands

Page 43: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

4343

Chapter SummaryChapter Summary

The dd command possesses a rich set of The dd command possesses a rich set of options that allow it to handle copies when options that allow it to handle copies when other copying methods failother copying methods fail

To make a bootable floppy disk, use four utility To make a bootable floppy disk, use four utility programs: rdev, mkfs, fdformat, and ddprograms: rdev, mkfs, fdformat, and dd

The rdev command queries and sets the root The rdev command queries and sets the root devicedevice

The fdformat command performs a low-level The fdformat command performs a low-level format on a floppy diskformat on a floppy disk

The mkfs utility sets up a file systemThe mkfs utility sets up a file system

Page 44: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

4444

Chapter SummaryChapter Summary

The df utility checks and reports on free disk The df utility checks and reports on free disk spacespace

The du command checks for disk usageThe du command checks for disk usage

Use the find command to retrieve wasteful files Use the find command to retrieve wasteful files and then use the rm command to remove themand then use the rm command to remove them

The top and free utilities provide detailed views The top and free utilities provide detailed views of the “internals” of the systemof the “internals” of the system

Redirect output of the top and free commands Redirect output of the top and free commands to a disk file to use as input for a report to the to a disk file to use as input for a report to the system administratorsystem administrator

Page 45: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

4545

Chapter SummaryChapter Summary

Run a program in the background by Run a program in the background by appending the & operator to the end of a appending the & operator to the end of a command linecommand line

The ps command displays all processes The ps command displays all processes currently runningcurrently running

The kill command terminates a specific The kill command terminates a specific processprocess

The utility that checks spelling, ispell, scans a The utility that checks spelling, ispell, scans a document for typing errorsdocument for typing errors

Page 46: Chapter Eight Exploring the UNIX Utilities. 2 Lesson A Using the UNIX Utilities.

4646

Chapter SummaryChapter SummaryText formatting involves embedding typesetting Text formatting involves embedding typesetting commands in a file, and then processing the commands in a file, and then processing the the marked-up file with a program that the marked-up file with a program that generates commands for the output devicegenerates commands for the output device

The text containing the embedded typesetting The text containing the embedded typesetting commands is processed by a program like commands is processed by a program like nroff and troff that formats the outputnroff and troff that formats the output

Linux introduced groff, which implements the Linux introduced groff, which implements the features of both nroff anf trofffeatures of both nroff anf troff

Those who have supervisor privileges most Those who have supervisor privileges most often create man pagesoften create man pages