Master fundamental Linux commands for file system navigation
Click the green 💻 Terminal button in the bottom-right corner to open an interactive terminal. You can practice all the commands on this page in real-time!
While graphical interfaces are intuitive, the command line (often called the terminal or shell) offers immense power, efficiency, and a deeper understanding of how your computer works. Many developers, system administrators, and even casual users find it an indispensable tool.
Let's start by exploring the file system using some fundamental navigation commands.
pwd📍 pwd - Print Working DirectoryDisplays the absolute path of your current directory location in the file system.Example$ pwd▸ /home/user/documents)The first thing you often want to know is your current location in the file system.
pwd (Print Working Directory)Try it in the interactive terminal:
pwd
Expected Output: You should see /home/user. This is your simulated "home" directory.
ls📋 ls - List Directory ContentsLists files and directories in the current or specified directory. Essential for navigating and understanding your file system.Basic Usage$ ls▸ documents/ downloads/ projects/ README.txtLong Format$ ls -l▸ Shows detailed information (permissions, size, date)Show Hidden Files$ ls -la▸ Shows all files including hidden ones (starting with .))Now that you know where you are, let's see what files and directories are in your current location.
Try it:
ls
Expected Output: You'll see a list like documents/ downloads/ projects/ README.txt.
For more information about the items, use the -l (long format) option:
ls -l
Expected Output: You'll see a much more detailed output, including:
cd🚀 cd - Change DirectoryNavigate between directories in the file system.Common Patterns$ cd ..▸ Go up one levelGo Home$ cd ~▸ Go to home directoryPrevious Directory$ cd -▸ Go to previous directory)The cd command (Change Directory) is how you navigate between directories.
Command: cd
Let's go into the documents directory:
cd documents
Expected Output: Your prompt will change to /home/user/documents$. This indicates your new current location.
Now, use ls again to see what's inside documents:
ls
You should see notes.md and report.txt.
Command: cd ..
(two dots represent the parent directory)
cd ..
Expected Output: Your prompt will change back to /home/user$.
Command: cd (without any arguments) or cd ~
First, go into projects/my_blog:
cd projects/my_blog
Now, go back to your home directory:
cd
Command: cd /
Try it:
cd /
pwd
Expected Output: pwd will show /. In this simulation, / acts as the top-level container for home.
cat📄 cat - Concatenate and Display FilesDisplay the entire contents of a file to the terminal.Basic Usage$ cat README.txt▸ Displays file contentsMultiple Files$ cat file1.txt file2.txt▸ Concatenate and display both files)Once you've found a file, you might want to see what's inside it.
Let's view the README.txt file in your home directory. Make sure you are in /home/user first (cd if needed):
cat README.txt
Expected Output: The content of README.txt will be displayed.
Try another: Try another file: Go into the documents directory and view notes.md:
cd documents
cat notes.md
Ready to practice? Head over to the Interactive Terminal to try all these commands hands-on!