What Is CLI and the Terminal: a simple guide for beginners

BasicsDeveloper Tools

What is CLI and why developers still use the black window

There are two ways to talk to a computer. The first is a graphical interface – mouse, icons, windows. It’s convenient, intuitive and familiar. But when you work on a server, configure a program or write code, the mouse suddenly becomes a hindrance.

CLI (Command Line Interface) – a program you interact with via the terminal (text only). You write a command, the computer executes it and returns the result. No graphics. No buttons. Just text. And, as it turns out, for many tasks it’s much faster.

If you’ve ever seen a hacker in a movie typing endlessly into a black window, that’s a dramatized version. In reality it’s far less flashy but far more useful.

Problem / Context: why we’re still here

Modern operating systems try to hide the need for you to type commands. Yet there are situations where a CLI is indispensable:

  • On a server there is no mouse. Most servers run head‑less, you SSH in and the only thing you see is a shell prompt. Without it you simply can’t do anything.
  • Automation. If you can do something with a single command, you can repeat it a thousand times in a loop or on a schedule.
  • Precision. In a GUI you often click the wrong folder or miss a setting. In a CLI you type exactly what you want – a specific file, a specific flag.

How it works in simple terms

A CLI consists of two main pieces:

Terminal – the window that shows the prompt and where you type. Shell – the program behind the prompt that interprets your text and tells the OS what to do. The most common shells are bash, zsh, fish on Linux/macOS and PowerShell or cmd on Windows.

When you type a command:

  1. The shell reads the text.
  2. It finds the executable that matches the command name.
  3. It runs it with the given arguments.
  4. It prints the result on the screen.

Basic commands you’ll need

You don’t have to learn everything at once. Start with the essentials:

ls              # list files in the current directory
ls -la          # detailed list: permissions, size, modification date
cd /path        # change directory
cd ..           # go up one level
pwd             # print the current working directory

Create & manage

mkdir new_dir          # create a directory
touch file.txt         # create an empty file
cp source.txt copy.txt # copy a file
mv old.txt new.txt     # rename or move a file
rm file.txt            # delete a file (be careful!)
cat file.txt        # output the whole file
head file.txt       # show first 10 lines
grep "word" file.txt  # find lines containing "word"
find /path -name "*.txt"  # locate all .txt files

Network & processes

ping google.com        # check if you have internet
curl https://example.com  # make a HTTP request
top or htop           # show running processes
ps aux                # list all processes

Flags (options)

Flags modify a command’s behaviour. They start with a dash (-) or double dash (--):

ls -l           # long format with permissions, sizes, dates
ls -a           # show hidden files (those starting with .)
ls -la          # both long and hidden
curl -I https://example.com  # fetch only response headers
curl --max-time 10 https://example.com  # timeout after 10 seconds

If you’re unsure what a flag does, man <command> will show you everything.

Pipelines: when you need a combo

One of the coolest CLI features is chaining commands with |. The output of the first command becomes the input of the next:

ls -la | grep ".txt"           # show only .txt files
cat log.txt | grep "error" | wc -l  # count how many lines contain "error"
ps aux | grep node | awk '{print $2}'  # get PIDs of node processes

Think of it as building with LEGO bricks – you combine small pieces to get the result you need.

Understanding error messages

CLI errors are rarely pretty, but they’re usually specific:

  • command not found – the program isn’t installed. You need to install it.
  • permission denied – you lack rights. Try sudo or adjust permissions with chmod.
  • no such file or directory – the path is wrong. Check pwd and ls.
  • connection refused – the service isn’t reachable. Maybe it’s not running or blocked by a firewall.

Commands return an exit code: 0 means success, any other number indicates an error. You can see it with echo $? right after a command.

Common beginner mistakes

  1. Fear of the terminal. It’s the most common mistake. The terminal doesn’t bite. As long as you read what a command does before running it, you’re safe.
  2. Copy‑pasting commands blindly. The internet is full of one‑liners that can wipe data. Always read them first.
  3. Deleting files as root. sudo rm -rf / – never, ever. Even variants with slightly different paths can be disastrous if you’re not sure what they target.
  4. Not knowing where you are. Before any destructive command, run pwd and ls to confirm you’re in the right directory.
  5. Ignoring man pages. man ls, man grep, man curl – these are full documentation right in your terminal. No need to Google for basic flags.

Conclusion / action plan

CLI is not black magic. It’s a language you use to tell the computer what to do. If you’re a developer, DevOps engineer, or even just a curious power user, mastering the command line will become one of your most valuable tools.

What to do next:

  1. Open a terminal and notice what you see (usually a path and a cursor).
  2. Run ls and ls -la – compare the outputs.
  3. Create a folder, navigate into it, create a file, view its contents – complete a basic cycle.
  4. Try grep and a pipeline (|) – combine two commands.
  5. Get help for any command with command --help or man command.

When you can do ten things in thirty seconds via the terminal (and understand what’s happening), you’ll see how much faster and reliable your workflow becomes.

Quick checklist

  • Open a terminal and run `ls`, then `ls -la` – notice the difference.
  • Create a folder `mkdir ~/test-cli`, navigate into it with `cd ~/test-cli`, create an empty file `touch readme.txt`.
  • Try a pipeline: `ls -la | grep txt` – it shows only files ending with txt.
  • Find out which shell you’re using: `echo $SHELL`.
  • Get help for a command: `man ls` or `ls --help`.

Prompt Pack: solve a task via the command line

I need to perform typical tasks via the command line because I lack a convenient graphical interface (e.g., on a server). Input data: - what exactly needs to be done (find files, check connectivity, copy a directory, etc.); - whether I have access rights to target directories; - operating system (Linux, macOS, Windows). Return the result in this format: 1. the exact command or pipeline of commands; 2. explanation of each flag/parameter; 3. how to verify the command succeeded; 4. how to abort if something goes wrong; 5. where to find documentation for the command without Googling.