📂 Basic Commands & Navigation

Master fundamental Linux commands for file system navigation

💻 Practice While You Learn!

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!

  • The terminal stays open as you navigate between pages
  • Try commands immediately after reading about them
  • Use ↑/↓ arrows for command history, Tab for auto-complete

Why Learn the Command Line?

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.

Basic Navigation Commands: A Hands-On Tutorial

Let's start by exploring the file system using some fundamental navigation commands.

1. Where Am I? (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.

Command: pwd (Print Working Directory)

Try it in the interactive terminal:

pwd

Expected Output: You should see /home/user. This is your simulated "home" directory.

2. What's Here? (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.

Command: ls (List)

Try it:

ls

Expected Output: You'll see a list like documents/ downloads/ projects/ README.txt.

  • Notice the / at the end of documents/, downloads/, and projects/. This is a common convention to indicate that these are directories (folders). README.txt is a file.

Detailed Listing: ls -l

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:

  • Permissions (e.g., drwxr-xr-x for directories, -rw-r--r-- for files)
  • Number of links (usually 1)
  • Owner (user)
  • Group (user)
  • Size (in bytes)
  • Last modified date and time
  • Name of the file or directory

3. Moving Around (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.

Going into a directory

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.

Going up one level

Command: cd ..

(two dots represent the parent directory)

cd ..

Expected Output: Your prompt will change back to /home/user$.

Going to your home directory

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

Going to the "root" directory

Command: cd /

Try it:

cd /
pwd

Expected Output: pwd will show /. In this simulation, / acts as the top-level container for home.

4. Viewing File Content (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.

Command: cat (Concatenate and print)

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

Practice Tips

Ready to practice? Head over to the Interactive Terminal to try all these commands hands-on!

EN
AR
EN
AR