-------------------------------------------------------------------
Copyright © 2007 Richard J. Gaydos.
-------------------------------------------------------------------
CIS 3735 Chapter 3 An Introduction to the Utilities
-------------------------------------------------------------------
Summary of Utilities
-------------------------------------------------------------------
Utilities to Examine Files
ls Displays a list of files
file Displays info about the contents of a file
cat Displays the contents of a File on the Terminal
pg or more Display file, screen-at-a-time
head Displays the beginning of a file
sed Display beginning of file
tail Display the end of a file
uniq Display contents of a file, skipping successive
duplicate lines
diff Display the differences between two files
grep Searches for a specific string in a file
find Searches for a specific file in a directory
-------------------------------------------------------------------
Utilities to Manipulate Files
vi Edit a text file
lp Print a text file
cp Copy a File
mv Change the name of a file
rm Delete a file
sort Sort a File
compress Shrink File in Size
zcat Display contents of a compressed file
uncompress Restore a compressed file
-------------------------------------------------------------------
Utilities Related to Other Users
w or who Display a list of who is logged on
finger Displays detailed info about users
write Send a message to another user
talk Supports online conversation
mesg Permit or Deny messages sent by write or talk
mailx Send and receive mail
-------------------------------------------------------------------
Utilities Related to Commands
passwd Change password
date Display Time, Day of Week, Date
man Display info on utilities
whereis Display the pathname of a utility
which Displays the full pathname of a command you can run
echo Displays a line of text on the terminal
-------------------------------------------------------------------
Detailed Explanations of Utilities
-------------------------------------------------------------------
Utilities to Examine Files
-------------------------------------------------------------------
ls Displays a list of files
Example(s)
ls Get list of files in the current directory
------------------------------------------------------------------
file Displays info about the contents of a file
Example(s)
file first Get info about first
-------------------------------------------------------------------
cat Displays the contents of a File on the Terminal
Example(s)
cat first See the contents of first
-------------------------------------------------------------------
pg or more Display file, screen-at-a-time
Example(s) - Refer back to Chapter 2
-------------------------------------------------------------------
head Displays the beginning of a file
Example(s)
head first Displays the first 10 lines of first
head -3 first Displays the first 3 lines of first
-------------------------------------------------------------------
sed Display beginning of file
Example(s)
sed 10q first Displays the first 10 lines of first and quits
-------------------------------------------------------------------
tail Display the end of a file
Example(s)
tail first Displays the last 10 lines of first
tail -3 first Displays the last 3 lines of first
-------------------------------------------------------------------
uniq Display contents of a file
skipping successive duplicate lines
Example(s)
uniq first Displays first, skipping adjacent duplicate lines
-------------------------------------------------------------------
diff Display the differences between two files
Example(s)
diff one two Displays a list of Differences between one and
two
NOTE: diff assumes you want to change the first into the
second
NOTE: diff includes a, d, c suggestions and arrows
to flag lines,
< for lines from the first file, and
> for lines from the second file
-------------------------------------------------------------------
grep Searches for a specific string in a file
Grep = Global Regular Expression Print
Example
grep 'hockey' sports Searches for the string hockey in the
file sports
NOTE: Quotes are necessary only if your search string
includes spaces and/or special characters
-------------------------------------------------------------------
find directory -name filename
Example
find . -name lab1.cc Finds all lab1.cc on your account
-------------------------------------------------------------------
Utilities to Manipulate Files
-------------------------------------------------------------------
vi Edit a text file
Example(s)
vi first Edits first
-------------------------------------------------------------------
lp Print a text file
Example(s)
lp -d p30xy filename,
where x = 1, 2 or 3
y = a or b
-------------------------------------------------------------------
cp Copy a File
Example(s)
cp first second Copies first into second
cp source destination Copies source to destination
Need COMPLETE pathnames unless source and/or destination are
in current directory
WARNING Destination will be OVERWRITTEN if it already exists !
-------------------------------------------------------------------
mv Change the name of a file
Example(s)
mv first third Renames the file first as third in the
directory
NOTE mv does other things (More in future chapters)
-------------------------------------------------------------------
rm Delete a file
Example(s)
rm first Deletes first
-------------------------------------------------------------------
sort Sort a File
Example(s)
sort first Sorts the lines in first
-------------------------------------------------------------------
compress Shrink File in Size, eliminating redundant data by
one copy and formulas
Example(s)
compress first Produces the file first.Z
compress -v first Produces the file, AND a message about the
compression
-------------------------------------------------------------------
zcat Display contents of a compressed file
Example(s)
zcat first.Z Displays contents in uncompressed form
-------------------------------------------------------------------
uncompress Restore a compressed file
Example(s)
uncompress first.Z Produces first
-------------------------------------------------------------------
Utilities Related to Other Users
-------------------------------------------------------------------
w or who Display a list of who is logged on
Example(s)
who Get ID, Terminal Number, Time logged in
who am i Your own info
w Like who, but part of BSD (Berkeley Software
Distribution) package
-------------------------------------------------------------------
finger Displays detailed info about users
Example(s)
finger Get Login ID, REAL Name, (*) indicating mesg off,
Terminal Number, How long idle,
When they logged in, Where they are
finger rick Get DETAILED info on user rick
.plan file on rick’s account (if it exists) will
display
-------------------------------------------------------------------
write Send a message to another user, LINE BY LINE
Example(s)
write rick Set up one-way communication with rick
Type in you message LINE AT A TIME
^-d to end the transmission - rick sees EOT
write rick term# To direct the messages to terminal term#
if rick is logged in on
more than one terminal
-------------------------------------------------------------------
talk Supports online conversation, CHARACTER BY CHARACTER
Example(s)
talk rick To talk to rick
Divides screen into Top Half: What YOU type
Bottom Half: What rick types
^c to end the session
-------------------------------------------------------------------
mesg Permit or Deny messages sent by write or talk
Example(s)
mesg n Deny messages
mesg y Permit messages (This is the default)
-------------------------------------------------------------------
mailx Send and receive mail
Example(s)
mailx rick To SEND mail to rick
Type in the lines, end each with RETURN
Type in ^-d to send the mail & get back
to the shell
mailx To RECEIVE mail
Get this of info:
mailx version v.v Type ? for help
"/.../your-mailbox": n messages n new
>N 1 user date sent time #lines/#characters subject
N 2 user date sent time #lines/#characters subject
N 3 user date sent time #lines/#characters subject
mailx Commands
RETURN Read current message
t# Display message number #
d# Delete message number #
Any NON-Deleted messages
are saved in the file mbox
q Quit mailx
-------------------------------------------------------------------
Utilities Related to Commands
-------------------------------------------------------------------
passwd Change password
Example(s) - Refer back to Chapter 2
-------------------------------------------------------------------
date Display Time, Day of Week, Date
Example(s)
date See Date, Time, Year
-------------------------------------------------------------------
cal Displays a calendar
Example
cal Get calendar
cal 5 2005 Get May 2005 calendar
-------------------------------------------------------------------
man Display info on utilities, etc. ...
The UNIX System Manual
1 User Commands
2 System Calls
3 C Library Functions
4 Devices and Network Interfaces
5 File Formats
6 GAMES and Demos
7 Environments, Tables, and troff Macros
8 System Maintenance
Example(s)
man write See ALL manual pages on write
man -s 1 write See User Command info on write
man -k topic Get list of manual section(s) that have info on
topic
-------------------------------------------------------------------
whereis Display the pathname of a utility
Example(s)
ping rick Get message: ping not found
whereis ping Gives the full path to get to the code for the ping
command
/.../.../ping rick To execute the command
NOTE: NOT part of SVR4, but BSD compatible
-------------------------------------------------------------------
which Displays the full pathname of a command you can run
Example(s)
which ping Show the path to ping, so you know which
version ran
NOTE: NOT part of SVR4, but BSD compatible
C shell only
-------------------------------------------------------------------
echo Displays a line of text on the terminal
Example(s)
echo Hi See Hi at the terminal
Used by shell programs to send messages
to the terminal
-------------------------------------------------------------------