apt Command In Linux
apt-get is a command-line utility that helps in handling packages in Linux. Its primary purpose is to get the information and packages from the authenticated sources for installation, upgrade, and removal of containers along with their dependencies. Here APT stands for the Advanced Packaging Tool.
apt Command Syntax:
apt-get [options] command
or
apt-get [options] install|remove pkg1 [pkg2 ...]
or
apt-get [options] source pkg1 [pkg2 ...]
Most Used Commands: You need to specify one of the commands below, if -h option is not used.
- update : This command is used to synchronize the package index files from their sources again. You need to conduct an update before you upgrade or dist-upgrade.
- apt-get update
- upgrade : This command is used to install the newest versions of the packages currently installed on the user’s system from the sources mentioned in /etc/apt/sources.list. The installed packages which have fresh packages available are fetched and installed. You need to do an update before the upgrade, so that apt-get knows that new versions of packages are available.
- dselect-upgrade : This is used alongwith the Debian packaging tool, dselect. It follows the changes made by dselect to the Status field of available packages, and executes any actions necessary to realize that state.
apt-get dselect-upgrade
- dist-upgrade : This command accomplishes the purpose of upgrade, and also manages altering dependencies with new versions of packages. If necessary, the apt-get command will try to upgrade vital packages at the expense of less important ones. It may also uninstall some packages in this process.
apt-get dist-upgrade
- install : This command is used to install or upgrade packages. It is followed by one or more package names the user intends to install. All the dependencies of the chosen packages will also be downloaded and installed. The user can also select the desired version by following the package name with a ‘equals’ and the desired version number. Also, the user can select a certain distribution by following the package name with a forward slash and the version or the archive name (e.g. ‘stable’, ‘testing’ or ‘unstable’). Both of these version selection approaches have the potential to degrade the packages, thus must be handled with care.
apt-get install [...PACKAGES]
- uninstall : This is similar to install, with the distinction being that it removes the packages instead of installing. It does not remove any configuration files made by the package.
apt-get uninstall [...PACKAGES]
- purge : This command removes the packages, and also removes any configuration files connected to the packages.
apt-get cleanse [...PACKAGES]
- check : This command is used to update the package cache and checks for broken dependencies.
apt-get check
- download : This command is used to download the provided binary package in the current directory.
apt-get download [...PACKAGES]
- clean : This command is used to empty out the local repository of fetched package files. It removes everything but not the lock file from /var/cache/apt/archives/partial/ and /var/cache/apt/archives/ .
apt-get clean
- autoremove : Sometimes the packages which are automatically installed to satisfy the dependencies of other packages, are no longer needed then autoremove command is used to remove this kind of packages.
apt-get autoremove \sOptions:
- –no-install-recommends : By passing this option, the user tells apt-get know not to consider suggested packages as a dependency to install.
apt-get —no-install-recommends [...COMMAND]
- –install-suggests : By passing this option, the user tells apt-get know that it should consider suggested packages as dependencies to install.
apt-get —install-suggests [...COMMAND]
- -d or –download-only : By passing this option, the user specifies that apt-get should simply fetch the packages, and not unpack or install them.
apt-get -d [...COMMAND]
- -f or –fix-broken : By passing this option, the user specifies that apt-get should attempt to fix the system with broken dependencies in place.
apt-get -f [...COMMAND]
- -m or –ignore-missing or –fix-missing : By passing this option, the user signals that apt-get should ignore the missing packages ( packages that cannot be retrieved or fail the integrity check ) and manage the outcome.
apt-get -m [...COMMAND]
- –no-download : By passing this option, the user prevents downloading for apt-get. It signifies that it should only use the .debs it has previously downloaded.
apt-get [...COMMAND]
- -q or –quiet : When this option is given, apt-get produces output which is suitable for logging.
apt-get [...COMMAND]
- -s or –simulate or –just-print or –dry-run or –recon or –no-act : This option signals that no action should be done, and execute a simulation of events that would occur based on the current system, but do not change the system.
apt-get -s [...COMMAND]
- -y or –yes or –assume-yes : During the execution of apt-get command, it may sometimes prompt the user for a yes/no. With this option, it is defined that it should presume ‘yes’ for all prompts, and should run without any intervention.
apt-get -y [...COMMAND] .COMMAND]
- –assume-no : With this option, apt-get assumes ‘no’ for all prompts.
apt-get —assume-no [...COMMAND]
- –no-show-upgraded : With this option, apt-get will not show the list of all packages that are to be upgraded.
apt-get —no-show-upgraded [...COMMAND]
- -V or –verbose-versions : With this option, apt-get will show full versions for updated and installed packages.
apt-get -V [...COMMAND] .COMMAND]
- –show-progress : With this option, apt-get will show user-friendly progress in the terminal window when the packages are being installed, deleted or upgraded.
apt-get —show-progress [...COMMAND]
- -b or –compile or –build : With this option, apt-get will compile/build the source packages it gets.
apt-get -b [...COMMAND]
- –no-upgrade : With this option, apt-get prevents the packages from being upgraded if they are already installed.
apt-get —no-upgrade [...COMMAND]
- –only-upgrade : With this option, apt-get will only upgrade the packages which are already installed, and not install new packages.
apt-get —only-upgrade [...COMMAND]
- –reinstall : With this option, apt-get reinstalls the packages that are already installed, at their newest versions.
apt-get —reinstall [...COMMAND] .COMMAND]
- –auto-remove or –autoremove : When using apt-get with install or remove command, this option operates like performing the autoremove command.
apt-get install/remove —autoremove [...PACKAGES] .PACKAGES]
- -h or –help : With this option, apt-get provides a short usage summary.
apt-get -h
- -v or –version : With this option, apt-get displays it’s current version number.
apt-get [...COMMAND] .COMMAND]
Note: apt-get command will return 0 for successful executions, and decimal 100 in case of problems.