Beginner's Guide to the Command Line Interface (CLI) - Part 1

Michael MensahMichael Mensah
6 min read

Introduction

Definition of Command Line Interface (CLI)

The Command Line Interface (CLI) is a text-based way of interacting with your computer. Instead of clicking buttons or navigating menus like in a graphical interface (GUI), you type specific commands into a terminal to tell your system what to do.

Think of it as having a direct conversation with your computer using text instructions.

Some examples of popular command-line environments include:

  • Terminal on macOS/Linux

  • Command Prompt or PowerShell on Windows

  • Bash (Bourne Again Shell) — a common shell in Unix-based systems

You type in commands like cd to change directories or ls to list files — and the computer responds with results in real time

Importance and benefits of learning CLI

Whether you're just starting out or planning a career in software engineering, understanding the CLI gives you superpowers as a developer. Here's why:

  • Speed & Efficiency: Once you're comfortable, the CLI is faster than most GUIs for tasks like navigating files, installing software, or automating tasks.

  • Control: Many tools and frameworks (like Git, Python virtual environments, Docker, Node.js, etc.) are designed to be run via command line.

  • Remote Work: Working on servers, cloud platforms, or remote machines often means using only a terminal — no GUI at all.

  • Troubleshooting: Logs, processes, system info — it’s all accessible and controllable via the CLI.

  • Better Understanding of the System: You gain a deeper knowledge of how operating systems work, which sharpens your thinking as a developer.

Overview of the article

In this guide, you'll gain a foundational understanding of the Command Line Interface (CLI) — what it is, why it's important, and how to start using it effectively as a beginner in software development. We’ll walk through:

  • The basic structure and logic behind command-line instructions

  • Key differences between terminals and shells

  • Essential navigation and file management commands

  • How to understand and use options, arguments, and directory paths

By the end, you’ll not only know how to use the CLI, but why it’s such a valuable skill for every software engineer, regardless of background

Understanding the CLI Environment

Terminal vs. shell explanation

The terminal and shell are core features of the CLI. These two are closely related and hence often confused. But here is a simple breakdown:

  • The terminal is the interface. The window or program where you type commands. (Eg., macOS Terminal, Windows Terminal)

  • The shell is the software that interprets and runs your commands. It functions as the brain behind the terminal — it understands your commands and gets things done. (Eg., Bash, Zsh, PowerShell)

Navigating the File System

One of the most common things you’ll do in the CLI is move around the file system — opening folders, checking contents, and jumping between directories. Here's how to understand and do that effectively.

Understanding the file system hierarchy

All operating systems organize files in a tree-like structure:

  • At the top is the root directory, usually / in Linux/macOS and a drive letter like C:\ in Windows.

  • Inside the root are folders (directories), which can contain files or more folders.

Here's a simplified view of what a Windows file system might look like:

Key commands for navigation (e.g., `cd`, `ls`, `dir`)

Knowing your current location or working directory is key to using the CLI effectively. It allows you to seamlessly move through folders. Here are some essential commands for moving around and working with directories

  • cd (change directory)
    It moves you from your current folder to another one
    cd Documents moves you into your Document folder.

  • ls (list)
    Lists files and folders in the current directory
    ls Documents provides a list of files and folders in your current directory

  • pwd (print working directory)
    Tells you where you currently are in the file stystem.

Note: All commands in this article run in bash (gitbash).

Basic Command Execution

Basic structure of a command line

Every command you type into a CLI follows a basic structure. Understanding this structure is key to mastering the CLI:

command [options] [arguments]

Let’s break this down:

  • Command: What you want the computer to do (e.g., ls, cd, mkdir)

  • Options/Flags: Modify how the command behaves. Often start with - or -- (e.g., ls -l)

  • Arguments: What the command should act on — like a file name or folder path (e.g., cd Documents/)

For example: ls -a /home/user. This means use the ls command to list all (-a) files including hidden files in the /home/user directory.

Common basic commands and their uses (mkdir, touch, cp, mv, rm)

  • mkdir (make a directory
    Creates a new folder.
    mkdir Projects —— creates a new folder named “Projects”
    mkdir backup —— creates a new folder named “backup”

  • touch (create a file)
    Creates a blank file.
    touch notes.txt —— creates text file named notes (notes.txt)

  • cp (copy files and folders)
    For copying files or directories from one location to another.
    cp notes.txt backup —— copy the notes.txt file into a folder named backup
    cp -r Projects —— copies the Projects folder in another folder named backup

  • mv (move or rename)
    Depending on the syntax can rename a file or move it into a different folder

    • For moving files
      mv notes.txt backup —— moves notes.txt into the backup folder
      (Syntax: mv file_to_move destination_folder)

    • For renaming files
      mv notes.txt my_notes.txt —— renames notes.txt to my_notes.txt (Syntax: mv old_name.txt new_name.txt)

  • rm (remove or delete)
    Deletes files or directories
    rm notes.txt —— deletes notes.txt
    rm -r Projects —— deletes Projects folder and all its content.
    Note: This command should be used cautiously as there is no recovery of files and folders deleted this way

Understanding options and arguments in commands

Most CLI commands have options (also called flags) that change how the command behaves. These are usually added after the command name and begin with - (short option) or -- (long option). It is not used in all commands.

Example:
rm -r Projects —— -r flag/option means recursively

Arguments are usually the files or folders you want the command to act on.

Example
mv notes.txt Documents

  • notes.txt and Documents are arguments

  • no option is used here

Conclusion

The command line may seem intimidating at first — just a black screen and a blinking cursor — but it's one of the most powerful tools in a developer’s toolkit.

Learning the CLI isn’t about memorizing hundreds of commands. It’s about:

  • Understanding how your system works under the hood

  • Gaining speed, flexibility, and control over your development environment

  • Building confidence in tasks that every serious software engineer eventually needs to master

Whether you’re managing files, navigating directories, or running code, the command line opens up a world of possibilities. The more you use it, the more natural it becomes — and soon, you’ll be writing scripts, automating workflows, and working like a true developer.

1
Subscribe to my newsletter

Read articles from Michael Mensah directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Michael Mensah
Michael Mensah