DEV Community

Cover image for Terminal Mastery: Windows, macOS & Linux
Hamed Farazi
Hamed Farazi

Posted on Edited on

Terminal Mastery: Windows, macOS & Linux

Chapter 01/10 — Terminal Fundamentals: Your First Steps into the Command Line

Terminal Fundamentals: Your First Steps into the Command Line

A practical beginner's guide to Windows, macOS, and Linux

Have you ever watched a developer open a black window, type a few commands, and suddenly create an entire project, install dependencies, or manage their system?

That window is called a Terminal.

For many beginners, the command line looks intimidating. It seems like a place where you need to memorize hundreds of mysterious commands just to get something done.

But here's the truth:

The terminal is simply another way to communicate with your computer.

Instead of clicking buttons and navigating menus, you type instructions and let the operating system execute them.

Whether you're using Windows, macOS, or Linux, learning the command line is one of the most valuable skills you can develop as a programmer.

In this article, we'll start from absolute zero.

By the end, you'll understand what a terminal is, how it differs from a shell, how to execute your first commands, and how to navigate the command-line environments of all three major operating systems.

Let's get started.


1. What Is a Terminal?

A terminal is an application that provides a text-based interface for interacting with your computer.

Traditionally, computers relied heavily on text-based interfaces. Users typed commands to perform operations instead of clicking graphical elements.

Today, we have beautiful graphical interfaces, but the terminal is still an essential tool.

For example, imagine you want to create a new folder.

Using a graphical interface:

  1. Open File Explorer or Finder.
  2. Navigate to the desired location.
  3. Right-click.
  4. Select New Folder.
  5. Enter the folder name.

Using a terminal:

mkdir my-project
Enter fullscreen mode Exit fullscreen mode

That's it.

One command creates the folder.

The terminal becomes especially powerful when you need to:

  • Manage files and directories.
  • Install software and dependencies.
  • Run development servers.
  • Work with Git and GitHub.
  • Manage processes.
  • Connect to remote servers.
  • Automate repetitive tasks.
  • Diagnose system problems.

For developers, the terminal isn't just an alternative interface. It's an essential part of the development workflow.

2. Terminal vs. Shell vs. Command Line

Before running commands, let's understand three terms that developers often use interchangeably.

Although they're related, they aren't exactly the same.

Terminal

A terminal is the application or interface where you type commands and see their output.

Examples include:

  • Windows Terminal
  • macOS Terminal
  • GNOME Terminal
  • iTerm2
  • Alacritty

Shell

A shell is the program that interprets your commands and communicates with the operating system.

When you type:

mkdir my-project
Enter fullscreen mode Exit fullscreen mode

The shell interprets the command and executes the requested operation.

Popular shells include:

Shell Common Environment
Bash Linux
Zsh macOS
PowerShell Windows, macOS, Linux
Fish Linux, macOS
CMD Windows

Command Line

The command line refers to the text-based interface through which you interact with the shell.

You'll often hear developers say:

  • Open your terminal.
  • Run this command in your shell.
  • Execute this from the command line.

In everyday development conversations, these expressions are often used loosely.

How Do They Work Together?

Think of it this way:

  • Terminal: Where you type.
  • Shell: What understands your commands.
  • Operating System: What performs the requested operations.

Understanding this distinction will make the rest of this series much easier.

3. Getting Started on Windows

Windows provides several command-line environments.

The two most common options for modern Windows users are:

  • Windows PowerShell
  • Command Prompt (CMD)

Windows Terminal is a modern application that can host these environments in separate tabs.

Option A: Open Windows Terminal

There are several ways to open it.

Method 1: Start Menu

  1. Press the Windows key.
  2. Search for Windows Terminal.
  3. Open the application.

Method 2: Run Dialog

Press:

Win + R
Enter fullscreen mode Exit fullscreen mode

Then enter:

wt
Enter fullscreen mode Exit fullscreen mode

Press Enter.

Windows Terminal should open.

Option B: Open PowerShell

You can also search for PowerShell directly in the Start Menu.

PowerShell is a powerful command-line shell with scripting capabilities and access to Windows system management features.

Let's run our first command.

Get-Location
Enter fullscreen mode Exit fullscreen mode

This displays your current working directory.

For example:

Path
----
C:\Users\Developer
Enter fullscreen mode Exit fullscreen mode

Now try:

Get-ChildItem
Enter fullscreen mode Exit fullscreen mode

This displays files and directories in your current location.

You can also use its shorter alias:

ls
Enter fullscreen mode Exit fullscreen mode

That's right. PowerShell supports aliases for many common commands.

Option C: Open Command Prompt

Search for cmd in the Start Menu.

Then run:

cd
Enter fullscreen mode Exit fullscreen mode

This displays your current directory.

To list files and folders:

dir
Enter fullscreen mode Exit fullscreen mode

Remember that CMD and PowerShell are different shells. They have different syntax and capabilities.

We'll explore their differences throughout this series.

4. Getting Started on macOS

macOS comes with a built-in terminal application.

The default shell on modern macOS installations is Zsh.

Open Terminal

There are two easy methods.

Method 1: Spotlight Search

  1. Press Command + Space.
  2. Type Terminal.
  3. Press Enter.

Method 2: Finder

Navigate to:

Applications → Utilities → Terminal
Enter fullscreen mode Exit fullscreen mode

Open Terminal.

You should see a command prompt waiting for input.

Let's execute our first command:

pwd
Enter fullscreen mode Exit fullscreen mode

pwd stands for Print Working Directory.

It displays your current location.

For example:

/Users/developer
Enter fullscreen mode Exit fullscreen mode

Now list the files and directories:

ls
Enter fullscreen mode Exit fullscreen mode

To display additional details, including hidden files:

ls -la
Enter fullscreen mode Exit fullscreen mode

We'll explore these options in detail in the next articles.

5. Getting Started on Linux

Linux distributions usually provide a terminal application, although the exact application depends on your desktop environment.

Some popular terminal applications include:

  • GNOME Terminal
  • Konsole
  • Xfce Terminal
  • Alacritty
  • Kitty

Open Terminal

On many Linux distributions, you can use:

Ctrl + Alt + T
Enter fullscreen mode Exit fullscreen mode

This shortcut works on many popular desktop environments, although it may vary.

Alternatively, search for Terminal in your applications menu.

Once the terminal opens, let's run:

pwd
Enter fullscreen mode Exit fullscreen mode

Then:

ls
Enter fullscreen mode Exit fullscreen mode

And finally:

whoami
Enter fullscreen mode Exit fullscreen mode

The whoami command displays the username of the current user.

For example:

developer
Enter fullscreen mode Exit fullscreen mode

Congratulations! You've already executed your first Linux commands.

6. Understanding Command Structure

Now that you've opened a terminal on each operating system, let's understand how commands are structured.

A typical command can contain several parts:

command [options] [arguments]
Enter fullscreen mode Exit fullscreen mode

Let's break it down.

Command: The program or operation you want to execute.

Options: Additional settings that modify the command's behavior.

Arguments: The values or targets on which the command operates.

For example:

ls -la /home/developer
Enter fullscreen mode Exit fullscreen mode

Here:

  • ls is the command.
  • -la contains options.
  • /home/developer is the argument.

Another example:

mkdir my-project
Enter fullscreen mode Exit fullscreen mode

Here:

  • mkdir is the command.
  • my-project is the argument.

Not every command requires options or arguments.

For example:

pwd
Enter fullscreen mode Exit fullscreen mode

This command works without either.

Short and Long Options

Many command-line tools support both short and long options.

For example:

ls -a
Enter fullscreen mode Exit fullscreen mode

And:

ls --all
Enter fullscreen mode Exit fullscreen mode

Both display hidden files on typical Unix-like systems.

However, option names and syntax depend on the specific command and shell.

Never assume every command supports the same options.

7. Your First Essential Commands

Let's learn a few commands that you'll use frequently.

1. Print Your Current Location

macOS / Linux:

pwd
Enter fullscreen mode Exit fullscreen mode

PowerShell:

Get-Location
Enter fullscreen mode Exit fullscreen mode

CMD:

cd
Enter fullscreen mode Exit fullscreen mode

2. List Files and Directories

macOS / Linux:

ls
Enter fullscreen mode Exit fullscreen mode

PowerShell:

Get-ChildItem
Enter fullscreen mode Exit fullscreen mode

CMD:

dir
Enter fullscreen mode Exit fullscreen mode

3. Clear the Terminal Screen

macOS / Linux:

clear
Enter fullscreen mode Exit fullscreen mode

PowerShell / CMD:

cls
Enter fullscreen mode Exit fullscreen mode

4. Display Your Username

macOS / Linux:

whoami
Enter fullscreen mode Exit fullscreen mode

PowerShell / CMD:

whoami
Enter fullscreen mode Exit fullscreen mode

5. Display Command Help

PowerShell:

Get-Help Get-ChildItem
Enter fullscreen mode Exit fullscreen mode

CMD:

help
Enter fullscreen mode Exit fullscreen mode

Bash / Zsh:

man ls
Enter fullscreen mode Exit fullscreen mode

You can also use:

ls --help
Enter fullscreen mode Exit fullscreen mode

Note that --help is not supported by every command.

The man command opens a manual page when documentation is available.

These help systems are incredibly useful. Experienced developers don't memorize everything. They know how to find the information they need.

8. Understanding Paths

A path describes the location of a file or directory.

There are two important types of paths.

Absolute Path

An absolute path specifies a complete location starting from the filesystem root or an equivalent system-specific root.

Examples:

Windows:

C:\Users\Developer\Documents
Enter fullscreen mode Exit fullscreen mode

macOS:

/Users/developer/Documents
Enter fullscreen mode Exit fullscreen mode

Linux:

/home/developer/Documents
Enter fullscreen mode Exit fullscreen mode

Relative Path

A relative path describes a location in relation to your current working directory.

For example:

projects/my-app
Enter fullscreen mode Exit fullscreen mode

If your current location is:

/home/developer
Enter fullscreen mode Exit fullscreen mode

Then the relative path points to:

/home/developer/projects/my-app
Enter fullscreen mode Exit fullscreen mode

You'll frequently use relative paths when working with development projects.

We'll explore navigation and filesystem operations in much greater detail in Article 02.

9. Important Terminal Concepts for Beginners

Before moving on, there are a few concepts worth understanding.

Case Sensitivity

Linux and macOS filesystems are commonly case-sensitive, although macOS can also use case-insensitive filesystem configurations.

Windows filesystems are generally case-insensitive by default.

For example, on a typical case-sensitive Linux filesystem:

Project.txt
project.txt
Enter fullscreen mode Exit fullscreen mode

These can be two different files.

Don't assume that filenames behave identically across operating systems.

Spaces in File and Directory Names

Consider this directory:

My Projects
Enter fullscreen mode Exit fullscreen mode

If you try:

cd My Projects
Enter fullscreen mode Exit fullscreen mode

The shell may interpret this as multiple arguments.

Instead, wrap the path in quotation marks:

cd "My Projects"
Enter fullscreen mode Exit fullscreen mode

This works in PowerShell, CMD, Bash, and Zsh.

Command History

Most interactive shells allow you to access previously executed commands.

Press the Up Arrow key:

↑
Enter fullscreen mode Exit fullscreen mode

This displays your previous command.

Press it again to navigate further back through your history.

The Down Arrow key moves forward.

This simple feature can save you a lot of time.

Tab Completion

You don't always need to type the entire command or path.

Start typing a filename or directory name and press:

Tab
Enter fullscreen mode Exit fullscreen mode

Your shell may automatically complete the name.

For example:

cd Doc
Enter fullscreen mode Exit fullscreen mode

Press Tab, and the shell may complete it to:

cd Documents
Enter fullscreen mode Exit fullscreen mode

The exact behavior depends on your shell configuration and available completions.

10. Practice: Your First Terminal Exercise

Theory is useful, but the best way to learn the terminal is to use it.

Open your terminal and complete these exercises.

Task 1: Display your current location.

Task 2: Display the files and directories in your current location.

Task 3: Display your current username.

Task 4: Clear your terminal screen.

Task 5: Display the available help information for a command.

Task 6: Use the Up Arrow key to execute a previously entered command.

Try completing all six tasks without copying the commands directly from the article.

The goal is to become comfortable with the environment.


What's Next?

You've now learned the fundamentals of the command line and explored the basic differences between Windows, macOS, and Linux terminal environments.

But knowing how to execute commands is only the beginning.

In the next article, we'll explore one of the most important terminal skills: navigating and managing the filesystem.

We'll learn how to move between directories, create files, rename folders, copy data, and delete files safely.

Next Article: Navigating the File System Like a Pro


Final Thoughts

The terminal might look complicated at first, but don't let that discourage you.

You don't need to memorize hundreds of commands.

Start with a few essential operations, understand what they do, and practice them regularly.

Over time, the command line will become a natural part of your development workflow.

Remember:

The goal isn't to memorize commands. It's to understand how to communicate with your computer.

Happy coding!

Top comments (0)