HOME Top of Unix Eye On The World  The World's Information Kiosk


Simple UNIX Commands for file-management

Table of Contents


An Introduction To Managing Files

To many of The World's new customers, understanding UNIX is the most daunting aspect of having an account that provides access to the Internet. Yet, UNIX is a widely-recognized and fairly easy operating system to learn. Moreover, you may not need to learn more than a dozen or so commands to use your account efficiently. If your needs resemble most of The World's new customers, this document will provide you with an understanding of most of the commands you'll ever have need of. If you find yourself interested in learning about additional UNIX commands not discussed here, please review the information presented in the UNIX help topic in this WWW help area.

An Overview

When you login to your account, you are placed automatically into your
home directory.  Configuration files needed to control your processes
reside in this area, as do any other files that you create or move there.
Each file has a filename that may consist of a single name, or a name
with a suffix and/or a prefix.  
Some examples:   
.login  
my.schedule  
phonelist
edit.session.3

You'll likely want to learn how to list, read, move, copy, remove and rename those files, view your directory pathname, create directories, change directory and view directory contents among other things. Before

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 is:

world% command options filename

The options, or flags, for unix commands are prefixed with a dash or hyphen. These options come directly after the command and before the 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 indicat 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.


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.


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


List File Size

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 File in Long Format

Other options exist for listing files in special ways. To view a long listing of information about the files in your directory, that includes file protections, file size, and date last edited, use:

Command: ls -la

Example: ls -la

-rw-rw-r--    1 freduser freduser     371 Jul 27  1993 .login
-rw-rw-r--    1 freduser freduser     729 Mar 17 23:07 .cshrc
-rw-r-----    1 freduser freduser    1558 Apr 17 12:43 sallys.humor
-rw-r-----    1 freduser freduser    9441 Mar 24 15:54 wired.info


View Contents of a File

Command: more file1

Example: more big.file

To view the contents of the specified file one page at a time 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 Without 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.


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.


Appending One File onto Another File

Command: cat file1 >> file2

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


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.


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.


Move or 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


View the Current Directory

Command: 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.

The output to this command for user jones would be:

world% pwd /home/ghar/jones


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.


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


Make New Directory

Command: mkdir name

Example: mkdir tech.tips.collection

Use this command to create a new directory.


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.

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. Please see the help file entitled "Diskspace limitations and your files" for further information surrounding this important issue.


HOME Top of Unix Eye On The World  The World's Information Kiosk


             For further assistance, please send an email 
                       request to support@world.std.com

        Copyright 1995 Software Tool & Die, Inc.  All Rights Reserved.

   Software Tool & Die, Inc., 1330 Beacon St. Suite 215 Brookline, MA 02146