apt command (Linux / bash / sh / zsh)
What it does
Search, install, update, and remove packages on Debian-based systems. When people search for the apt command linux packages, they usually want apt's everyday flags, safe examples, and how it differs from related tools. Below you'll find syntax, options, and copyable examples for Bash/sh/zsh.
Search, install, update, and remove packages on Debian-based systems.
Syntax
apt [OPTION] COMMAND [PACKAGE...]
Common options
| Flag / option | Meaning |
|---|---|
| update | Refresh package indexes. |
| install PACKAGE | Install or upgrade a package. |
| remove PACKAGE | Remove a package while retaining configuration. |
| search TERM | Search available package descriptions. |
| show PACKAGE | Display package details. |
Practical examples
Refresh indexes
sudo apt update
Downloads current repository metadata.
Install Git
sudo apt install git
Installs Git and required dependencies.
Find package
apt search image editor
Searches package names and descriptions.
Common mistakes
- Running install without refreshing stale package indexes.
- Confusing `apt remove` with `apt purge`, which also removes packaged configuration.
Related commands
- yumManage RPM packages and repositories on compatible Linux distributions.
- sudoRun an authorized command with another user's privileges.
- whichLocate the executable selected from the current PATH.
- conda createCreate a new isolated Conda environment with an optional Python version and starter packages.
- conda activateActivate a named or path-based Conda environment in the current shell session.
- conda installInstall packages into the active or named Conda environment from configured channels.
- conda listList packages installed in the active or named Conda environment.
- conda env listList all Conda environments and mark the currently active one.
FAQ
What does apt do in Linux?
Search, install, update, and remove packages on Debian-based systems.
How do I use apt from the terminal?
Start with `apt [OPTION] COMMAND [PACKAGE...]`, then choose only the options needed for the task.
What is a practical apt example?
Try `sudo apt update` — Downloads current repository metadata.
Can I use apt in a shell script?
Yes. apt works in Bash, sh, and Zsh, but scripts should handle quoting, errors, and command output explicitly.
Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.