How to use apt

The package Manager Apt or Advanced Package Tool is used in many distributions based on Debian or Ubuntu, and those distributions are now very much. This package Manager provides all necessary functions you can install and remove packages, update what was already installed to search for packages, install them from a file or download without installing. In this case all dependencies are resolved automatically.

Apt is not inferior to package management tools, yum used RPM distros, Yes, this is still not supported partial update packages in Zypper, but overall looks very good. In this article we will discuss how to use apt in Linux for solving problems with software.

  • The syntax and options of apt
  • How to use apt
    • 1. Upgrade packages
    • 2. Installing packages
    • 3. Remove packages
  • Insights

The syntax and options of apt

The syntax of the apt is very simple and similar to other Linux command:

$ apt options team parametrically

Options indicate the General behaviour of the utilities, the command – the action which should be carried out and the command parameters are usually passed in the name of the package that should work, for example, to install or remove. Here are the basic options utility:

  • -v, –version – displays the version of the utility;
  • -h, –help – displays help on using the utility;
  • -y, –yes automatically answer Yes to all questions;
  • –assume-no – automatically answer “no” to all questions;
  • -d, –download-only – only download packages and do nothing else;
  • -f, –fix-broken – fix missing dependencies;
  • –no-download – nothing download, use only the packages from the cache;
  • -s, –simulate – simulation mode, no operation, only displays information on a screen;
  • –allow-unauthenticated – allows you to install packages from repositories for which there is no GPG signature;
  • –no-install-recommends – don’t install recommended packages by default are installed;
  • -m, –ignore-missing — ignore packages that exist;
  • -q, –quiet – output minimal information, not to show a progress bar;
  • -V, –verbose-versions – show-full version updated packages;
  • –only-upgrade – do not install new packages, only upgrade;
  • –allow-downgrades – allow to roll back the version of the packages.
  • –reinstall – reinstall the package if it is already installed;

And now let’s go over the apt commands that you can use:

  • install – install the package;
  • remove – delete a package, configuration files that have changed in your system will not be deleted;
  • purge – to remove a package, along with all its configuration files;
  • autoremove – purge unnecessary packages;
  • autoclean – clean the package cache;
  • update – update package lists from repositories.
  • upgrade – upgrade package version to the latest, if not specified will update all packages.
  • full-upgrade – complete upgrade of the system, including the removal of incompatible or more unnecessary packages.
  • list – list installed packages;
  • search – search packages;
  • show – show information about a package;
  • download – the download package to current folder;
  • edit-sources – open with the settings of a repository in a text editor.
  • source – download the source code package into the current folder;
  • build-dep – install dependencies needed to build the chosen package;

Next, consider several examples of using apt, which will be useful for both beginners and more experienced users.

How to use apt

1. Upgrade packages

First, let’s update the list of packages from the apt repositories. Repositories are on remote servers and when that apt looks for the package to install, of course, that it does not apply to all repositories in a row to find out where he is. The system already has a saved cache of information about what packages actually are and where they can be downloaded. To update this cache, use the update command:

sudo apt update

While loading the URL of the repository is indicated by their prefixes, that’s what they mean:

  • Hit (Noun) – the list has not changed since the previous load;
  • Ign (IGN) – the repository is ignored, or it is too new, or there is a minor bug during loading;
  • The Get (Gender) – a new version is available and it will be uploaded.

When the cache has updated you can see for which packages updates are available:

sudo apt list --upgradable

Similarly, you can see the installed packages apt:

sudo apt list --installed

Or all available:

sudo apt list --all-versions

Then you can update all packages on the system:

sudo apt full-upgrade

2. Installing packages

To install apt, use the command install, for example, to install the software Gimp, use the install command:

sudo apt install gimp

If the package was installed incorrectly and you need to reinstall, you can use the –reinstall option:

sudo apt install --reinstall gimp

As you can see, the options you can specify not only the team, but after it, similarly, you can install multiple packages at once, for example:

sudo apt install gimp inkskape -y

Not to confirm the installation manually, use the option -y. Let’s say you installed the package with dpkg and now want to install the dependencies, run the install command without any parameters with the option -f or –fix-broken:

sudo apt install --fix-broken

You can download a deb package in the current directory without installing it:

apt download gimp

To download the necessary packages as a standard user, otherwise they will not be available to work with them. If you need to install a package from a file, just pass the file path to the install command:

sudo apt install gimp_2.8.22-1_amd64.deb

To install a specific version of a package, simply select the desired version after the package name using the = sign, for example:

sudo apt install linux-headers-generic=4.15.0.20.23

To find the available versions you can use the command policy. It displays information about what version you have installed, and which versions are available:

sudo apt policy linux-headers-generic

If you don’t know exactly how is called the package, you can search packages apt command to search:

sudo apt search gimp

3. Remove packages

To remove a package use the remove command:

sudo apt remove gimp

However, if you have modified any configuration files from the package, with this method they will remain in the system, to remove completely use the purge command:

sudo apt purge gimp

To remove the extra packages that you don’t need to run the command autoremove:

sudo apt autoremove

And to clean the package cache – autoclean:

sudo apt autoclean

Insights

In this article, we reviewed the use case and the basic commands Ubuntu apt, as you can see, the command of this utility is enough for all occasions. But as you can see, it’s very simple if you look. I didn’t tell of only one command, try typing in the terminal apt moo, see what happens. This is a small Easter eggs from the developers.

Source: losst.ru

(Visited 13 times, 1 visits today)