top of page

Basic Apt commands in Linux.

Feb 29, 2020
2 min read

Advanced Package Tool, or APT, is a free software user interface that works with core libraries to handle the installation and removal of software on Debian, Ubuntu, and related Linux distributions. APT simplifies the process of managing software on Unix-like computer systems by automating the retrieval, configuration and installation of software packages, either from precompiled files or by compiling source code.


1. Manual

To open manual pages for the apt tool containing all the commands, modes and right ways to use apt.

man apt

2. Update package index

To sync the indexes of the package from their sources or the main repository. You need to use " apt update " before upgrading else you will get old updates of the time you last run the update command.

sudo apt update

3. Upgrade

To download and install the upgrades to the installed packages from the main repository or repositories mentioned in sources.list file at /etc/apt/sources.list. You need to do an "apt update" at time of upgrading, else you will not get the latest upgrades till that point.

sudo apt upgrade

4. Search a package

To search a package with the mentioned keyword in either name or description from repositories mentioned in sources.list file at /etc/apt/sources.list.

sudo apt search <keyword>

5. Install a package

To install a package. You need to know the exact name of the package to successfully install it.

sudo apt install <package-name>

6. Remove a package

To remove an installed package. To remove a package you need to know the accurate name of the package.

Warning: It also removes all the configuration files installed with the software.

sudo apt autoremove <package-name>

7. Clean downloaded unused packages

It clears all the downloaded unused local packages from the /var/cache/apt/archives/partial/ and /var/cache/apt/archives directories, except the lock file.

sudo apt autoclean

and there are many more commands of apt you can use. You can explore them from man pages of the apt tool.

Comments


bottom of page