|
Commands and Utilities cp The UNIX command to copy a file or directory is cp. The basic cp command syntax is cp source destination. EXAMPLE: The command $cp ~/.profile ~/pcopy makes a copy of your .profile file, and stores it in a file called "pcopy" in your home directory. mv - The UNIX mv command moves files and directories. You can move a file to a different location in the filesystem, or change the name by moving the file within the current location. EXAMPLE: The command $mv ~/pcopy ~/qcopy takes the pcopy file you created in the cp exercise, and renames it "qcopy". lpr The lpr command tells the system that one or more files are to be printed on the default printer. If the printer is busy with another user's file, an entry will be made in the printer queue and the file will be printed after other lpr requests have been satisfied. The command line format is: $lpr file-spec-list $lpr Pmailroom filename ( it prints file filename to printer names mailroom) $lpq (print jobs that are in queue) $lpr job# (lets you remove a job# that is in que queue) grep - The grep program can be used to search a file for lines containing a certain string:
$ grep string filename $ grep -i string filename (case insensitive match)
or not containing a certain string: $ grep -v string filename
head It displays the first ten lines of a file
$head filename $head 1 filename (it will display the first line only)
tail It displays the last ten lines of a file
$tail filename $tail 1 filename (it will display the last line only)
sort It displays the contents of a file in order by lines
$sort filename
uniq It displays a file a file, skipping adjacent duplicate lines. Ie. There is a file called test with the contents: boy took bat home
The command $uniq test would display boy took bat home
diff -This utility compares two files and displays a list of the differences between them. IE. File m and its contents aaaaa
File n and its contents aaaaa
$diff m n output: 2d1 < bbbbb 2d1 = indicates that you need to delete the second line from file 1 m (bbbbb) to make the same as file 2 (n)
file It displays the information about a file $file letter_e.z
letter_e.z: gzip compressed data
echo This utility copies anything you put on the command line after echo $echo Hi Hi
$echo $TERM vt100
date It displays the current date and time gzip utility that compresses file $gzip filename it creates a file filename.gz
$gzip v filename (gzip reports how much it was able to reduce. gunzip and zcat -$gunzip filename.gz it restores the file to its original format
$zcat ginlename.gz it displays the contents of the file without decompressing it.
compress & uncompressit compresses a file $compress filename resulting in a file filename.Z
$uncompress filename.Z it uncompresses the file created with compress
tar (tape archive)
To combine multiple files and/or directories into a single file: tar -cvf file.tar inputfile1 inputfile2 -c, --create a new archive -v, --verbosely list files processed -f, --file [HOSTNAME:]F use archive file or device F (default /dev/rmt0) (saying that we to join files not create a tape archive) To separate an archive created by tar into separate files: tar -xvf file.tar
Finding Utilities and other Files which
i.e. which info whereis
apropos
Obtaining user and system information who-, who am i show who is logged on [wmorales@rc33uxas01 wmorales]$ who (user id) (terminal designation) (name of remote computer) dmichels pts/0 Jan 26 09:40(198.106.33.162) finger The finger displays information about the system users. [wmorales@rc33uxas01 wmorales]$ finger Login Name Tty Idle Login Time Office Office Phone qnguyen /0 Jan 26 13:34 (198.106.33.161) [wmorales@rc33uxas01 wmorales]$ finger-l Login: psheehan Name: Directory: /home/stu//psheehan Shell: /bin/bash On since Wed Jan 26 10:06 (PST) on pts/2 from fw1.tek.com 36 minutes 5 seconds idle No mail. No Plan. Login: wmorales Name: Directory: /home/fac/wmorales Shell: /bin/bash
-l Produces a multi-line format displaying all of the information de scribed for the -s option as well as the user's home directory, home phone number, login shell, mail status, and the contents of the files ``.plan'' and ``.project'' and ``.forward'' from the user's home directory. Finger may be used to look up users on a remote machine. finger foo@machine.com Try fingering these addresses:
w-
10:46am up 19 days, 4:55, 4 users, load average: 0.01, 0.00, 0.00 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT dmichels pts/0 198.106.33.162 9:40am 2:16 0.09s 0.04s -bash [wmorales@rc33uxas01 wmorales]$
Communication with other users write -
Message from yourname@yourhost on yourtty at hh:mm Type: write username What is up? CTRL-D (end of file) Turn it off by using $mesg n turn it on again using mesg y talk-
Type: talk username tty (if logged in more then once) user sees: When first called, talk sends the message Message from TalkDaemon@his_machine... talk: connection requested by your_name@your_machine. talk: respond with: talk your_name@your_machine
Email Pine Elm Mail mailx |
Back to
CS140U Homepage |