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:
List Current Directory Contents
Typels
to see files and subdirectories. Files appear in normal text, while directories are often bold.Navigate Into a Directory
Usecd [directory_name]
. For example:cd example
Create Files and Directories
Usetouch [file_name]
to create a file:touch index.html
Or, use
mkdir [directory_name]
to create a folder:mkdir frontEnd
Remove Files
Userm [file_name]
to delete a file:rm index.css
Clear the Terminal Window
Theclear
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 insidecode
.
To navigate back to the parent directory, use:
cd ..
A Quick Exercise
Here’s a hands-on task:
Create a directory named
project
.mkdir project
Navigate into
project
and create a file namedapp.js
.cd project touch app.js
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.