apt-get install
Packages and runtimes
Usage
sudo apt-get install [-y] <package>...Installs from the package list already on disk, so a stale list gives "Unable to locate package" until apt-get update runs; apt-get keeps a stable interface for scripts, while apt is the one meant for humans.
Common flags
| Flag | Meaning |
|---|---|
| -y | answer yes, needed in scripts and Dockerfiles |
| --no-install-recommends | skip recommended extras, keeping images small |
| -s | simulate; print the plan and change nothing |
| --only-upgrade | upgrade it if present, do not install it new |
| --reinstall | install the same version over itself |
| -f | try to fix broken dependencies |
Examples
sudo apt-get install -y curl gitthe usual line in a Dockerfile
sudo apt-get install --no-install-recommends nginxnginx without the suggested extras
sudo apt-get install -s ffmpegshows what would be pulled in
The question is always what goes where: inside this project, or on the whole machine.
How to read this
- Square brackets [ ] mark a part you may leave out.
- An ellipsis … means you can list more than one.
- Flags are case-sensitive — in some commands -r and -R do different things.
Questions
Q. What does apt-get install do?
Installs from the package list already on disk, so a stale list gives "Unable to locate package" until apt-get update runs; apt-get keeps a stable interface for scripts, while apt is the one meant for humans.
Q. How do I type it?
sudo apt-get install [-y] <package>... — square brackets mark the parts you can leave out.
Q. How many flags are worth knowing?
6 are listed here; the full set is in man apt-get. This command sits under Packages and runtimes.
Related commands
man page: man apt-get-install