Unix Tutorial #1: Navigating the directory tree¶
Topics covered: Directories, navigation
Commands used: pwd, cd, ls
Like other operating systems, Unix organizes folders and files using a directory tree - also known as a directory hierarchy, or directory structure. At the top of the hierarchy is a folder called
root, written as a forward slash (
/). All other folders (also known as directories) are contained within the
root folder, and those folders in turn can contain other folders.
Think of the directory hierarchy as an upside-down tree:
root is the base of the tree, and all of the other folders extend from it, just as branches extend from the trunk.
To navigate around your computer, you will need to know the commands
pwd stands for “print working directory”;
cd stands for “change directory”; and
ls stands for “list”, as in “list the contents of the current directory.” This is analogous to pointing and clicking on a folder on your Desktop, and then seeing what’s inside. Note that in these tutorials, the words “folder” and “directory” are used interchangeably.
Click here to see a video overview of the commands cd, ls, and pwd - the basic commands you will need to navigate around your directory tree.
When you’re done watching the video, try the following exercises:
ls ~and note what it returns; then type
ls ~/Desktop. How are the outputs different? Why?
- Navigate to the Desktop by typing
cd ~/Desktop. Type
pwdand note what the path is. Then create a new directory using the
mkdircommand, choosing a name for the directory on your own. Navigate into that new directory and think about how your current path has been updated. Does that match what you see from typing
pwdfrom your new directory?
- Define the terms
pwdin your own words.