How to use apt get command in Ubuntu Linux. Here are some apt-get command in Linux with examples including install apt-get in ubuntu command line.
This posts explains apt-get install command in Linux and apt-get update command in Linux including apt-get install options and update options.
apt-get install options
Before we begin, we must understand the apt-get package.
apt-get – APT package handling utility
apt-get is the command-line tool for handling packages, and may be considered the user’s “back-end” to other tools using the APT library. Several “front-end” interfaces exist, such as synaptic and aptitude.
apt-get [options] [-o config=string] [-c=cfgfile] command [pkg]
APT (for Advanced Package Tool) is a set of tools for managing Debian packages, and therefore the applications installed on your Debian system. APT makes it possible to install applications, remove applications and update or upgrade applications up to the latest versions.
APT resolves dependency problems and retrieves requested packages from designated package repositories. APT delegates the actual installation and removal of packages to dpkg.
update
apt-get update
Used to re-synchronize the package index files from their sources. The indexes of available packages are fetched from the location(s) specified in /etc/apt/sources.list. An update should always be performed before an upgrade or dist-upgrade.
upgrade
apt-get upgrade
Used to install the newest versions of all packages currently installed on the system from the sources enumerated in /etc/apt/sources.list. Packages currently installed with new versions available are retrieved and upgraded; under no circumstances are currently installed packages removed, nor are packages that are not already installed retrieved and installed.
dist-upgrade
apt-get dist-upgrade
In addition to performing the function of upgrade, this option also intelligently handles changing dependencies with new versions of packages; apt-get has a “smart” conflict resolution system, and it will attempt to upgrade the most important packages at the expense of less important ones, if necessary.
clean
apt-get clean
Clears out the local repository of retrieved package files. It removes everything but the lock file from /var/cache/apt/archives/ and /var/cache/apt/archives/partial/. Like clean, autoclean clears out the local repository of retrieved package files. The difference is that it only removes package files that can no longer be downloaded, and are largely useless.
autoclean
apt-get autoclean
This command removes .deb files for packages that are no longer installed on your system. Depending on your installation habits, removing these files from /var/cache/apt/archives may regain a significant amount of diskspace.
install
apt-get install
This option is followed by one or more packages desired for installation. Each package is a package name. All packages required by the package(s) specified for installation will also be retrieved and installed. The /etc/apt/sources.list file is used to locate the repositories for the desired packages. A specific version of a package can be selected for installation by following the package name with an equals (=) and the version of the package to select. This will cause that version to be located and selected for install.
-f install
apt-get -f install
This command does the same thing as Edit->Fix Broken Packages in Synaptic. Do this if you get complaints about packages with “unmet dependencies”.
remove
apt-get remove
Remove is identical to install except that packages are removed instead of installed. Note that removing a package leaves its configuration files on the system. If a plus sign is appended to the package name (with no intervening space), the identified package will be installed instead of removed.
purge
apt-get purge
The purge is identical to remove except that packages are removed and purged (any configuration files are deleted too). Please note that the command apt-get remove just removes a package and not the configuration files. Whereas the command apt-get purge removes the package and its configuration files.
check
apt-get check
This command is a diagnostic tool. It does an update of the package lists and checks for broken dependencies.