Ubuntu Command Line Cheat Sheet for 2026

Last updated Sunday, May 17, 2026 5:38 pm Joshua James 12 min read

A useful Ubuntu command line cheat sheet for 2026 needs to be searchable, copy-ready, and honest about what changes between releases. Ubuntu 26.04 LTS, 24.04 LTS, and 22.04 LTS share the same core terminal workflow, but APT output, coreutils behavior, and optional tools can differ enough that older printable sheets need a few current notes.

Use the commands here as a practical Ubuntu terminal reference for package management, files, users, services, logs, networking, firewall checks, remote access, and Ubuntu-specific tools. When a command changes system state, read the surrounding note before pasting it into a production server or remote SSH session.

Ubuntu Command Line Cheat Sheet Quick Reference

Start with the commands that answer the most common Ubuntu terminal questions: where you are, which release you are running, what packages can change, which services are active, and where logs live.

TaskCommandWhat It Does
Show current directorypwdPrints the shell’s current working directory.
List filesls -laLists normal and hidden entries with permissions, owner, size, and date.
Change directorycd /path/to/directoryMoves the current shell to another directory.
Check Ubuntu releaselsb_release -aShows the release number, codename, and description when the helper is installed.
Check release fieldsgrep -E '^(VERSION_ID|VERSION_CODENAME)=' /etc/os-releaseReads exact release fields from a file present on normal Ubuntu installs.
Refresh package metadatasudo apt updateDownloads current package lists from enabled APT sources.
Upgrade packagessudo apt upgradeUpgrades installed packages without removing packages.
Check service statussystemctl status <service>Shows whether a systemd service is loaded, active, and logging errors.
Read service logsjournalctl -u <service> -n 50 --no-pagerPrints the newest 50 journal entries for one unit.
Show IP addressesip -brief addrLists interfaces and addresses in a compact format.
Show listening TCP portsss -ltnLists local TCP sockets that are waiting for connections.
Check firewall statesudo ufw status verboseShows UFW status and active rules when UFW is installed.
Open command helpman <command> or <command> --helpShows detailed or short help for a command.

Read Ubuntu Command Syntax Correctly

Cheat sheets often use placeholder values. Replace the placeholder and remove the angle brackets before running the command. For example, sudo apt install <package> becomes sudo apt install htop, not sudo apt install <htop>.

Commands with sudo can change system files, users, services, firewall policy, or packages. On remote systems, confirm your SSH access and the command target before restarting services, enabling firewalls, removing packages, or editing network configuration.

The same command can print different output on supported Ubuntu LTS releases. The main difference for package maintenance is APT: Ubuntu 26.04 uses APT 3, while Ubuntu 24.04 and 22.04 use APT 2. The command behavior is usually the same, but transaction summaries and status wording can differ.

Ubuntu ReleaseCodenameCLI Note
Ubuntu 26.04 LTSresoluteUses APT 3 and introduces rust-coreutils for many base utilities while keeping GNU implementations for some commands. Prefer explicit forms such as head -n 20 instead of shorthand like head -20.
Ubuntu 24.04 LTSnobleUses APT 2 with GNU coreutils by default, so many package examples show older APT output wording.
Ubuntu 22.04 LTSjammyUses older APT 2, GNU coreutils, Bash, and systemd versions; avoid assuming newer Bash or command options without checking help.

For release-specific repository work, confirm the codename first with:

lsb_release -rs
lsb_release -cs

On Ubuntu 26.04, those commands print:

26.04
resolute

For deeper release checks, use the dedicated guide to check the Ubuntu version from the terminal.

Manage Ubuntu Packages with APT and Snap

APT manages Ubuntu repository packages and third-party APT sources. Snap manages Snap packages through the Snap Store. Keep those package sources separate when you install, update, troubleshoot, or remove software.

APT Command Cheat Sheet

TaskCommandWhat It Does
Refresh package listssudo apt updateDownloads current metadata from every enabled APT source.
Show pending upgradesapt list --upgradableLists installed packages with newer candidates.
Upgrade installed packagessudo apt upgradeApplies upgrades without removing installed packages.
Resolve broader dependency changessudo apt full-upgradeAllows package removals or new dependency choices when needed.
Search package descriptionsapt search <name>Searches package names and descriptions.
Inspect candidate sourceapt-cache policy <package>Shows installed version, candidate version, and package source priorities.
Install a packagesudo apt install <package>Installs the named package and required dependencies.
Upgrade one installed packagesudo apt install --only-upgrade <package>Upgrades the package only if it is already installed.
Reinstall a packagesudo apt install --reinstall <package>Reinstalls files from the package while keeping package state.
Fix broken dependenciessudo apt --fix-broken installAttempts to complete or repair an interrupted dependency transaction.
Remove package binariessudo apt remove <package>Removes the package while leaving system configuration files.
Purge package configurationsudo apt purge <package>Removes the package and its package-owned configuration files.
Remove unused dependenciessudo apt autoremoveRemoves packages installed automatically that are no longer needed.
Clean downloaded package filessudo apt cleanClears downloaded package archives from APT’s cache.

For routine maintenance, use a reviewable sequence instead of adding -y to every command:

sudo apt update
apt list --upgradable
sudo apt upgrade

APT 3 History Commands on Ubuntu 26.04

Ubuntu 26.04’s APT 3 command set adds transaction history commands. Use the read-only history commands first; undo and redo operations can remove or reinstall packages, so review the proposed transaction before confirming.

TaskCommandWhat It Does
List APT historyapt history-listShows recent APT transactions with IDs, dates, actions, and changed package counts.
Inspect one transactionapt history-info <id>Shows details for a selected transaction ID.
Undo a transactionsudo apt history-undo <id>Proposes the inverse transaction so you can review it before continuing.
Redo a transactionsudo apt history-redo <id>Repeats a previous transaction when the packages are still available.

Use the full maintenance article when you need more detail on updating Ubuntu packages from the command line. For cleanup decisions, use the separate guide to remove packages on Ubuntu from the command line. For downloaded local packages, APT can install and remove local .deb files cleanly when you follow the Ubuntu DEB file workflow.

If APT cannot find a package that should exist, refresh metadata first and then check whether the required component is enabled. Many desktop and community packages live in Universe or Multiverse, which you can review with the guide to enable Universe and Multiverse on Ubuntu.

Snap Command Cheat Sheet

TaskCommandWhat It Does
Search for snapssnap find <name>Searches the Snap Store.
Show snap detailssnap info <snap>Shows channels, publisher, installed state, and description.
Install a snapsudo snap install <snap>Installs the snap from its default channel.
List installed snapssnap listLists installed Snap packages and revisions.
Refresh snapssudo snap refreshUpdates installed snaps according to Snap refresh policy.
Remove a snapsudo snap remove <snap>Removes the selected snap and may keep a recovery snapshot.

Standard Ubuntu Desktop and Server installs normally include snap, but minimal images, containers, and custom builds can omit it. Other useful commands, including htop, tree, curl, and lxc, are optional tools rather than a safe assumption on every Ubuntu install.

Navigate and Manage Files on Ubuntu

File commands are safest when you start in the right directory and quote paths that contain spaces. Use pwd before destructive commands, and prefer exact paths over broad recursive cleanup.

TaskCommandWhat It Does
Show current pathpwdPrints the current directory.
List one entry per linels -1Prints a compact list for scanning or pipelines.
Long list with hidden filesls -laShows permissions, owner, group, size, date, and hidden entries.
Change to homecd or cd ~Returns to the current user’s home directory.
Return to previous directorycd -Switches back to the previous working directory.
Create nested directoriesmkdir -p project/logsCreates parent directories as needed.
Create or update a file timestamptouch file.txtCreates an empty file or updates an existing file’s timestamp.
Copy a filecp source.txt destination.txtCopies one file to a new path.
Copy a directory recursivelycp -a source-dir backup-dirCopies a directory while preserving metadata.
Move or renamemv old-name new-nameMoves or renames a file or directory.
Remove one filerm file.txtDeletes a file immediately.
Remove an empty directoryrmdir empty-dirDeletes only an empty directory.
Find files by namefind . -type f -name '*.log'Searches from the current directory for matching files.
Identify a file typefile archive.tar.gzReports the file type based on content and metadata.

The cd command is a shell built-in, not a separate package. Use the detailed cd command guide for path expansion, cd -, and symbolic-link behavior. For permission-sensitive cleanup, review the chmod command examples before changing modes recursively.

Archive and Compress Files on Ubuntu

Archive commands are common in downloads, backups, log bundles, and software releases. Check the archive type with file when the extension is unclear, and extract into a directory you control before moving files into system paths.

TaskCommandWhat It Does
Create a gzip tar archivetar -czf backup.tar.gz folder/Creates a compressed tar archive from a directory.
List archive contentstar -tzf backup.tar.gzShows what a gzip tar archive contains before extraction.
Extract a gzip tar archivetar -xzf backup.tar.gz -C ./restoreExtracts the archive into a chosen directory.
Compress one filegzip file.logCreates file.log.gz and removes the original file.
Decompress one gzip filegunzip file.log.gzRestores the original uncompressed file.
Create a ZIP archivezip -r project.zip project/Compresses a directory into a ZIP file when zip is installed.
Extract a ZIP archiveunzip project.zip -d ./projectExtracts a ZIP archive into a target directory when unzip is installed.

On minimal Ubuntu systems, confirm zip, unzip, or 7z exists with command -v before using those rows. For deeper examples, use the guide to open GZ and TGZ files in Linux or the workflow to unzip archives into a directory. If a workflow needs the 7z command, install it first with the 7-Zip on Ubuntu guide.

Read, Search, and Process Text

Ubuntu terminal work often starts with reading logs, filtering configuration, or counting matching lines. Prefer explicit options such as head -n 20 and tail -n 50 because they read clearly and avoid implementation-specific shorthand.

TaskCommandWhat It Does
Print a whole filecat file.txtWrites file contents to the terminal.
Page through a fileless file.txtOpens a scrollable viewer; press q to quit.
Print first lineshead -n 20 file.txtShows the first 20 lines.
Print newest log linestail -n 50 /var/log/syslogShows the last 50 lines.
Follow a growing logtail -f /var/log/syslogPrints new lines as they are appended.
Search for textgrep -n 'error' app.logPrints matching lines with line numbers.
Search recursivelygrep -R 'server_name' /etc/nginxSearches files under a directory.
Print selected fieldsawk '{print $1}' file.txtPrints the first whitespace-separated field from each line.
Preview line rangessed -n '10,20p' file.txtPrints only lines 10 through 20.
Count lineswc -l file.txtCounts newline-delimited lines.
Sort and de-duplicatesort file.txt | uniqSorts lines and removes adjacent duplicates.
Write output as rootprintf '%s\n' 'value' | sudo tee /etc/example.confWrites piped text to a root-owned file.

Use the grep command guide for pattern matching, the tail command guide for live log-following examples, and the sed command examples for repeatable stream edits. For URL downloads and HTTP checks, use wget examples when wget is available, or use the curl command guide when curl is installed and the workflow needs curl-specific options.

Change Permissions, Users, and Groups

User and permission commands can affect login access, service files, and private data. Check the target account, group, and path before applying recursive ownership or mode changes.

TaskCommandWhat It Does
Show current identityidPrints user ID, group ID, and supplementary groups.
Show another user’s groupsgroups <username>Lists the groups for a named account.
Show logged-in usersw or whoShows current login sessions.
Validate sudo accesssudo -vRefreshes sudo credentials or fails if the account lacks sudo access.
Create an interactive usersudo adduser <username>Creates a user through Ubuntu’s friendly account helper.
Add user to a groupsudo usermod -aG <group> <username>Adds a user to a supplementary group without replacing existing groups.
Delete a usersudo deluser <username>Removes the account but does not automatically delete every related file.
Set a passwordsudo passwd <username>Sets or changes a user’s password.
Lock a passwordsudo passwd -l <username>Locks password login for the account.
Change file modechmod 640 file.confSets owner, group, and other permissions with numeric mode.
Add executable bitchmod u+x script.shMakes a script executable by its owner.
Change owner and groupsudo chown user:group fileAssigns ownership to a user and group.

Ubuntu keeps routine administration tied to sudo. If a new administrator cannot run privileged commands, use the full workflow to add a new user to sudoers on Ubuntu instead of editing sudoers blindly.

Inspect Processes, Services, and Logs

Ubuntu uses systemd for system services. Start with read-only status and log commands before restarting daemons, killing processes, or enabling services at boot.

TaskCommandWhat It Does
Show uptime and loaduptimePrints system uptime and load averages.
Interactive process viewtopShows live CPU, memory, and process activity.
List process tableps auxPrints a broad process list.
Find process IDspgrep -a <name>Finds processes by name and shows command lines.
Terminate by process IDkill <pid>Sends the default terminate signal to one process.
Run command in background<command> &Starts a command while returning control to the shell.
List shell jobsjobsShows jobs started by the current shell.
Bring job to foregroundfg %1Returns job 1 to the foreground.
Check service statesystemctl is-active <service>Prints whether a unit is active.
Show service detailssystemctl status <service>Shows load state, active state, recent logs, and unit metadata.
Restart a servicesudo systemctl restart <service>Stops and starts a service.
Reload configurationsudo systemctl reload <service>Reloads configuration when the unit supports reload.
Enable service at bootsudo systemctl enable --now <service>Starts the service now and enables it for future boots.
Read unit logsjournalctl -u <service> -n 50 --no-pagerShows recent journal entries for a service.
Follow live logsjournalctl -fPrints new journal entries as they arrive.
List systemd timerssystemctl list-timers --allShows scheduled systemd timers.
Edit user cron jobscrontab -eOpens the current user’s crontab in an editor.
List user cron jobscrontab -lPrints the current user’s scheduled cron entries.

Use systemctl status for diagnosis, but use narrower checks such as systemctl is-active in scripts. A service can have a different unit name than the package name, so verify the exact unit with systemctl list-unit-files | grep '<name>' when a status command returns Unit not found.

Check Networking, Firewall, and Remote Access

Networking commands should separate local interface state, DNS resolution, listening sockets, firewall rules, and remote connectivity. Do not open firewall ports until the service is actually listening and the intended access path is clear.

TaskCommandWhat It Does
Show interface addressesip -brief addrLists interfaces and assigned addresses.
Show routesip routePrints the kernel routing table.
Show listening TCP socketsss -ltnShows TCP ports waiting for connections.
Show process names for socketssudo ss -ltnpAdds process details for listening TCP sockets.
Test IP reachabilityping -c 4 1.1.1.1Sends four ICMP requests to a public IP address.
Test DNS and reachabilityping -c 4 ubuntu.comChecks whether a hostname resolves and responds to ICMP.
Check DNS resolver stateresolvectl statusShows resolver servers and per-link DNS state.
Download a URLwget <url>Downloads the URL you provide over HTTP or HTTPS.
Check UFW statussudo ufw status verboseShows whether UFW is active and which rules exist.
Allow the OpenSSH UFW profilesudo ufw allow OpenSSHAdds the packaged OpenSSH application rule when the profile exists.
Allow a TCP portsudo ufw allow 8080/tcpAllows inbound TCP traffic to port 8080.
Connect over SSHssh user@example.comStarts a remote shell over SSH.
Copy a file over SSHscp file.txt user@example.com:/tmp/Copies one local file to a remote host.
Review Netplan configsudo cat /etc/netplan/*.yamlPrints matching Netplan YAML files, including root-readable configurations.
Test Netplan changessudo netplan tryApplies a network change temporarily so it can roll back if not confirmed.
Apply Netplan changessudo netplan applyApplies the current Netplan configuration.

Use the focused Ubuntu workflows when you need to enable or disable the firewall on Ubuntu or enable SSH on Ubuntu. For client flags, one-off remote commands, and tunnels, use the ssh command guide.

Use Ubuntu-Specific CLI Tools

Ubuntu also ships or documents tools that are less universal than basic shell commands. Treat these as context-specific commands: they only apply when the feature is installed, configured, or part of your support plan.

AreaCommandUse It When
Ubuntu Propro statusYou need to see whether Ubuntu Pro services are attached or enabled.
Ubuntu Prosudo pro attach <token>You are attaching a system to a valid Ubuntu Pro subscription token.
Ubuntu Prosudo pro enable livepatchYou want to enable Livepatch on a supported attached system.
LXDlxc listLXD is installed and initialized, and you need to list instances.
LXDlxc launch ubuntu:26.04 <name>You want to create and start an Ubuntu 26.04 LTS container from an image alias.
LXDlxc exec <instance> -- bashYou need a shell inside a running LXD instance.
Netplansudo netplan getYou want Netplan to print the merged network configuration, including root-readable files.
Netplansudo netplan tryYou are testing a network change and need an automatic rollback window.

The pro command is part of normal Ubuntu Pro tooling on current Ubuntu LTS systems. The lxc command appears only after LXD is installed, so do not copy LXD commands from a cheat sheet onto a base server and expect them to exist. Canonical maintains separate resources for Ubuntu Pro and LXD.

Troubleshoot Common Ubuntu CLI Errors

Most command-line problems become easier once you identify whether the failure is a missing command, missing package source, permission issue, locked package manager, wrong service name, or wrong path.

SymptomFirst CheckLikely Next Step
command not foundcommand -v <command>Install the package that provides the command or use a built-in alternative.
E: Unable to locate packagesudo apt update and apt-cache policy <package>Check spelling, enabled APT sources, and Universe or Multiverse availability.
Permission deniedls -ld <path> and idFix ownership or permissions only after confirming the correct target path.
APT or dpkg lock messagepgrep -af '[a]pt|[d]pkg'Wait for the active package task or inspect apt-daily services; do not delete lock files as a first response.
Unit not foundsystemctl list-unit-files | grep '<name>'Verify the installed package and exact service unit name.
No such file or directorypwd and ls -laConfirm the current directory, quote paths with spaces, and check whether the file exists.
Firewall rule did not worksudo ufw status numbered and sudo ss -ltnpConfirm the service is listening on the expected port before changing firewall policy.
DNS lookup failsresolvectl status and ping -c 4 1.1.1.1Separate DNS resolver problems from general network reachability.

For package inventory checks after troubleshooting, use the guide to list installed packages on Ubuntu. Package ownership matters when a command exists in more than one location or a previous manual install shadows the APT-managed version.

Official Ubuntu CLI Resources

Canonical maintains an Ubuntu Server command-line cheat sheet in the official documentation and a downloadable Ubuntu CLI cheat sheet PDF. Those resources are useful for quick lookup; release notes, optional-command caveats, and full workflow links still matter when a command depends on release, package source, or system state.

For release status and support context, use Ubuntu’s official release cycle page. For 26.04-specific terminal changes such as APT 3, rust-coreutils, Netplan 1.2, and systemd 259, review the Ubuntu 26.04 LTS summary for LTS users.

Conclusion

Ubuntu terminal work is easier when quick lookups start with the right command family and a clear risk boundary. Use the linked workflows when a command changes packages, users, services, firewall rules, network access, or release-specific configuration, then verify the result before moving to the next command.

Follow LinuxCapable

Want more LinuxCapable guides in Google?

Add LinuxCapable as a preferred source so Google can show more of our fresh Linux tutorials in Top Stories and From your sources when relevant.

Add LinuxCapable as a preferred source on Google
Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffeeBuy me a coffee
Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed in published comments:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<blockquote>quote</blockquote> quote block

Got a Question or Feedback?

We read and reply to every comment - let us know how we can help or improve this guide.

Let us know you are human: