Skip to main content
Linux Command Line·Lesson 1 of 5

Terminal Basics

The terminal is your direct line to the operating system. While graphical interfaces hide complexity behind buttons and menus, the terminal gives you precise control over everything your computer does.

What Is the Terminal?

The terminal (also called the console or command line) is a text-based interface where you type commands and the system responds with output. Behind the terminal sits a shell — a program that interprets your commands and talks to the operating system.

The most common shells are:

ShellDescription
bashBourne Again Shell — the default on most Linux distributions
zshZ Shell — default on macOS, with extra features like better autocompletion
fishFriendly Interactive Shell — user-friendly with syntax highlighting
shThe original Bourne Shell — minimal and POSIX-compliant

To check which shell you are using:

echo $SHELL

Opening a Terminal

On most Linux distributions, you can open the terminal with Ctrl + Alt + T. On macOS, open the Terminal app from Applications > Utilities, or use Spotlight (Cmd + Space) and type "Terminal."

If you are on Windows, you can use WSL (Windows Subsystem for Linux) to get a full Linux terminal:

wsl --install

Running Your First Commands

Once the terminal is open, you will see a prompt that looks something like this:

username@hostname:~$

This tells you your username, the machine name, and your current directory (~ means your home directory). The $ sign indicates you are a regular user (root users see #).

Try these commands:

# Print text to the screen
echo "Hello, terminal!"

# Show today's date and time
date

# Display your username
whoami

# Show the current directory
pwd

Understanding Command Structure

Every command follows this general pattern:

command [options] [arguments]
  • command — the program you want to run
  • options (flags) — modify the command's behavior, usually prefixed with - or --
  • arguments — the targets the command acts on (files, directories, text)

For example:

ls -la /home

Here ls is the command, -la combines two options (-l for long format and -a for all files), and /home is the argument.

Getting Help

Almost every command has built-in documentation. Use --help for a quick summary or man for the full manual:

# Quick help
ls --help

# Full manual page (press q to exit)
man ls

Inside a man page, you can navigate with arrow keys, search with /keyword, and quit with q.

Another useful command is whatis, which gives a one-line description:

whatis ls
# ls (1) - list directory contents

Essential Navigation Commands

These commands will be your daily drivers:

# Print working directory
pwd

# List files in the current directory
ls

# List with details (permissions, size, date)
ls -l

# List all files including hidden ones
ls -la

# Change directory
cd /var/log

# Go to your home directory
cd ~

# Go up one directory
cd ..

# Go back to the previous directory
cd -

Command History

The terminal remembers your previous commands. Use the up and down arrow keys to cycle through them, or search with Ctrl + R:

# Show full command history
history

# Search history (type after pressing Ctrl+R)
# Press Ctrl+R again to cycle through matches

# Run the last command again
!!

# Run the last command that started with "ls"
!ls

Clearing and Exiting

# Clear the terminal screen
clear
# Or press Ctrl + L

# Exit the terminal session
exit
# Or press Ctrl + D

Keyboard Shortcuts

These shortcuts will speed up your workflow significantly:

ShortcutAction
Ctrl + CCancel the current command
Ctrl + LClear the screen
Ctrl + AMove cursor to the beginning of the line
Ctrl + EMove cursor to the end of the line
Ctrl + WDelete the word before the cursor
Ctrl + UDelete everything before the cursor
Ctrl + RSearch command history
TabAuto-complete file names and commands
Tab TabShow all possible completions

Chaining Commands

You can run multiple commands on a single line:

# Run sequentially (regardless of success/failure)
echo "first"; echo "second"

# Run second only if first succeeds
mkdir mydir && cd mydir

# Run second only if first fails
cat config.txt || echo "File not found"

Summary

The terminal is the most powerful tool in a developer's toolkit. You learned how to open a shell, run basic commands, read documentation, navigate the command history, and use keyboard shortcuts. In the next lesson, you will explore the Linux file system and learn to create, move, copy, and delete files and directories.