The Different Apt-Get Commands

Sam Richard
featurepreneur
Published in
3 min readOct 19, 2021

If you are an Ubuntu newbie, then this article will help you a lot in getting to know the different Apt-Get Commands on Ubuntu

Apt-Get

apt-get is one of the most important Ubuntu commands every beginner must know. It is used to install, update, upgrade and remove any package. apt-get basically works on a database of available packages. Here is the list of different apt-get commands:

1. sudo apt-get update

apt-get update with superuser privileges is the first command you need to run in any Linux system after a fresh install. This command updates the database and let your system know if there are newer packages available or not.

2. sudo apt-get upgrade

After updating the package database, the next step is to upgrade the installed packages. For upgrading all the packages with available updates you can use this command.

And if you like to upgrade a particular package, you should tweak the above command a little:

sudo apt-get upgrade <package-name>

Replace the <package-name> with your desired package.

3. sudo apt-get install

If you know the name of the package, then you can easily install a program using this command:

sudo apt-get install <package-name>

Replace the <package-name> with your desired package.

4. sudo apt-get remove

When it comes to removing the installed program apt-get remove command suits your need. You only have to know the exact package name of the software you want to uninstall.

If you don’t know the package name, use below ubuntu basic command to list all the packages installed on your system and then copy the package name from the list:

dpkg --list

Now run the apt-get remove command as sudo in order to remove the software:

sudo apt-get remove <package-name>

Replace the <package-name> with the one you copied from the dpkg list.

apt-get remove command only removes the software from your system but not the configuration or data files of the package. These files help in keeping the same settings when you want to reinstall the same software.

5. sudo apt-get purge

apt-get purge command is used when you want to remove a software completely from your system with its configuration or data files so that no longer personalized settings will be available during reinstallation.

Run the apt-get purge command as sudo in order to remove the software completely:

sudo apt-get purge <package-name>

Replace the <package-name> with the application that you want to remove or copied from the dpkg list.

6. sudo apt-get autoremove

apt-get autoremove command is used to remove any unnecessary packages. Unnecessary means, whenever you install an application, the system will also install the software that this application depends on. It is common in Ubuntu that applications share the same libraries. When you remove the application the dependency will stay on your system.

So run apt-get autoremove as sudo after uninstalling a package to remove unwanted software dependencies.

So apt-get autoremove will remove those dependencies that were installed with applications and that are no longer used by anything else on the system.

--

--