Print (pwd), Change (cd), or List (ls) Directory
Print Working Directory (pwd)
Purpose: The pwd
command shows your current location in the file system by displaying the absolute pathname of your working directory.
Usage:
eos$ pwd
Example output:
eos$ /mnt/ncsudrive/s/ssrahman
Should I expect an output?
Yes: The terminal will return the absolute path. For example: /mnt/ncsudrive/s/ssrahman
Change Directory (cd)
Purpose: The cd
command changes your current working directory to a specified location.
Usage:
eos$ cd pathname
Example
Changing from the E115 Course Locker directory to your home directory. (View animation here)

To return to the E115 Course Locker:
eos$ cd /mnt/coe/workspace/csc/admin/e115
Should I expect an output?
No: The cd
command does not produce output unless an error occurs.
List Directory (ls)
Purpose: The ls
command lists the contents of a directory. It’s useful for checking that files are present or confirming a directory’s contents.
Usage:
eos$ ls
Or, to list contents of a different directory:
eos$ ls pathname
Common Options:
-l | List contents in long format (includes size, date, owner, permissions, etc.) |
-a | Show all files, including hidden files (those starting with .) |
-al or -la | Combine both options to show all files in long format |
Example
To list the contents of your home directory while you are in it:
eos$ ls
You can also specify another directory by providing a pathname with the ls
command.
Should I expect an output?
Yes: The contents of the directory will be listed. For example:
MyDocuments MyE115 File.txt
Note: The actual output will vary depending on the directory and the user’s files.
Exercises
- What does the command
ls
do when used with the-l
option? - What happens if you use two options at the same time, such as
ls -l -h
? - The command
ls -R
lists the contents of directories recursively, which means the subdirectories, sub-subdirectories, and so on at each level are listed. The commandls -t
lists things by time of last change, with most recently changed files or directories first.- In what order does
ls -R -t
display things? Hint:ls -l
uses a long listing format to view timestamps.
- In what order does
- which of the following commands could
ssrahman
use to navigate to home directory, which is/mnt/ncsudrive/s/ssrahman?
cd .
cd /
cd /home/ssrahman
cd ../..
cd ~
cd home
cd ~/data/..
cd
cd ..
cd ../.
- Moving and copying
Assuming the hypothetical filebooks.dat
as the only one in the directory you’re currently in, what is the output of the closingls
command in the sequence shown below? $ mkdir doc
$ mv books.dat doc/
$ cp doc/books.dat ../books-saved.dat
$ ls