‘apt‘ or the Advanced Packaging Tool is one of the most powerful system tool available in Ubuntu. If you are a GUI lover or a classic terminal junkie, you have to deal with it no matter what. Almost all Ubuntu users have used it knowingly or unknowingly. So, now lets take a walk down the basics of this tool, how it works and how to master it.

Installing Packages

sudo apt-get install <package_name>

It downloads and installs the given package if present in the package database. This command will automatically verify package authenticity for gpg keys it knows about.

sudo apt-get -d install <package_name>

Downloads the package file only, places it in /var/cache/apt/archives. No install is done.

sudo apt-get -f install <package_name>

Does a check for broken packages & tries to fix any “unmet dependency” messages.

NOTE : ‘<package_name>’ should be replaced by the actual package name that needs to be installed. If you put <package_name>* then all the packages with the same first name will be installed . This is really helpful if you want to install all the packages starting with the same initial name.

Updates

sudo apt-get update

Consults /etc/apt/sources.list and updates the database of available packages. Be sure to run this command whenever sources.list is changed.

sudo apt-get upgrade

Check updates for all installed packages and then prompt to download and install them.

sudo apt-get dist-upgrade

Updates the entire system to a new release, even if it means removing packages.

Note: This is not the preferred method for updating a system.

System Cleaning

sudo apt-get autoclean

Should be run once a week to delete partially downloaded packages, or packages no longer installed.