Current Level: 1 | 2 | 3 | 4 | 5
cd
The cd
command lets you move between folders (directories). It doesn’t change the folder itself — it just tells the shell which directory you want to work in.
Change to a different folder From your home directory, type:
cd Desktop
cd shell-lesson-data
cd exercise-data
Now you’re inside the exercise-data
folder.
Check where you are
The shell doesn’t show a message when cd
works. To check your current location, type:
pwd
Example output:
/Users/nelle/Desktop/shell-lesson-data/exercise-data
List what’s here You can now run:
ls -F
Example output:
alkanes/ animal-counts/ creatures/ numbers.txt writing/
Go up one level To move back to the folder above this one, type:
cd ..
Then check:
pwd
You should now be in:
/Users/nelle/Desktop/shell-lesson-data
What went wrong here? If you try this:
cd shell-lesson-data
while already inside exercise-data
, it won’t work:
-bash: cd: shell-lesson-data: No such file or directory
That’s because shell-lesson-data
is not inside exercise-data
. You can only cd
into folders that are inside your current folder.
cd folder-name
moves into a folder.cd ..
moves up to the parent folder.pwd
shows your current location.ls -F
lists what’s in the current folder.