Skip to main content
ubuntu-blog.com

Search Ubuntu Blog

apt Command Builder for Ubuntu

Author: First published

The apt command builder turns a task, such as installing, removing, upgrading or fixing a package, into the exact Ubuntu command line. Choose apt for typing by hand or apt-get for scripts, add a package name, and tick sudo, simulate or yes if you need them. Each result says what the command does in the words of the Ubuntu manual page it comes from and warns about the risky steps.

apt command builder

Choose a task, fill in the package if the task needs one, and read the command. The builder only prints text: nothing is run, and nothing leaves your browser.

Task

One or more names separated by spaces. Add =version or /release after a name if you need one, such as openssl=3.0.2-0ubuntu1.18.

Command

How the builder forms a command

Every task in the builder is one row of data: the apt form, the apt-get form, the options that task accepts, a sentence from the Ubuntu manual page, and the page it came from. The builder joins the parts, checks the package names, and adds sudo when the task changes the system.

Command layout
[sudo] apt [options] <verb> [packages]
[sudo] apt-get [options] <verb> [packages]
read-only tasks (search, show, policy, depends) need no sudo
options
-s simulate, -y assume yes, --no-install-recommends; a task takes only the ones that apply to it
packages
names that follow Debian Policy; name=version picks a version, name/release picks a release

Example 1: install two packages without recommended extras

Worked example

Given: task: install; packages: nmap curl; sudo on, skip recommended packages on.

  1. Start with the program and the options: sudo apt --no-install-recommends
  2. Add the verb and the package list: install nmap curl

Answer: sudo apt --no-install-recommends install nmap curl

Example 2: preview a full upgrade in a script

Worked example

Given: task: upgrade and allow removals; tool: apt-get; simulate on.

  1. apt-get calls full-upgrade by another name: dist-upgrade
  2. Simulate goes right after the program: sudo apt-get -s dist-upgrade

Answer: sudo apt-get -s dist-upgrade shows the plan, including packages to be removed, and changes nothing.

Example 3: remove a program and its settings

Worked example

Given: task: remove packages; packages: nmap; purge on.

  1. Purge replaces remove: purge
  2. Follow with autoremove for dependencies nothing needs now: sudo apt autoremove

Answer: sudo apt purge nmap, then sudo apt autoremove.

apt and apt-get side by side

Tasks where the apt and apt-get commands differ
Taskaptapt-get
Upgrade and allow removals apt full-upgradeapt-get dist-upgrade
Reinstall a package apt reinstallapt-get install --reinstall
Search for a package apt searchapt-cache search
Show a package's details apt showapt-cache show
Show version priorities and sources for a package apt policyapt-cache policy
Show what a package depends on apt dependsapt-cache depends
Show what depends on a package apt rdependsapt-cache rdepends

Sources 1 to 3. The apt manual says it is an end user interface and that apt-get and apt-cache keep backward compatibility for scripts. Tasks not listed use the same words in both.

Assumptions and limits

  • The wording and options follow the apt, apt-get, apt-cache, apt-mark and dpkg manual pages for Ubuntu 24.04 (Noble), read on 2026-11-14. Older releases can differ: check man apt on your own system.
  • The builder prints text. It does not run anything, check that a package exists, or know which packages your sources offer. Use the search and policy tasks for that.
  • Simulating (-s) is a plan, not a guarantee: the apt-get manual notes the system state can change while it runs, and a simulation by a normal user may not read every configuration file.
  • The yes option skips the prompts that let you stop a bad plan. Use it only after you have read the plan with simulate.
  • Packages from PPAs and other third-party sources run installation scripts as root. Add only sources you trust.
  • Snap, Flatpak and manual downloads are outside the scope of this tool.

Questions readers ask

What is the difference between apt update and apt upgrade?

apt update downloads package information from all configured sources and installs nothing. apt upgrade then installs the newer versions that information lists for packages you already have, and it never removes an installed package. Run update first, because upgrade works from the local list. The builder shows both commands in the refresh and upgrade group.

How do I remove a package completely?

Use apt purge instead of apt remove. The apt manual says remove leaves usually small modified configuration files behind, and purge gets rid of those leftovers, though it does not touch settings in your home directory. Then run apt autoremove to clear dependencies nothing needs now. In the builder, tick "Also purge configuration files" on the remove task to get apt purge.

What does apt autoremove do?

apt autoremove removes packages that were installed automatically to satisfy dependencies and are no longer needed, because the packages that needed them changed or were removed. Read the list before you confirm. A package you installed yourself with apt install is never proposed for automatic removal, and apt-mark manual protects one that arrived as a dependency.

How do I fix held-back or broken packages?

For packages kept back by apt upgrade, try apt full-upgrade, which may remove packages, and read the plan first with the simulate option. Some are phased updates that arrive on their own. For broken dependencies run apt --fix-broken install, then dpkg --configure -a for an interrupted install. apt-mark showhold lists packages you held yourself.

What is the difference between apt and apt-get?

apt is a high-level command line intended as an end user interface, with options better suited to interactive use. The apt manual warns it may change behavior between versions and advises using apt-get and apt-cache in scripts. For basic tasks the syntax is the same, and the builder shows both forms. Both use the same package database.

What is the difference between apt and snap?

apt installs deb packages, the collection at the core of every Ubuntu release. Snap is a separate package format. Canonical describes snaps as suited to apps and tools that update frequently and independently from the main system. They have their own command, snap, so apt update and apt upgrade do not manage them, and this builder covers apt only.

How do I install a specific version of a package?

Follow the package name with an equals sign and the version, as in apt install name=version. The apt manual also allows a slash and a release name, as in name/noble-updates, to take the version from that release. Run apt policy name first to see the installed and candidate versions and the priority of each source. The builder accepts both forms.

Why does the builder reject my package name?

Debian Policy says package names consist only of lower case letters, digits, plus and minus signs and periods, are at least two characters long and start with a letter or digit. The builder checks for that before it prints a command, which also stops stray characters, such as a semicolon, from ending up in a shell command that you might paste and run.

Further reading

  1. apt(8) manual page, Ubuntu 24.04 (Noble) (manpages.ubuntu.com) Read 2026-11-14.
  2. apt-get(8) manual page, Ubuntu 24.04 (Noble) (manpages.ubuntu.com) Read 2026-11-14.
  3. apt-cache(8) manual page, Ubuntu 24.04 (Noble) (manpages.ubuntu.com) Read 2026-11-14.
  4. apt-mark(8) manual page, Ubuntu 24.04 (Noble) (manpages.ubuntu.com) Read 2026-11-14.
  5. dpkg(1) manual page, Ubuntu 24.04 (Noble) (manpages.ubuntu.com) Read 2026-11-14.
  6. Debian Policy Manual, 5.6.1 Source (package names) (debian.org) Read 2026-11-14.
  7. Ubuntu Server documentation: Upgrade your release (ubuntu.com) Read 2026-11-14.
  8. Ubuntu release cycle (Canonical): deb and snap packages (ubuntu.com) Read 2026-11-14.

Worth reading next