Simple UNIX Commands for The World

Table of Contents


An Introduction to UNIX Commands

The unix command-line format offers a great deal of flexibility and power to the user. The general command line format for unix follows:

world% command options filename

A simple unix command will contain only the command. In this document simple commands are prefixed by the phrase Command:. A detailed example of a command is prefixed by the phrase Example:.

The options, or flags, for unix commands are prefixed with a dash or hyphen. These options come directly after the command and before any filenames.

Example: sz -a my.file

Many unix commands require filename arguments. In this document filenames are indicated by file1 or file2. Whenever you see this in an example, you can replace it with the name of the document you wish to create, access or view. Many commands can be issued with more than one filename.

Also in this document optional values are indicated by where the keyword describes an optional value that you select.

Every command should be followed by a carriage-return or enter. The command will not be invoked until you press this key.


Appending One File onto Another File

Command: cat file1 >> file2

The special characters >> will append the contents of file1 to the end of file2


Calendar

Command: cal month year

Example: cal 3 1993

	   March 93
	 S  M Tu  W Th  F  S
                        1  2
	 3  4  5  6  7  8  9
	10 11 12 13 14 15 16
	17 18 19 20 21 22 23
	24 25 26 27 28 29 30
	31

Example: cal 93

This will display the calendar for the entire year of 1993.


Change To Another Directory

Command: cd directory

Use this command to change from the present directory to another directory.

Example: cd /pub

Example: cd /sources/macintosh/archivers

A / (slash) at the beginning of a pathname means "begin at the root directory". This is similar to beginning at the desktop on a Macintosh, or begining at C:\ on a PC.

Example: cd ..

The command cd followed by two periods will take you to the directory one level above the directory you are currently in. For example, if the path to your current directory is /sources/macintosh, typing cd .. would change it to /sources.


Change Directory To Home

Command: cd ~

Use this command to change the directory back to your home directory (the directory where your personal files are stored). The ~ (tilde) can always be used as a substitute for the path to your home directory.


Compress a file

Command: gzip file1

Example: gzip Shakespeare.complete

The Shakespeare.complete file will be compressed, renamed Shakespeare.complete.gz, will take up less disk space and will require less time to download. Files compressed with gzip usually end with .Z, .z, or .gz


Copy a File

Command: cp file1 ile2

Example: cp roach-attack bugs

This will create a copy of the file roach-attack with the new name bugs. Another useful example follows.

If you were in the directory /ftp/obi/Martin.Luther.King, you could make a copy of a famous Martin Luther King speech to be placed into your home directory with the command:

Example: cp free.at.last ~

The tilde "~" here refers to your home directory (see Changing to your Home Directory) and the filename will remain unchanged. Once you issue this command, a copy of the document free.at.last is added your home directory.


View the Current Directory

Command: pwd

Example: pwd

The pwd stands for "present working directory" and shows what directory you are in. It indicates the exact path from the root. The root is the top level of the unix file system, similar to the desktop on a Macintosh, or C:\ on a PC.


Viewing the Current Date and Time

Command: date

Use this command to get the date and time of day.


Decompress File

du Command: gunzip file1.gz

Example: gunzip reading.txt.gz

The file reading.txt.gz then becomes reading.txt without the suffix .gz. Compressed files usually end with .Z, .z, or .gz.

You can read compressed ASCII text files on World without uncompressing them. The special command gzcat will display the compressed file.

Command: gzcat filename.gz

These compressed files can also be uncompressed on a Mac or PC after downloading. This can save time during the download, as the compressed file will be smaller. Your Mac or PC will need the Unix compress software. These programs can be found in the following directories on World:

PC utilities: /sources/pc/archivers/gzip

Mac utilities: /sources/mac/archivers/stuffit/expander


Showing Disk Space Used

Command: du -k

Disk usage is the total amount of disk space your account is allocated on World. If your saved mail or other files are large, you may go over your quota and receive a warning message.


Edit a File

Command: pico file1

Example: pico memo.john

Pico will invoke the text editor used by Pine. This program has menus and uses arrow keys. If the file specified does not exist, pico will create a new one by that name. Pico is very user-friendly.

Vi, the text editor found on most UNIX systems, is also available.

Emacs (also on World) is a text editor of exceptional power and complexity. It features a built-in online tutorial and help system. A potent tool in the hands of an expert, it can do far more than edit text. To its devotees, Emacs is not simply an editor, but a way of life.

The commands needed to use emacs or vi effectively are rather complex, so we recommend user-friendly Pico.


File Transfer (Sending to your PC or Mac) Zmodem ASCII

Command: sz -a file1

If you are in the help directory and wish to download the World help file "Primer", just type:

Example: sz -a Primer

To do this from your home directory, type the command:

Example: sz -a /help/Primer

The sz tells World to send the file using the Zmodem file transfer protocol. The -a indicates to send the file as a plain ASCII file. Any file that is in a format other than plain text, such as a Microsoft Word document or a shareware program, must be transferred in binary mode.

The command sz is used to "download" a file from World to your computer. To receive a file, you must tell your communications program to "Receive Zmodem". Many telecom programs receive a Zmodem download automatically.

To abort a file transfer, use the keystroke "control-x". You may need to hit "control-x" several times to interrupt the transfer.


File Transfer (Sending to your PC or Mac) Zmodem Binary

Command: sz -b file1

Example: sz -b maccompress.sit

Example: sz -b kipling.Z

Example: sz -b shareware.application

The command sz tells World to send the file using the Zmodem file transfer protocol. The -b means to send the file as a binary transfer. Any file created from a word processsor or an application (program), such as a piece of shareware, is binary and must be uploaded or downloaded using binary mode. This is also true for any files that are compressed.

The command sz is used to "download" a file from World to your computer. To receive it, you must tell your communications program to "Receive Zmodem". Many telecom programs receive a Zmodem download automatically.

To abort a file transfer, use the keystroke "control-x". You may need to hit "control-x" several times to interrupt the transfer.


File Transfer (Send to World) Zmodem ASCII

Command: rz -a

The rz tells World to receive this file using the Zmodem file transfer protocol. The -a means to transfer the file as a plain ASCII file.

Then, tell your communications prgam to start sending using the ZMODEM protocol.

To abort a file transfer, issue the command "control-x". Several "control-x" commands may be needed to interrupt the transfer.


File Transfer (Send to World) Zmodem binary

Command: rz -b

Example: rz -b

The rz tells World to receive the file using the Zmodem file transfer protocol. The -b indicates to send the file as a binary file. If the file is not a simple ASCII file, binary mode should be used. Any file created from a word processsor in non-ASCII format, or an application (program) such as a piece of shareware, is binary and must be uploaded or downloaded using binary mode. This is also true for any files that are compressed.

Then, tell your communications program to start sending using the ZMODEM protocol.

To abort a file transfer, issue the command "control-x". Several "control-x" commands may be needed to interrupt the transfer.


File Transfer Kermit (Send/Receive)

Command: kermit

When using Kermit, the World prompt becomes C-Kermit> and UNIX commands are no longer valid.

If you are sending from World to your local host, type:

C-Kermit> send file1

For example:

	world% kermit 
	C-Kermit> set file type binary 
	C-Kermit>
	send CV082122.GIF 
Then, tell your communications program to start receiving.

If you are sending from your local host to World, type:

C-Kermit> receive file1

For example:

	world% kermit 
	C-Kermit> set file type binary 
	C-Kermit> receive funthings
Then, tell your communications program to start sending.

To quit kermit, type: exit at the C-Kermit> prompt.


List File Sizes

Command: ls -s

Example: ls -s

	1 activists.dir
	2 chinese.food.brookline
	12 emacs-command-summary
	1 fun.internet.dir
	27 Internet.books.list
	1 key.letters.dir
	1 mail
	7 march.internet.hunt

This displays the size of the files. Directories will not show the size of their contents. Use the command du for this.


List File Type

Command: ls -F

Example: ls -F

	ACT_V.Macbeth                   
	Cyberspace.discussion                             
	News/
	Alt.Internet.services
	Mail/
In this example, Mail/ and News/ are directories. The remaining items are files.

A slash after a name indicates a directory. Other files will be stored in the directory.

Another symbol you might see looks like this: @

Example: obi@

This indicates that obi@ is a link, an alias which allows one file or directory to have multiple placements. You can access these aliases, just as if they were real, using the appropriate commands.

You may see another symbol *. This indicates the file is a World binary format and can only be used as a World command.


List Files

Command: ls

Use this command to display the files within the current directory.

It can be used selectively, as

Example: ls *92

This means display only those files whose names end with the numbers 92. The * character allows you to save a great deal of typing.

Other options exist for listing files in special ways. To list the files by date, use:

Example: ls -cl


List Invisible Files

Command: ls -a

This command shows all files in a directory, both visible and invisible. All files preceded by a period are normally invisible, and are not normally displayed when using ls. These files are often called dot files and are initialization files for the various programs. Some examples might be:

     .login       .cshrc       .newsrc      .mailrc


Make New Directory

Command: mkdir name

Example: mkdir tech.tips.collection

Use this command to create a new directory.


View the Manual Pages for a Command

Command: man command

Example: man mail

Example: man ls

This will give information (sometimes dry and verbose) about a given command or software. Once one learns how to read them without getting lost, they are quite useful.


Move File into a Directory

Command: mv file1 directory-name

Example: mv file.moving.tips tech.tips.directory

WARNING:If the second name is another file, this command will write the first file over the contents of the second file, thus eliminating the second file. Be sure this is what you want to do before using this command.

It is important to distinguish files from directories! Use the command "ls -F".

For example, if I type:

mv my.speech speech.list

and these are both *files*, the file my.speech will overwrite on top of the file speech.list If appending the contents of the first file to the end of the contents in the second file is preferable --not merely moving a file--use the command:

	cat my.speech >> speech.list


Change Password

Command: passwd

The machine will prompt you:

	Old password: (give your old password) 
	New password: (type in your new password) 
	Retype new password: (retype your new password to confirm it)


Remove directory

Command: rmdir directory-name

Example: rmdir old.files

Use this command to remove an empty directory. You must remove all contents or the command won't work.

To remove EVERYTHING from a directory, type

Command: rm directory-name/*

Example: rm News/* BE SURE YOU WANT TO DO THIS. You cannot undelete files on World.


Remove a File

Command: rm file1

Example: rm trash.this

Use this command to remove the named file. Any file you saved a few minutes ago will be gone. Some older files may be found on the World backups, but you must request a restore, which will take a least a day for the staff to perform.

To be safe, it is best to assume deletion is FINAL.


Rename a File

Command: mv file1 new-file1

Example: mv file.moving.tips tech.tips

Thus, the file called file.moving.tips will be renamed tech.tips.

   If the second name is an *existing* file, this command will
   overwrite the first file over the contents of the second file, 
   thus eliminating the second file. Be sure this is what you want 
   to do! Look before you leap with the "ls" command. 
If the second name is a directory (not a file), the file will be moved into the directory. See "Move File Into Directory".

To tell the difference between a file and a directory, use the command

Example: ls -F


Suspend an Operation

Command: control-z

The give the control-z command, chold down the control key, and simultaneously press z.

UNIX allows you to conveniently suspend processes you are engaged in. While reading mail, you may suddenly decide you want to read a file to obtain information to include in the letter. To suspend composing in the e-mail program called mail, type the control-z command:

        ^Z
        Suspended

There is a slight complication to suspending a Pine process: you have to start Pine with the command

Command: pine -z

in order for that session of Pine to respond to the control-z command. In UNIX, you can suspend several operations, and return to them anytime, right where you left off. To see which jobs are suspended, type:

Example: jobs

        [1]    Suspended              rn wstd.general
        [2]  - Suspended              pine -z
        [3]  + Suspended              more Well.conference.list
You can resume any job by typing a percent sign, followed by the number shown in the job lising:

Command: %1

If you have a job that you no longer want, you can get rid of it by using the kill command. Simply specify the job number on the command line.

Command: kill %1


View Usage Charges

Command: charges

Example: charges

Example: charges 7

This command will display your sessions and usage charges for the current month.

This command will display your sessions and usage charges for July.


View Contents of a File

Command: less file1

Example: more big.file

To view the contents of the specified file with pauses. Hit the spacebar to see the next portion. To view previous screenfuls, use b for "back." You can search for a specific word within the text by typing the following command at the : prompt. You must be in the : program to use the search command.

        /search.pattern


View Contents of a File Withput Pausing

Command: cat file1

Example: cat big.file

This displays the contents of a file in a rapid scroll without pausing. Use control-c to abort this.


Who is Online Now?

Command: who

This command displays a short list of all folks online at the moment the command is issued.


HOME Top of Help Desk Eye On The World  The World Kiosk


      This brings us to the end of this UNIX Command guide
      brought to you by Vedder Wright (vwright@world.std.com)
      and Will Donovan (70511.1317@compuserve.com) on behalf
      of Software Tool and Die. This document may be redistributed 
      as long as the following notice remains intact.

      This document was HTMLized and modified on January 5, 1995
                                   
                         Copyright by authors.
                         All rights reserved
                       
                        Permanent license granted 
                  (with deep appreciation and thanks) to
   Software Tool & Die, Inc., 1330 Beacon St. Suite 215 Brookline, MA 02146