5 Must Know APT Commands for a Debian User
Tags: linux, debian, ubuntu, apt
Published: 2020-07-16 08:32:34

# What is apt?
APT (Advanced Package Tool) is the command-line tool to interact with the packaging system. A packaging system is a way to provide programs and applications for installation.

# Must Know APT Commands
1. `apt update`
2. `apt upgrade`
3. `apt install`
4. `apt remove`
5. `apt autoremove`

# `apt update`
### Update package database with `apt`
apt actually works on a database of available packages. If the database is not updated, the system won’t know if there are any newer packages available. That is why updating the repository should is the first thing we do in any Linux system's fresh install.
Updating the package database requires superuser privileges in Ubuntu, Ubuntu Mate, and other Debian flavors, so you’ll need to use `sudo`.
```javascript
sudo apt update
```
![apt update](https://dev-to-uploads.s3.amazonaws.com/i/5p9qgh13vnpeqwaqksbp.png)
When you run this command, you’ll see the package information is retrieved from various servers.
![apt update output](https://dev-to-uploads.s3.amazonaws.com/i/ecfab4fay70bd3wai434.png)

# `apt upgrade`
### Upgrade installed packages with `apt`
Once you have updated the package database, you can now upgrade the installed packages. The most convenient way is to upgrade all the packages that have available updates. You can simply use the command below:
```javascript
sudo apt upgrade
```
![apt upgrade](https://dev-to-uploads.s3.amazonaws.com/i/zzly3naf0bl0gon6kjqk.png)
This will show you how many and which all packages are going to be upgraded.
![apt upgrade output](https://dev-to-uploads.s3.amazonaws.com/i/mvdegtia4njckhrfuklv.png)

This is the faster way to update and upgrade your packages.
```javascript
sudo apt update && sudo apt upgrade -y
```
![sudo apt update && sudo apt upgrade -y](https://dev-to-uploads.s3.amazonaws.com/i/z9wc22wb6av1l3yfubgv.png)

Or set an alias, `uu` for the above command. Here's how you can set up an alias in Linux.
![Open .bashrc](https://dev-to-uploads.s3.amazonaws.com/i/elb8zaqs98h8tkg6tg72.png)
Add
```javascript
alias uu='sudo apt update && sudo apt upgrade -y'
```
![Update .bashrc](https://dev-to-uploads.s3.amazonaws.com/i/6xrqjza11riqvki7uj6c.png)

# `apt install`
### Install new packages with `apt`
If you already know the name of the package, you can install it using the command below:
```javascript
sudo apt install <package_name>
```
Just replace the <package_name> with the desired package. Suppose you want to install git, you can simply use the command below:
```javascript
sudo apt install git
```
![sudo apt install git](https://dev-to-uploads.s3.amazonaws.com/i/brjbcsym76m00nmzunaa.png)
You can install several packages at a time by providing the package names all together:
```javascript
sudo apt install <package_1> <package_2> <package_3>
```

# `apt remove`
### Remove installed packages with `apt`
Removing packages is as easy as installing them. Just use the command below:
```javascript
sudo apt remove <package_name>
```
![sudo apt remove vlc](https://dev-to-uploads.s3.amazonaws.com/i/jfy7qbdg1f72vod1nwxg.png)

Another way of uninstalling packages is to use `purge`. The command is used in the following manner:
```javascript
sudo apt purge <package_name>
```
![sudo apt purge vlc](https://dev-to-uploads.s3.amazonaws.com/i/z1f67aa66y7wla7n1t7q.png)

* `apt remove` just removes the binaries of a package. It leaves residue configuration files.
* `apt purge` removes everything related to a package including the configuration files.

# `apt autoremove`
### Clean your system with `apt`
This command removes libraries and packages that were installed automatically to satisfy the dependencies of an installed package. These are often the previous linux kernels which got updated during the linux update.
```javascript
sudo apt autoremove
```
![sudo apt autoremove](https://dev-to-uploads.s3.amazonaws.com/i/i6qqdn0w5jgxo7tgy7pe.png)

or try `sudo apt --purge autoremove`

Let me know in the comments, what are your best APT commands?