100 Linux Command Examples, Organised Around Real Tasks

Image retained from the original article.

Originally published 21 June 2023; rewritten and reviewed on 15 October 2026.

A long command list becomes useful when it helps answer a question. Where am I? Which file changed? Why did the service stop? I would learn a small inspection workflow first, then return to the reference when a specific task calls for another tool.

The examples below are a practice reference, not a script to execute in sequence. Names such as notes.txt, demo, example.service and example.com are placeholders. Commands and flags vary across distributions, and some tools may require installation. Practise file-changing operations only in a disposable directory you created.

Navigation and file inspection

  1. pwd — show the current directory.
  2. ls — list visible entries.
  3. ls -la — include hidden entries and details.
  4. cd demo — enter a chosen directory.
  5. cd .. — move to its parent.
  6. realpath notes.txt — resolve a full path.
  7. stat notes.txt — inspect file metadata.
  8. file notes.txt — inspect the detected file type.
  9. readlink link-name — show a symbolic link’s target.
  10. find . -maxdepth 2 -type f — find nearby regular files.

Reading and comparing text

  1. cat notes.txt — print a small text file.
  2. less notes.txt — page through a file.
  3. head -n 20 notes.txt — inspect its beginning.
  4. tail -n 20 notes.txt — inspect its end.
  5. tail -f app.log — follow appended log output.
  6. wc -l notes.txt — count newline characters.
  7. grep -n 'error' app.log — find matching lines.
  8. sort names.txt — print sorted lines.
  9. uniq sorted-names.txt — collapse adjacent duplicates.
  10. diff -u before.txt after.txt — compare text versions.

Working in a disposable directory

  1. mkdir demo — create a directory.
  2. mkdir -p demo/subdir — create missing parents.
  3. touch demo/notes.txt — create or update a file timestamp.
  4. cp notes.txt demo/notes-copy.txt — copy to an intentional destination.
  5. cp -i notes.txt demo/notes.txt — ask before overwriting.
  6. mv -i demo/notes-copy.txt demo/renamed.txt — rename with overwrite prompting.
  7. ln -s notes.txt notes-link — create a symbolic link.
  8. rmdir demo/empty — remove an empty directory.
  9. rm -i demo/renamed.txt — remove one named file after prompting.
  10. find demo -type f -name '*.txt' -print — preview matching files.

Understanding identity and permissions

  1. whoami — show the effective username.
  2. id — show user and group identifiers.
  3. groups — list current group memberships.
  4. umask — inspect the creation mask.
  5. ls -ld demo — inspect directory permissions.
  6. namei -l /path/to/file — inspect permissions along a path.
  7. getent passwd username — look up a user entry.
  8. getent group groupname — look up a group entry.
  9. chmod u+x demo/script.sh — add owner execution permission to a known script.
  10. sudo -l — inspect your permitted sudo operations.

Processes and system load

  1. ps aux — inspect processes.
  2. ps -ef — inspect another common process listing.
  3. pgrep -a process-name — find matching processes.
  4. top — inspect changing resource usage.
  5. uptime — show uptime and load averages.
  6. free -h — inspect memory accounting.
  7. vmstat 1 5 — sample system activity.
  8. lscpu — inspect CPU information.
  9. uname -a — inspect kernel information.
  10. hostnamectl — inspect host metadata on systemd hosts.

Storage and mounts

  1. df -h — inspect filesystem capacity.
  2. df -i — inspect inode usage.
  3. du -sh demo — measure one directory.
  4. du -h --max-depth=1 demo — compare its immediate children.
  5. lsblk — inspect block devices.
  6. findmnt — inspect mounted filesystems.
  7. findmnt / — inspect the root filesystem mount.
  8. ls -lh archive.tar.gz — inspect an archive’s size.
  9. tar -tzf archive.tar.gz — list an archive without extracting.
  10. unzip -l archive.zip — list ZIP entries.

Networking and HTTP inspection

  1. ip address — inspect interface addresses.
  2. ip route — inspect routes.
  3. ss -lnt — inspect listening TCP sockets.
  4. ss -lun — inspect listening UDP sockets.
  5. getent hosts example.com — use the host’s name-resolution configuration.
  6. dig example.com — inspect DNS answers with an installed DNS tool.
  7. ping -c 4 example.com — send a bounded connectivity probe where authorised.
  8. curl -I https://example.com — request HTTP headers.
  9. curl --fail --location https://example.com — fetch a known public resource.
  10. openssl s_client -connect example.com:443 -servername example.com — inspect a TLS connection.

Services and logs on systemd hosts

  1. systemctl status example.service — inspect one service.
  2. systemctl cat example.service — inspect its unit definition.
  3. systemctl --failed — list failed units.
  4. systemctl list-timers — inspect timers.
  5. journalctl -u example.service -n 50 — inspect recent service logs.
  6. journalctl -u example.service --since today — inspect today’s entries.
  7. journalctl -b — inspect the current boot journal.
  8. journalctl --disk-usage — inspect journal storage.
  9. systemctl is-enabled example.service — inspect boot enablement.
  10. systemctl is-active example.service — inspect current activation.

Archives, hashes and structured output

  1. sha256sum notes.txt — calculate a content hash.
  2. sha512sum archive.tar.gz — calculate an archive hash.
  3. gzip -l archive.gz — inspect gzip metadata.
  4. tar -czf demo-backup.tar.gz demo — create an archive of a known directory.
  5. zip -r demo-backup.zip demo — create a ZIP of known files.
  6. jq '.' data.json — format JSON with jq installed.
  7. jq '.items | length' data.json — count a known array.
  8. python3 -m json.tool data.json — inspect JSON using Python.
  9. cut -d ',' -f 1 simple.txt — split simple delimited text, not arbitrary quoted CSV.
  10. printf '%s\n' 'example' — print a controlled string.

Help and shell understanding

  1. man ls — read a manual page.
  2. ls --help — inspect command options.
  3. type cd — identify how the shell resolves a command.
  4. command -v dotnet — locate a command in PATH.
  5. printenv PATH — inspect the executable search path.
  6. history 20 — inspect recent commands without sharing sensitive history.
  7. date --iso-8601=seconds — print a timestamp with supported GNU date.
  8. timedatectl — inspect system time configuration.
  9. sleep 1 — pause briefly in a practice shell.
  10. exit — leave the current shell.

Turn the list into a troubleshooting sequence

Start with location and identity, inspect the relevant service, then follow its logs and dependencies. Read the manual before using unfamiliar flags. Commands that change files, privileges or services need a defined target and recovery plan. Being comfortable at the terminal means understanding the effect of the command you are about to run, not memorising the largest possible list.

Related reading