A Beginner’s Guide to Installing Software in Ubuntu with APT
— November 25, 2016Ubuntu is widely regarded as a beginner friendly version of Linux, but that doesn’t mean that Ubuntu is only used by beginners. Advanced users can also make use of some of the great features Ubuntu has to offer.
Ubuntu is widely regarded as a beginner friendly version of Linux, but that doesn’t mean that Ubuntu is only used by beginners. Advanced users can also make use of some of the great features Ubuntu has to offer.
You can install, update and clean packages with APT, as well as find new packages to install. The packages you can find are dependent on which PPAs you have enabled on your machine.
Managing Packages With apt-get
You can use the apt-get command to install, update and clean the packages that are available to your system. APT uses a local database of packages, which tells the system if any updates are available.
Keeping this database up to date is extremely important, as using out of date packages can lead to security issues on your machine. To update the APT database, you can use the following command:
sudo apt-get update
There are three types of update to the APT database:
- Hit — This means there is no change to the package since the last check.
- Ign — This means the package has been ignored, either because the package is so recent that there’s no need to check it, or because there is a small error. Either way, this is nothing to worry about.
- Get — This means there is a package update available and APT will now download the details for this update, but not the update itself.
Once you have updated your database, you can use APT to then update the packages on your system. This will update any applications, and the Ubuntu core system to the latest versions available.
sudo apt-get upgrade
Upgrade a Specific Package
Sometimes you may wish to upgrade a specific package, rather than the whole system. APT allows you to do this with the following command:
sudo apt-get upgrade [package-name]
This will then update that specific package. This can be useful if there is a known bug with a certain package, yet you want to still upgrade others.
Dist-Upgrade
APT also has a slightly more intelligent way of upgrading your packages, this tool is known as dist-upgrade. It is used in the same way as the standard upgrade command:
sudo apt-get dist-upgrade
In addition to performing the function of upgrade, dist-upgrade also intelligently handles changing dependencies with new versions of packages; apt-get has a “smart” conflict resolution system, and it will attempt to upgrade the most important packages at the expense of less important ones if necessary. So the dist-upgrade command may remove some packages.
Because dist-upgrade can remove packages as well as update them, it is generally recommended that this command isn’t used unless absolutely necessary, or when doing an update to the latest version of Ubuntu.
Combining Commands
It’s very important to run an update before an upgrade when using APT, but some people may find running multiple commands frustrating. However, you can combine commands in Ubuntu so that one command can run two functions.
To carry out an update followed by an upgrade, you can run this command:
sudo apt-get update -y && sudo apt-get upgrade -y
This command is basically telling APT to run an update and say yes to any prompts, then run an upgrade and again, say yes to any prompts. This will completely automate the update and upgrade process.
Searching for Packages
APT is also very useful for finding new packages. Although there are better ways of searching for new packages in Ubuntu, the apt-cache command does come in handy when looking for a specific lib or package.
To search for a package using APT you can use the following command:
apt-cache search [search term]
As you can see from the output above, the search feature is fairly verbose and will allow you to search for terms, rather than package names, so you don’t have to know the name of the package you’re searching for.
However, if you want to search for packages that contain your search term within their name, you can use the following command:
apt-cache pkgnames [search term]
Once you know the name of the package you are looking for, you can then use the following command to get more information about that package:
apt-cache showpkg [package name]
Once run, this command will show information such as version numbers and dependencies. This information can be very useful when it comes to installing new packages.
Install/Remove Packages With APT
Like sudo apt-get update, the install command from APT is probably one that you have come across before when installing new applications with Ubuntu and APT.
The command to install a package using APT is:
sudo apt-get install [package name]
Conversely, to remove a package using APT, you simply replace the word “install” with “remove”:
sudo apt-get remove [package name]
More to Learn
This guide merely touches the surface of what you can do with APT. It’s an extremely powerful tool that is at the core of Ubuntu, as well as many other distributions.
If you want to continue to learn about APT, you can have a flick through the APT man pages using the following command:
man apt
Are you a terminal user, or do prefer to stick with the Ubuntu Software Center? Feel free to share your tips in the comments below.