next up previous
Next: A Up: Other UNIX commands Previous: Listing files, directories -

Changing the working directory, creating and removing a directory

Those already registered in cs241 have a directory called cs241 in the home directory. Terms like home directory, current directory, working directory etc. will be explained in lab 2. Use lc command to check, if the cs241 directory is in your home directory. All files related to cs241 course are normally kept in the cs241 directory. Change of one directory to another is achieved by the UNIX command

cd dirname

meaning change to directory dirname. Next, let us switch to the cs241 directory typing cd cs241. UNIX is not very friendly. By default it will not show if the working directory was changed. The pathname of the current directory is displayed by the UNIX command 'print working directory':

pwd

Type pwd and verify that you are currently in the directory /u/youruserid/cs241. It is recommended to create new directories for all your cs241 assignments and other directories related to cs241 course in the cs241 directory.

The command 'make directory', mkdir, creates a new directory.

Type:

mkdir temp

and switch to the newly created directory temp by typing: cd temp and display the path of temp using pwd. To switch back to cs241 directory type

cd ..

This is similar to DOS environment. Notice that space is needed between cd and the two dots. Command cd .. returns one level up to a higher directory, cd goes straight to the home directory (up or down).

Exercise 1:
Go to the temp directory created before, make a directory called lab1 and switch into it. Verify that your working directory is indeed lab1:

Solution:
cd
cd cs241/temp
mkdir lab1
cd lab1
pwd



Subsections
next up previous
Next: A Up: Other UNIX commands Previous: Listing files, directories -
Instructional Support Group 2008-08-05