Welcome to the SUNY Oswego
UNIX system primer!

This page should make it easy for anyone to get started on the computer
system at SUNY Oswego. On your left you can see a menu of choices, just
click on any one of the links, and the topic will appear in this window. If
you want to start over just hit the reset button at the bottom of the menu.
If you are a beginner the best way to begin using the system is the link
for the top ten commands; it just might be all you'll ever need to know about
the UNIX system at SUNY Oswego.
 
 
 
 
 
 
 

What is UNIX?

UNIX is a computer operating system (OS.) that originally was developed in AT&T laboratories in the early 1970's. It is capable of running on many different types of computer hardware, which has made it a very popular OS.. At Oswego the computer that you are most likely to use UNIX on is called rocky. The interface that this system uses is a command prompt where a user types various messages (commands) to the system; the system responds to users on the same prompt. There are hundreds of commands available on the UNIX system, but most users can get by only knowing a few of them.
 
 
 
 
 
 
 

SUNY Oswego's Top Ten UNIX commands

#1 pine

pine   Enter

This starts the email program called pine. Pine is a menu driven program, which means the user scrolls though a list of choices to uses the program's features. In order to use pine you must have an address to send an email message to. An email address has the following form:

Username@computerName.domain

An Oswego state email address looks like this:

hubbabubba@oswego.edu

If you used the name 'hubbabubba' to log onto rocky then this is your email address! Most likely though, you used some other name. If you want to see how pine works, start the program and scroll up to the COMPOSE option in the main menu, hit the enter key. This will open the composer, and the cursor is automatically defaulted to the space where the address is to be entered. Type in your username followed by '@oswego.edu'. Next, hit the Enter key three times and enter a subject, such as 'testing 1-2-3'. Hit Enter again and type a short message to yourself. When all that is done hold down the control key (usually found on the lower left of the keyboard) and hit the x key. This will send your message to yourself; it should arrive in less than a minute. To read your message, go to the FOLDER LIST option on the main menu and hit enter, hit enter again to open the INBOX folder, you should see your message in the list. Scroll down to your message and read it by hitting Enter again. This concludes the brief of pine which is all many people need to know about UNIX. If you want to know more about Pine hit the question mark key while in pine to access help, and always read the options listed on the bottom of the screen.

#2 ls

ls   Enter

This command will list the contents of a directory. For more on ls click here.

#3 cd

cd 'directory-name'   Enter

Use this command to change the current directory to another directory. The 'directory-name' could be the direct child of the current directory or it could be a directory at the end of a pathname. If the user wants to go backwards to the parent of the current directory the command looks like this,

cd ..

Don't forget the space between the cd and the two periods! For more on cd click here.

#4 pwd

pwd   Enter

This is a simple command that tells the user what directory they are currently in.

#5 print

print 'document-name'   Enter

This sends a document (usually text) to be printed out one of the Oswego system printers. A dialog box will prompt the user to choose on of 5 printers; all at different locations. It takes 15-20 minutes to actually get the printout, so be patient.

#6 passwd

passwd   Enter

If you want to change your login password, this is the command to use. It starts a dialog that will prompt you for all that is needed to change your password.

#7 mkdir

mkdir 'directory-name'   Enter

This is how a user creates a new directory on UNIX. Simply navigate to the directory you wish to make new directories branch off of, and type the command with the new directories' name in the 'directory-name' position. For more on mkdir click here.

#8 cp

cp 'file-name' 'destination'   Enter

This command copies files from one directory to another. The 'filename', and 'destination are often pathnames. However, there is often a need to copy a file from one pathname/directory to the current directory. This is done through using a '.'(period) in place of the destination. Here is an example:

cp first-dir/second-dir/destination-dir/file.txt .

This example would copy the file named 'file.txt' that is in the destination-dir to the current directory using ls to list the files in the current directory is a good way to test if your commands worked.

#9 finger

finger 'username'   Enter

This command has a funny name but it is very useful, not only as a source for obvious jokes, but as a UNIX command. Finger allows a user to see what other users on the system are doing at the moment. It is best shown by an example

     you type this
               |
rocky>finger smith
    you get this
Login name: smith    In real life: john jackob jinglehiemersmith
Directory: /users/sec_ed_span_ba/smith Shell: /etc/tcsh
Last login Tue Feb 17 11:41 on pts/56 from pemac02.oswego.e
Mail last read Tue Feb 17 11:41:54 1998
No Plan.

This command tells you many things about the specified user. In real life means the persons full name It tells you when they have last read their mail, and several other good things.

#10 talk

talk 'username'   Enter

Talk opens a 'chat' session with the specified user. You might want to finger a user to find out if they are on the system and then invite them for a chat with talk. Talk will send a message to the user that you want to talk to, and if they want to talk they will type the talk command with your username and then hit enter. This series of events will split your screen in two with one user typing in the top and the other typing in the bottom of the screen. Make sure that if you use this that your friend knows how to use the command as well. 
 
 
 
 
 
 
 
 
 

Directory commands


 
 
 
 
 
 
 
 
 

cd - change directory

 - used to change the current directory. This command is followed
by a space and directory path, or a space and two periods (..).

ex-1: >cd directory1/directory2/final
      >pwd
      >final
this command makes the directory called final the current directory.

ex-2: >cd ..
      >pwd
      >directory2
this command causes the current directory to be the previous directory.
if this command were to be executed when the current directory is "final"
then the current directory would become directory2.
 
 
 
 

ls - list files in a directory

ls - used to lists the contents of a directory. This command is often used 
with several UNIX switches which include:
 -R , lists the contents of all subdirectories
 -l , gives a long list of the directory

ex-1: > ls
      > nextDirectory   Graphic.JPG  oneFile.txt  twoFile.txt  database.db 

In this example the first item is a directory itself. The other four are files 
within the directory.

ex-2: > ls -R firstdir/
        firstdir/:
        2nddir  file1   file2

        firstdir/2nddir:
        file1  file2
        >

This example shows how the -R switch reveals the entire tree of 
sub directories and there contents as well.

ex-3: > ls -l
        total 2
        drwxr-xr-x   2 smith    10132         512 Feb 10 11:56 2nddir
        -rw-r--r--   1 smith    10132           0 Feb 10 11:57 file1
        -rw-r--r--   1 smith    10132           0 Feb 10 11:57 file2
        >       
             |          |         |             |&

nbsp;       |      |
             |          |         |             |&

nbsp;       |      |
             |          |         |             |&

nbsp;       |      name of file
           file         |         |             |   las

t modified
        permissions   Owner      group     size of file                  &n

bsp;      
                       of                    in by

tes
                      file

The text below the output explains what each peice of information means.

pwd - print the working directory

pwd - prints the current directory, its use is very simple.

ex-1: > > pwd
        /csclass/info_sci_ba/smith/public-html/classes/firstdir 

This command will print out the entire directory path of the current 
directory.

mkdir - makes a new directory

mkdir - creates a new directory that will become a subdirectory of the current
directory.

ex-1: > pwd
        /csclass/info_sci_ba/smith/public-html/classes
        > ls
        csc241
        > mkdir newdir
        > ls
        >csc241    newdir

From this example you can see that the current directory is classes and it 
now contains two subdirectories one called csc241, and the new one called 
newdir.

rmdir - removes a directory

rmdir - removes the specified directory provided that it is empty, to remove 
files from the directory see the rm command.

ex-1:   >ls
        >csc241    newdir
        > rmdir newdir
        >ls
        >csc241    

The rmdir command does not tell you what has been done it simply returns
a prompt. This leaves it up to the user to verify that it has worked, as you 
can see the ls command lets us see that the directory has been removed.

chmod - changes the mode (permissions) of a directory or file

chmod - this command lets the user set permissions on files and directories,
provided that the user is the owner of the files or directories. Chmod is 
often used to make files accessible to the world wide web. The format of the 
command in a very simple way is as follows:

chmod  operator 

 refers to what users you are
 setting the mode for, options are: 

                    u         user's permissions
                    g         group's permissions
                    o         others' permissions
                    a         all permissions (user,  group,  and
                              other) 
            
operator is a + or a - symbol meaning "give" and "take away" permissions
respectively.

 refer to what permissions 
you want to change they are:
                   r -  permission for  to read a file or directory
                   w -  permission for  to write to the file or directory       
                   x -  permission for  to execute (search through)
                        the file or directory 

In order to address the permissions of a directory, the current directory 
must be the parent (in the directory tree) of the directory that you want 
to address.  In order to address the permissions of a file you must
specify the correct pathname.  Chmod does not make much sense out of 
context so here are a couple of examples.

The form, chmod  operator 

ex-1: chmod g-r firstdir

This example takes the permission of groups to read the directory called 
firstdirectory. Groups will no longer be able to see what is in this 
directory.

ex-2: chmod a+rx public-html

This example gives permission to all people to read and execute the 
directory called public-html.  This is needed on rocky to make web pages 
accessible to the World Wide Web. 

ex-3: chmod ug+rwx privateFile.txt

This example give permission for users and groups to read, write, and execute
privateFile.txt. This might not be a good idea if the file needs to be kept 
private. A better set of permissions is set in the following example.

ex-4: chmod ugo-rwx privateFile.txt

Here we see that chmod will remove permission for users, groups, and other
to read, write, or execute privateFile.txt.  Even in the case that the directory
that contains privateFile.txt is r,w, and x privateFile.txt will not be able
to be seen or written to by anyone including the user! Which admittedly makes 
little sense.

ex-5: chmod a-r+x-w firstdir

This chmod takes away permission of all to read firstdir.  It also gives all 
permission to execute the directory, and takes away all's permission to write 
to firstdir.  This kind of a setup is useful if you have private files in  
firstdir and you need users to pass through it in order to read files in one
of firstdir subdirectories. 

 all==> prevdir(a+rx-w) ==> firstdir(a-r+x-w) ==> nextdir(a+rx-w)
                |               |             

;          |
             files to        private                 files to   
               read           files                &nbs

p;   read

 
 
 
 
 
 
 
 
 
 

File Commands


 
 
 
 

cp 'file-name' 'destination'   Enter

This command copies files from one directory to another. The 'filename', and 'destination are often pathnames. However, there is often a need to copy a file from one pathname/directory to the current directory. This is done through using a '.'(period) in place of the destination. Here is an example:

cp first-dir/second-dir/destination-dir/file.txt .

This example would copy the file named 'file.txt' that is in the destination-dir to the current directory using ls to list the files in the current directory is a good way to test if your commands work 
 
 
 
 

rm 'filename'   Enter

This command is very simple to use. It will not tell the user if the file has been removed, so it is up to the user to use the alias that will make the system ask your permission before it deletes a file. 
 
 
 
 

print 'document-name'   Enter

This sends a document (usually text) to be printed out one of the Oswego system printers. A dialog box will prompt the user to choose on of 5 printers, all at different locations. It takes 15-20 minutes to actually get the printout, so be patient. 
 
 
 
 

more 'file-name'   Enter

more : more 'file-name'

This does the same thing as print, but instead of printing the 
file to one of the printers it prints the files contents to the
screen.
        ex-1: 
                rocky-gw> more file1.txt
                          this is the
                          contents of
                          a file that is
                          printed to the
                          screen

 
 
 
 

head -'number-of-lines' 'file-name'   Enter

                
head : head -'number-of-lines' 'file-name'
This command will let you view the first three lines of a file,

ex-1:   rocky-gw> head -3 firstThree
                this file is an example to show how the
                first three lines of a file
                might look if the head command is used. It should show only the 
        rocky-gw> 

the user can choose any number of lines to display 
by changing the value of the 'number-of-lines' switch.

 
 
 
 

mv 'file-name' 'new-file-name'   Enter

mv : mv 'file-name' 'new-file-name' Or  
     mv 'directory-name' 'new-direstory-name'

Using mv it is possible to rename a directory or file.
In order to rename a file, the file must be in the current 
directory, or specified through a pathname. In order to 
rename a directory the current directory must be below the 
directory to be changed
  
ex-1:   rocky-gw> ls *.txt
                old-name.txt
        rocky-gw> mv old-name.txt new-name.txt
                rocky-gw> ls *.txt
                new-name.txt
        rocky-gw>

mesg '-switch'   Enter

mesg : mesg -switch

This command used without a switch will tell you 
how the user messages are set.

ex-1:   rocky-gw> mesg
                  is y
        rocky-gw>