Essential Unix commands

Essential Unix commands


     If you connect to the Net through a Unix system, eventually you'll
have to come to terms with Unix.  For better or worse, most Unix systems
do NOT shield you from their inner workings -- if you want to copy a
Usenet posting to a file, for example, you'll have to use some Unix
commands if you ever want to do anything with that file.
     Like MS-DOS, Unix is an operating system - it tells the computer how
to do things.  Now while Unix may have a reputation as being even more
complex than MS-DOS, in most cases, a few basic, and simple, commands
should be all you'll ever need.
     If your own computer uses MS-DOS or PC-DOS, the basic concepts will
seem very familiar -- but watch out for the cd command, which works
differently enough from the similarly named DOS command that it will
drive you crazy.  Also, unlike MS-DOS, Unix is case sensitive -- if you
type commands or directory names in the wrong case, you'll get an error
message.
     If you're used to working on a Mac, you'll have to remember that
Unix stores files in "directories" rather than "folders."  Unix
directories are organized like branches on a tree. At the bottom is the
"root" directory, with sub-directories branching off that (and
sub-directories in turn can have sub-directories). The Mac equivalent of
a Unix sub-directory is a folder within another folder.

cat           Equivalent to the MS-DOS "type" command.  To pause a file
              every screen, type

                        cat file |more

              where "file" is the name of the file you want to see.
              Hitting control-C will stop the display.  You can also use
              cat for writing or uploading text files to your name or home
              directory (similar to the MS-DOS "copy con" command).  If you
              type

                        cat>test

              you start a file called "test."  You can either write
              something simple (no editing once you've finished a line and
              you have to hit return at the end of each line) or  upload 
              something into that file using your communications software's
               ASCII  protocol).  To close the file, hit control-D.

cd            The "change directory" command.  To change from your present
              directory to another, type

                        cd directory

              and hit enter. Unlike MS-DOS, which uses a \ to denote sub-
              directories (for example: \procomm\text), Unix uses a / (for
              example: /procomm/text).  So to change from your present
              directory to the procomm/text sub-directory,  you would type

                        cd /procomm/text

              and then hit enter. As in MS-DOS, you do not need the first
              backslash if the subdirectory comes off the directory you're
              already in.  To move back up a directory tree, you would type

                        cd ..

              followed by enter. Note the space between the cd and the two
              periods -- this is where MS-DOS users will really go nuts.

cp            Copies a file. The syntax is

                        cp file1 file2

              which would copy file1 to file2 (or overwrite file2 with
              file1).

ls            This command, when followed by enter, tells you what's in the
              directory, similar to the DOS dir command, except in
              alphabetical order.

                        ls | more

              will stop the listing every 24 lines -- handy if there are a
              lot of things in the directory. The basic ls command does not
              list "hidden" files, such as the .login file that controls
              how your system interacts with Unix. To see these files, type

                        ls -a      or    ls -a | more

              ls -l will tell you the size of each file in bytes and tell
              you when each was created or modified.

mv            Similar to the MS-DOS rename command.

                        mv file1 file2

              will rename file1 as file2, The command can
              also be used to move files between directories.

                        mv file1 News

              would move file1 to your News directory.

rm            Deletes a file.  Type

                        rm filename

              and hit enter (but beware: when you hit enter, it's gone for
              good).


WILDCARDS:  When searching for, copying or deleting files, you can use
"wildcards" if you are not sure of the file's exact name.

              ls man*


would find the following files:

              manual, manual.txt, man-o-man.

Use a question mark when you're sure about all but one or two characters.
For example,

              ls man?

would find a file called mane, but not one called manual.