In this guide, we will discuss the apt Linux command with different examples on the Linux system.
apt Linux Commands with Examples
The basic syntax of the apt command is as follows:
apt command allows you to run the command with different arguments:
Options | Description |
-d | Only download a specific package |
-y | Answer yes to prompts |
-f | Fix broken dependencies |
-h | Help guide |
–assume-no | Answer no to all prompts |
-s | Displays output only without altering the system |
Example 1: Install a Package Using apt Command
To install a package from Linux repository, you must follow the below-given apt syntax by replacing the package name according to your choice.
Here I am using the apt install command for installing the PlayOnLinux on Linux:
Example 2: Update System Using apt Command
The apt update command updates all the packages present in the repository. Always execute this command before installing a new package on your system to get the latest version of it:
Example 3: Upgrade Packages Using apt Command
When you run the upgrade command without specifying the package name it will upgrade all the packages of the system.
If you specify the name of the package with the upgrade command it will upgrade only that package. The following command will upgrade the installed package of Bluetooth:
Example 4: Search Package Using the apt Command
The following command will display the name and descriptions of the available packages for a specified search term. The basic syntax of the search option with the apt is:
Search the Bluetooth in the list of all available packages and display matches via the following command:
Example 5: Clean System Using apt Command
Whenever we run the apt command, the cache is stored in the specific folder of your system. It takes up space in your system. The cleaning using the apt command will free up the disk and remove packages from the folder|:
Example 6: Get the List of the Packages via apt Command
To get the list of all the upgradeable packages of your system, execute the following command:
To get the list of all the packages in the repository, use the following command:
Example 7: Remove a Package Using apt Command
The apt with the remove command will remove the binaries of packages. The following remove command of apt will remove the package with all its dependencies from your Linux system:
The removing packages will remove the data from the system but leave the user configuration files behind. Use purge to get rid of all the leftover files from your system:
The following purge command will remove everything related to PlayOnLinux package including the configuration files:
Bottom Line
Knowing how to manage packages is an important part of the Linux system. In Linux, we use the apt package manager for installing, removing, and updating the packages from the Linux repository. The apt command can be used in different ways and the above guide will show you some examples of using the apt command in Linux for performing a specific task on the system.