Unix Tutorial

 

First you need an account on a computer with a Unix operating system. 

 

Macintosh users can just open a Terminal window (find the Terminal.app in the Utilities folder).  You donÕt need to login, you are automatically the Admin user on your own machine.

 

Windows users will need to make an ssh connection to a Unix server. Download the application Putty:
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

Then you need a server address, username, and password to login.

 

Once you login, make a listing of the contents of your home directory. (donÕt type the Ò%Ó symbol, it stands for the command prompt from the Unix shell)

show the location of your current directory:                                 %  pwd

Now create a text file. Type the following command:                   %  man cp > cp.txt

 

List your file:                                                                                      %  ls

Try the long listing                                                                            %  ls -l

Try list of all files:                                                                              %  ls –a

(this shows some files that are otherwise ÔinvisibleÕ)

 

Use the ÒmoreÓ command to read the text in your file:                          %  more cp.txt

Read just the top of the file:                                                                        %  head cp.txt

change file permissions for cp.txt so that no one can read or write it

                                                                                                            % chmod a-wr cp.txt

Read just the bottom of the file:                                                      %  tail cp.txt

(what just happened? – better change permissions back!)

Copy the first 25 lines of the file into a new file:  %  head -25 cp.txt > cptop.txt

 

Create a sub-directory called ÒEx1Ó (I like to use capitol letters for directory names):

%  mkdir  Ex1

Copy your cp.txt file into the Ex1 sub-directory:                                      %  cp cp.txt Ex1

Change directory to Ex1 and then list files:                                   %  cd Ex1

                                                                                                            %  ls

Go back to your home directory  (this can be done in several ways):

                                                %  cd ..           (go ÔupÕ one level)

                                                %  cd              (go back to home directory from anywhere)

Delete cp.txt from the Ex1 directory:                                             %  rm Ex1/cp.txt

List files in the Ex1 directory:                                                          %  ls Ex1

Move the both cp.txt and cptop.txt files to Ex1 directory:                       %  mv  *.txt  Ex1

List files in your home directory, and in the Ex1 directory:         %  ls ~

                                                                                                            %  ls Ex1

Delete all Ò.txtÓ files from Ex1, then delete directory Ex1:                       %  rm Ex1/*.txt

                                                                                                            %  rmdir Ex1