When navigating the Linux filesystem from the command line, three of the most basic commands are pwd, cd, and ls. They answer three questions: Where am I? Where do I want to go? What is here?
pwd Print the full path of the current working directory.
cd Change the current working directory.
ls List files and subdirectories in a directory.
pwd: confirm your location
pwd stands for “print working directory.” If you are inside Alice's Documents directory, pwd might print /home/alice/Documents. It is useful whenever you are not sure where you have navigated.
cd: change the current directory
cd Documents enters a subdirectory named Documents inside the current directory. cd .. moves to the parent directory, while running cd with no argument normally returns to the current user's home directory. You can also use a full path such as cd /var/log.
$ pwd
/home/alice
$ cd Documents
$ pwd
/home/alice/Documents
$ ls
notes.txt projectls: see what is inside
With no arguments, ls lists visible entries in the current directory. You can also ask it to inspect another directory, such as ls /etc. As you will see later, ls has useful options for hidden files, detailed information, and human-readable file sizes.
Navigation habit: Use pwd when you are unsure where you are, cd to move, and ls after arriving to inspect the directory.
Navigate a Simulated Filesystem
Simulated terminal ready. Run commands and watch the filesystem on the right.
/homealicearchivebackupcachedataindex.bin
DocumentsDownloadsemptyPicturesprojectsrcREADME.md
.bashrc.profileaccess.logapp.logdraft.txterror.lognotes.txt
varlogsyslog
Quick buttons fill the prompt; run the command or press Enter to change terminal and filesystem state.KNOWLEDGE QUIZ
KNOWLEDGE QUIZ
Practice Common ls Options
The commands below use the same simulated directory. Predict what each ls command changes, then use the single “View reference answer” button in the top-right to check them together. Focus on the effects of -a, -l, and -h.