While it is easy to install and manage many applications from the Ubuntu Software Center, it is often convenient to be able to manage installation and other operations from the command prompt. In Ubuntu, management and installation of applications from the command line is handled by APT (Advanced Package Tool).
Mastering this will allow you to have better control over the process of installing applications on your machines. As you become more familiar with Ubuntu APT, you’ll even be able to manage your installed apps faster through the command line than with the included GUI Software Center.
Note: unless you are logged in with the root account on your system, you will need to use
sudo in front of the commands below.
Installation of the application
There are several different commands associated with installing applications with APT.
Install a new package
To install a new package, use the command below:
Install multiple packages with a single line of code
Instead of installing the packages one by one, they can also be installed using the command below:
There are a few options for removing packages in APT. Deleting packages is more nuanced than simply deleting files from a folder, and the commands available to support deleting packages support it.
Remove a package while leaving the configuration files intact
If you want to remove a package from your computer while leaving the configuration files intact, you can use the command below. This method is useful for packages that you can reinstall later.
Remove package with configuration files
If you want to remove all configuration files associated with a package, use the command below. This command is useful for packages that you do not plan to reinstall and would like to see completely removed from your system.
Remove one package and install another in one go
It is actually quite common to remove one package because another is more appropriate. Whatever the reason, you can remove a package and install a package with one command. If you want to do this, enter the following:
In this case, you will remove package1 and install package2.
Remove unnecessary packages
To remove unnecessary packages, you can use the command below:
You can combine this with removing packages, so that all unnecessary packages are removed when you uninstall a package.
Maintain your Ubuntu system with APT
Just like with a physical object, you will need to perform maintenance on your Ubuntu system from time to time.
Update system packages
You should update your system packages regularly to keep your system running in optimal condition. The command below resynchronizes the package index files with their sources.
The command below upgrades all packages installed on your system to the latest versions.
This command also upgrades system packages, but it can also remove installed packages to avoid conflicts.
Finding Packages and Package Information
You might be looking for a package, but you might not be sure of the name. You can also just search for information about a package. Find out how to achieve this below.
Localization of packages with keywords
To search for a package containing a particular keyword, you can use the command:
View information about a package
The command below will display information about a package, such as its version, size, dependencies, and any conflicts with it on your system.
If you want a list of all available packages, use the following command:
The following command provides a list of all available packages, including information about the versions and architecture of the package:
If you want to see all the packages you have installed on your system, use:
To display a list of upgradeable packages, use the following command:
Now that you know how to use Ubuntu Apt, there are times when a package is broken and you need to fix it. Learn how to fix broken packages in Ubuntu. Or, if you prefer Software Center and it isn’t working, check out our guide for help with fixing Software Center not working in Ubuntu.
Is this article useful?