CS1101: Laboratory 3b

Wrapping-up UNIX Basics

Academic Year 2006-2007

Lecturer: Dr. Barry O'Sullivan
Department of Computer Science
University College Cork

b.osullivan@cs.ucc.ie


Objective of this Lab

To familarise students with the basis UNIX commands for managing files and directories.


Background: Commands for Managing Files

The commands in Table 1 may be useful for completing the tasks listed below. If you need to view documentation on any command, simply type the following at the unix command prompt:

man <command name>
For example, to get help on the cp command, type:
man cp
Here are the commands you may need:

Command What it does
cd moves you to another directory
pwd tells you which directory you are in
mkdir creates a directory
rmdir removes a directory
ls lists the contents of a directory
ls -l lists the contents of a directory (long version)
vi or elvis edit/create a file
cp copies a file/directory
mv moves/renames a file/directory
rm removes a file/directory
file check the type of a file
more view the contents of a file by page

Table 1: UNIX commands which may be useful during this laboratory.


Tasks

You should complete the following tasks. The result will be a directory structure similar to the one presented in Figure 1, except where otherwise noted. Please also ensure that you can answer all questions on UNIX commands from the past exam papers once you've finished this exercise.

  1. Log-in to your accounts;
  2. Make sure that you are in your home-directory;
  3. Create 3 sub-directories of your home-directory: cs1100, cs1102 and cs1101;
  4. Change directory so that cs1101 is your current directory;
  5. Create two further sub-directories of this directory: labs and reports;
  6. In the directory labs create a file called myFirstFile.txt;
  7. Make a copy of myFirstFile.txt and call it myFirstFile.copy;
  8. Make a copy of myFirstFile.txt and ensure that it is in the reports directory - call it myFirstFile.copy2;
  9. Rename the file called myFirstFile.copy that is in the labs directory to be mySecondFile.txt. This is not illustrated in Figure 1.
  10. Please also ensure that you can answer all questions on UNIX commands from the past exam papers once you've finished this exercise.

Figure 1: An illustration of how the directory structure that you are asked to develop should look as you construct it.


b.osullivan@cs.ucc.ie

Return to the CS1101 Home Page