Thirteen basic Linux commands cover most of what you need to navigate, inspect, and manage files on a GNU/Linux system without touching anything destructive. The Linux Commands Cheat Sheet packages those thirteen commands, including pwd, ls, mkdir, cp, mv, cat, head, tail, wc, sort, uniq, df, and du, into searchable templates you can copy one at a time. Each template comes with placeholder text wrapped in angle brackets, a short description, and safety notes tailored to the command's quirks. Because the list skips force flags, recursive deletion, privilege escalation, and process termination, you can treat the sheet as a recall aid rather than a complete command reference. The cheat sheet runs entirely in your browser; it does not open a terminal, read your filesystem, or execute anything. Your job is to search, replace the placeholders with real values, and confirm the working directory before you paste a command into a shell you actually control.

basic linux commands
basic linux commands

What the Cheat Sheet Actually Covers

The 13 commands fall into four practical groups, each answering a distinct beginner question. Location commands answer "where am I?" with pwd. File and directory commands let you list, create, copy, and move with ls, mkdir, cp, and mv. Text commands let you preview, count, and order file contents with cat, head, tail, wc, sort, and uniq. Disk commands report space consumption at the filesystem and path level with df and du. Together they cover the everyday tasks a new user hits in the first week: navigating directories, creating folders, copying and renaming files, peeking at logs, counting lines, sorting output, and checking whether a disk is filling up. None of them require elevated privileges under normal conditions, which is why they make a sensible starting set.

This deliberate scope also explains what is missing. The cheat sheet does not include rm, force flags, recursive deletion, chmod, package managers like apt or dnf, network commands like curl or ssh, or process control like kill. Removing any of those from a quick-copy reference prevents the kind of accidental data loss that happens when someone pastes a command without reading the flags. When you need a destructive operation, the expectation is that you will consult the local man page and verify the target first, not grab a one-liner from a recall aid.

The 13 Commands Grouped by Task

The table below groups each template by its primary job. Use it as a quick index when you know the verb you want but not the exact flag syntax.

Category Command Primary use
Location pwd Print the current working directory
File and directory ls List directory contents
File and directory mkdir Create one or more directories (mkdir -p creates parents)
File and directory cp Copy files, with -i prompting before overwrite
File and directory mv Move or rename files, with -i prompting before overwrite
Text cat Write file contents to standard output
Text head Show the first 20 lines of a file
Text tail Show the last 20 lines of a file
Text wc Count lines, words, and bytes (wc -l counts newlines)
Text sort Order lines according to the active locale
Text uniq Collapse adjacent duplicate lines; input must be sorted first
Disk df Report free space per mounted filesystem (df -h for human units)
Disk du Estimate disk usage for a path (du -sh for a single total)

How to Copy and Run a Template Safely

  1. Open the Linux Commands Cheat Sheet and search by command name, category, syntax, or purpose. For example, type "disk" or "first lines" to narrow the list.
  2. Read the description and any safety notes so you understand what the template does and what it omits before copying anything.
  3. Replace every angle-bracket placeholder, such as <file>, <path>, <source>, <destination>, <directory>, or <sorted-file>, with the real value and remove the brackets.
  4. Confirm the working directory with pwd, confirm the target paths exist with ls, confirm the executable source with command -v or which, and confirm the local behavior with man <command>.
  5. Copy the template and run it with the least privilege needed. The cp and mv templates already include -i so the shell prompts before any overwrite.
  6. Verify the observed result and the exit status before moving on. Read the output, confirm the file actually changed, and echo $? when you need to check the return code explicitly.

Replacing Placeholders Without Breaking Commands

Angle-bracket text is a placeholder, not literal input. If you type cat <file> exactly, the shell will look for a file literally named "<file>" and fail with "No such file or directory." The same rule applies to <path>, <source>, <destination>, <directory>, and <sorted-file>. Replace the entire placeholder including brackets, and choose real values that point to the targets you actually mean.

Shell-sensitive characters add another layer of risk. Spaces, leading hyphens, wildcard characters, environment variables, and symbolic links can all change what a command targets. Quote paths that contain spaces or special characters, and use -- before filenames that begin with a hyphen when the utility supports it. The cp and mv templates already include -i, which forces an interactive prompt before any overwrite, but that prompt only appears in a real terminal. In scripts, aliases, or noninteractive sessions, the prompt may not trigger, so always double-check the destination before running.

When Linux Behavior Differs From the Sheet

The cheat sheet is verified against the GNU Coreutils manual and cross-checked against POSIX utility documentation, but real systems vary. macOS, BSD, BusyBox, containers, minimal images, and older distributions ship different core utilities with different flags and output formats. sort, for example, follows the active locale unless configured otherwise, so a directory listing sorted on one machine may come out in a different order on another. head and tail default to twenty lines here, but the line delimiter and encoding still matter; binary input and Windows-style line endings can produce unexpected results.

For authoritative details, consult the GNU Coreutils manual or the POSIX utilities index on the system where you actually run the command. The local man page and the command's built-in help output should be your final source, not the cheat sheet.

Disk Commands Report Different Things

df -h and du -sh look similar but answer different questions. df -h summarizes space for mounted filesystems in human-readable units, which is useful for "is the disk full?" questions. du -sh estimates the total blocks attributed to a selected path, which is useful for "where is the space going?" questions. Their totals can differ because deleted-but-open files, sparse files, hard links, permissions, mount boundaries, snapshots, reserved blocks, and filesystem accounting affect what each command sees.

Neither command proves a cleanup is safe. Before deleting anything to reclaim disk space, identify the exact consumer and preserve recoverability. Archive or move the candidate files, verify the new total, and only then remove them. The cheat sheet treats disk commands as inspection tools, not as authorization to delete.

Common Pitfalls When Copying Commands

A syntactically valid command can still act on the wrong file, and that mistake is hard to spot until something breaks. Three habits prevent most accidents. First, always print the working directory with pwd before running cp, mv, or rm. Second, list the target with ls to confirm the path exists and resolves where you think it does. Third, treat -i as a guardrail, not a backup; the prompt is there to slow you down, not to recover lost data. When you want to compare two files side by side, the walkthrough on how to check the difference between two files in Linux pairs naturally with these commands.

The same habit applies to redirects and pipes. wc -l counts newline characters, not a human definition of records. uniq only collapses adjacent duplicates, so the template explicitly says sorted-file: sort first, then dedupe. cat writes file contents to standard output, and large or binary input can flood a terminal. head and tail are safer previews because they cap the output, but the cap is twenty lines here, not a universal guarantee. When you need to map out a directory before moving files, the Linux directory tree generator produces a clean visual map from a strict path list.

Building a Habit Around Conservative Templates

The cheat sheet is a learning and recall aid, not authorization to operate an unfamiliar server. When a command could overwrite, disclose, move, or consume important data, stop and resolve the exact target first. In scripts, handle exit status explicitly, quote variables, set explicit working directories, and choose idempotent operations that you can re-run without harm. Back up material data before mutations and verify the result afterward. The 13 commands listed here give you enough surface area to handle most beginner tasks without exposing yourself to the destructive shortcuts that turn small mistakes into permanent ones.