You are on page 1of 9

Files are organized in directories

root
/

Applications Users Library System

Adobe …
App Store username … …
Acrobat


Downloads
The current working directory and absolute pathname

pwd # print working directory

/Users/username

Working directory is the directory you are currently in

Command pwd will show the absolute pathname to the directory you are in.
In the example above the pwd command shows that you are in your home directory.

Absolute pathnames always start with /


Your home directory

When you open a terminal, your current working directory is set to home (or login)
directory.

If you type pwd when you open a terminal, it will show you the path to your home
directory

/Users/username

Users

username
Home directory and other directories for Cygwin users

For Windows users the path to the home directory will be:

/home/username

Keep in mind that this is NOT your home directory:

/home

Downloads and Desktop on Windows will be in

/cygdrive/c/Users/username/Downloads
/cygdrive/c/Users/username/Desktop

For further information and how to troubleshoot, consult the document


cygwin-windows-setup.pdf on the Blackboard.
Navigating the directory tree

Changing the current working directory


/
cd pathname

You can use the cd command and specify the absolute pathname.
Absolute pathnames always start with / (i.e. the root directory). Users

To go to the directory of choice you have to specify a full path


from the root to that directory. username
E.g., if you want to go to Downloads you should specify:

cd /Users/username/Downloads
Downloads
Relative pathname

Absolute pathnames start from the root /

However, you can also specify a pathname to another directory


/
relative to your current working directory.

To use relative pathnames, you have to know which directory you are in.
You can use the pwd command to find that out which directory Users
you are in

!! Relative pathnames never start with / !! username

Using cd command with relative pathnames

If you are in your home directory and you want to go to Downloads Downloads
by using the relative pathname, you should specify:

cd Downloads
Navigating the directory tree

Changing the current working directory:

To go back one directory using relative pathname:

cd ..
pwd

To go back two directories using a relative pathname:

cd ../..
pwd

To go to the root directory using absolute pathname

cd /
pwd

Shortcut to go to your home directory:

cd
cd ~
pwd
cd
/

cd cd
Users

username

cd Downloads cd
/ cd

cd Users

username

cd Downloads cd username/Downloads

You might also like