Home › Developer Tools › Linux Commands Cheat Sheet

Linux Commands Cheat Sheet

Look up any everyday Linux or bash command, see what its flags actually do and copy a working example. Search by command name or by task, such as "disk space", "find large files" or "kill process".

Last updated:

Advertisement
Advertisement

How to use the Linux Commands Cheat Sheet

  1. Search for a command name (tar, grep, chmod) or describe the task, like "find large files" or "which process uses a port".
  2. Filter by category with the tabs, for example Files, Text, Networking or Processes.
  3. Read the flags under each command to understand what every option does before you run it.
  4. Copy an example with its Copy button and replace the sample file names or paths with your own.
  5. Download the whole cheat sheet as Markdown to keep a local copy.

Linux file permissions explained

Every file has three permission sets: for the owner (u), the group (g) and others (o). Each set is a sum of read (4), write (2) and execute (1), which is why chmod 754 means owner rwx (4+2+1), group r-x (4+1) and others r-- (4). ls -l shows the same thing as letters, such as -rwxr-xr--.

OctalLettersTypical use
755rwxr-xr-xDirectories, scripts and programs everyone may run
644rw-r--r--Regular files: web pages, config files
700rwx------Private directories such as ~/.ssh
600rw-------Private files: SSH keys, .env files with secrets
775rwxrwxr-xShared project folders where the group may write
777rwxrwxrwxEveryone may write. Almost never the right fix for a permission error

Important Linux directories

PathContains
/The root of the single directory tree; every drive is mounted somewhere below it
/home/<user> (~)Your personal files and hidden settings (dotfiles such as .bashrc)
/etcSystem-wide configuration files
/var/logLog files
/usr/bin, /usr/local/binInstalled programs; /usr/local is for software you install yourself
/tmpTemporary files, often cleared at reboot
/optOptional, self-contained third-party applications
/dev, /proc, /sysVirtual filesystems for devices, processes and kernel information
/mnt, /mediaMount points for extra drives and removable media

Five habits that prevent terminal accidents

  • Preview before you delete. Run find … -print or ls with the same pattern before adding -delete or rm.
  • Quote variables like "$file" so names with spaces are not split into several arguments.
  • Use dry runs where they exist: rsync -n, git clean -n, apt -s.
  • Check device names with lsblk before dd, mkfs or partitioning; /dev/sda is usually your system disk.
  • Use sudo only when needed. If a command fails with "Permission denied", first ask whether you are editing the right file.

Frequently asked questions

What are the most important basic Linux commands?

Start with ls (list files), cd (change directory), pwd (show current directory), cp, mv and rm (copy, move and delete), mkdir (create a folder), cat and less (view files), grep (search text), man (read the manual) and sudo (run as administrator). These cover most daily terminal work.

Do these commands work on macOS?

Most do, because macOS is Unix-based and ships with bash or zsh. Some flags differ because macOS uses BSD versions of tools: for example sed -i needs an empty argument (sed -i '' ...), and commands such as ip, ss, free and systemctl do not exist on macOS.

How do I see what a command's flags mean on my system?

Run man command (for example man tar) to open the full manual, or command --help for a shorter summary. Press q to leave man. The tldr tool, if installed, shows short practical examples.

What does sudo do?

sudo runs a single command as the root (administrator) user after asking for your own password, if your account is allowed to. Use it only for commands that really need system-wide access, such as installing packages or editing files in /etc.

Is rm -rf dangerous?

Yes. rm -r deletes folders recursively and -f skips all confirmations, and there is no recycle bin in the terminal. Double-check the path, avoid variables that could be empty, and never run it on / or ~ by mistake. Use rm -ri when you want to confirm each file.

What is the difference between > and >> in bash?

> redirects output to a file and overwrites anything already in it. >> appends the output to the end of the file. Use 2> to redirect error messages and &> (bash) to send both output and errors to the same file.

How do I find which process is using a port?

Run sudo ss -ltnp | grep :8080 or sudo lsof -i :8080, replacing 8080 with your port. Both show the program name and process ID, which you can then stop with kill PID.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

Git Cheat SheetSearchable Git command reference by task, with copy buttons and an undo/rename/fix wizard.Chmod CalculatorConvert Linux file permissions between checkboxes, octal (755) and symbolic (rwxr-xr-x) notation.Cron Expression GeneratorBuild crontab schedules visually, read them in plain English and see the next run times.Common Ports ListSearchable TCP/UDP port number list with service, protocol and description, filterable by range.ANSI Color Code GeneratorStyle terminal text with 16, 256 or RGB colors and get escape codes for bash, Python, JS and C.Dockerfile LinterLint a Dockerfile for best practices: pinned tags, apt cleanup, non-root USER and layer count.Dockerignore GeneratorBuild a .dockerignore from Node, Python, Go and Java templates, plus your own entries.Systemd Service File GeneratorCreate a systemd .service unit with ExecStart, user, restart policy, environment and hardening.QR Code GeneratorMake QR codes for links, Wi-Fi, email and more.Barcode GeneratorCreate Code 128, EAN-13, UPC-A, EAN-8, Code 39 and ITF-14 barcodes as PNG or SVG.UUID GeneratorGenerate UUID v4 and v7 / GUIDs in bulk and copy or download them.Schema Markup Generator (JSON-LD)Create JSON-LD structured data for FAQ, Product, Article and more.Htaccess & Nginx Redirect GeneratorBuild 301 redirects for .htaccess, Nginx and Netlify or Cloudflare _redirects.Fake Data GeneratorGenerate mock data as JSON, CSV or SQL.Random String GeneratorGenerate secure random strings and tokens in bulk with any length and character set.API Key GeneratorCreate secure API keys and secrets with prefixes, checksums and SHA-256 hashes for storage.MIME Type LookupFind the MIME type for any file extension, or the extensions for a MIME type, in 400+ entries.URL Slug GeneratorTurn titles into clean, SEO-friendly URL slugs: accents, stop words, separators and bulk lines.JSON Schema GeneratorTurn sample JSON into a draft 2020-12 JSON Schema with types, required fields and formats.Gitignore GeneratorBuild a .gitignore from 50+ templates for languages, frameworks, IDEs and OS, merged and deduped.License GeneratorCreate a LICENSE file for MIT, Apache, GPL, BSD, ISC, MPL or Unlicense with your name and year.ULID GeneratorGenerate sortable ULIDs and UUID v7 in bulk, monotonic option, and decode their timestamps.Htpasswd GeneratorCreate .htpasswd entries with bcrypt, APR1-MD5 or SHA-1 for Apache and Nginx basic auth.Placeholder Image GeneratorCreate placeholder images in any size, color and text as PNG, JPG, WebP, SVG or data URI.Ads.txt GeneratorCreate or validate ads.txt and app-ads.txt files: seller lines, cert IDs and variables.Docker Run to Compose ConverterConvert docker run commands to docker-compose.yml, or a compose file back to docker run.Dockerfile GeneratorGenerate a production Dockerfile and .dockerignore for Node, Python, Go or a static nginx site.HTML Boilerplate GeneratorTick the options you need and get a clean HTML5 starter template with meta, OG tags and CSS reset.JSON to Zod SchemaInfer a Zod (or Yup) schema from sample JSON with optional, nullable and z.infer types.LLMs.txt GeneratorBuild an llms.txt file for AI crawlers: summary and link sections, import from your sitemap.Nano ID GeneratorGenerate secure Nano IDs with custom alphabet, length and count, plus a collision calculator.Nginx Config GeneratorBuild an nginx server block: static site, SPA, reverse proxy or PHP, with SSL, gzip and redirects.OpenAPI / Swagger ViewerView OpenAPI 2/3 JSON or YAML as interactive API docs with validation and an endpoint list.package.json GeneratorFill a form and get a valid, npm-ready package.json with scripts, dependencies and checks.PKCE Code Challenge GeneratorGenerate an OAuth 2.0 PKCE code_verifier and S256 code_challenge, build auth URLs, verify pairs.README GeneratorFill in a form and get a polished README.md with badges, install, usage and license, live preview.Regex GeneratorBuild regular expressions visually from blocks or presets (email, date, phone) and test them live.Commit Message GeneratorBuild Conventional Commit messages with type, scope, body, breaking change and issue refs.ESLint Config GeneratorGenerate a flat eslint.config.js for JavaScript, TypeScript, React or Node with rule presets.Git Branch Name GeneratorTurn a ticket ID and title into a clean, valid git branch name like feature/PROJ-12-add-login.GitLab CI Config GeneratorGenerate a .gitlab-ci.yml with stages, jobs, images, cache, artifacts and rules from templates.Jinja2 Template TesterRender Jinja2 templates with YAML or JSON variables using real Jinja2, with clear error lines.JSON Schema Mock Data GeneratorGenerate realistic sample JSON from a JSON Schema: formats, patterns, $ref, seeds and counts.Kubernetes Secret GeneratorCreate Kubernetes Secret YAML from key/value pairs or .env with auto base64, or decode one.Kubernetes YAML ValidatorValidate Kubernetes manifests against the API schema of a chosen version, with error paths.Prettier Config GeneratorToggle Prettier options, preview formatted code live and copy your .prettierrc file.Quartz Cron GeneratorBuild and explain Quartz and Spring cron expressions with seconds, ?, L, W and #, plus next fire times.README Badge GeneratorCreate Shields.io-style README badges for license, version, build and custom labels.tsconfig.json GeneratorBuild a tsconfig.json with target, module, strict checks and path aliases, each option explained.Access Log AnalyzerAnalyze Apache and Nginx access logs: top URLs, IPs, status codes, bots and traffic charts.Regex String GeneratorGenerate random test strings that match any regular expression, checked against the real regex.ASCII Table GeneratorTurn CSV or pasted cells into plain-text tables: MySQL, Markdown, Unicode box and reST styles.Database Schema DesignerDesign tables and relationships visually, then export SQL for MySQL, PostgreSQL or SQLite.Docker Compose GeneratorBuild a docker-compose.yml with a form: services, ports, volumes, env, healthchecks and presets.Dummy File GeneratorCreate test files of an exact size in KB, MB or GB with zeros, random bytes or text.FFmpeg Command GeneratorPick a task and options, get the exact ffmpeg command with every flag explained.Folder Tree GeneratorTurn a local folder or an indented list into an ASCII directory tree for your README.GitHub Actions Workflow GeneratorBuild a GitHub Actions CI workflow: triggers, matrix, caching, tests, Pages or Docker deploy.Kubernetes YAML GeneratorGenerate Deployment, Service, Ingress, ConfigMap, Secret and HPA manifests with safe defaults.Markdown TOC GeneratorGenerate a linked table of contents from Markdown headings with GitHub-style anchors.OpenAPI EditorEdit OpenAPI/Swagger YAML or JSON side by side with live API docs, validation and download.OpenAPI ValidatorValidate OpenAPI 3.0/3.1 and Swagger 2.0 specs: schema errors, broken $refs, line numbers.Pivot Table MakerBuild pivot tables from CSV or Excel by drag and drop: sum, count, average, charts, export.SQL Query BuilderBuild SELECT queries visually: joins, filters, GROUP BY, ORDER BY and LIMIT, as clean SQL.Truth Table GeneratorType a logic expression and get its full truth table, minterms and canonical DNF/CNF.TypeScript PlaygroundWrite TypeScript with live type checking, see the compiled JavaScript and run it in your browser.Article Schema GeneratorCreate Article, BlogPosting or NewsArticle JSON-LD with headline, authors, dates and images.Event Schema GeneratorCreate Event JSON-LD with dates, venue or online location, tickets, organizer and performers.
See all 85 Code Generators & Builders →