Navigating Your Computer Using the Terminal

Navigating Your Computer Using the Terminal

The first intimidating lesson in learning to code

When I started learning to code, one of my earliest challenges was understanding that a “directory” is essentially a file folder. This guide is here to demystify the basics of navigating your computer’s file structure using the Linux terminal—an essential skill for any budding programmer.

Terminal Essentials

Here are some commonly used commands and their functions:

  • Directory: Another term for a file folder.

  • ls: Lists the contents of the current directory.

  • cd: Changes your current directory.

  • mkdir: Creates a new directory.

  • touch: Creates a new file.

  • rm: Deletes a specific file or directory.

  • clear: Clears the terminal window of previous outputs.


Graphical File Navigation vs. Terminal

In graphical navigation, you double-click folders to explore their contents. Here’s how to replicate that in the terminal:

  1. List Current Directory Contents
    Type ls to see files and subdirectories. Files appear in normal text, while directories are often bold.

  2. Navigate Into a Directory
    Use cd [directory_name]. For example:

     cd example
    
  3. Create Files and Directories
    Use touch [file_name] to create a file:

     touch index.html
    

    Or, use mkdir [directory_name] to create a folder:

     mkdir frontEnd
    
  4. Remove Files
    Use rm [file_name] to delete a file:

     rm index.css
    
  5. Clear the Terminal Window
    The clear command makes the terminal tidy:

     clear
    

Navigating Paths Efficiently

Directories are part of a hierarchical structure, known as a “path.” For example, ~/code/example indicates:

  • ~: Home directory.

  • code: A folder in the home directory.

  • example: A folder inside code.

To navigate back to the parent directory, use:

cd ..

A Quick Exercise

Here’s a hands-on task:

  1. Create a directory named project.

     mkdir project
    
  2. Navigate into project and create a file named app.js.

     cd project
     touch app.js
    
  3. Confirm the file exists by running:

     ls
    

Now you’re equipped with essential terminal skills! Practice regularly to make terminal navigation second nature.


For more tech insights and coding tips, follow Dan Kimutai Koskei.