apt-get utility - productive free console program, used and working with the APT (Advanced Packaging Tool) library to install new software packages, remove existing ones, update installed ones, and also update the entire operating system.
The apt-cache console utility is used to search the cache for APT software packages. talking in simple words, this tool, is used to search for packages, gather information about packages, and find packages available for installation on operating systems based on Debian or Ubuntu.
How can I get a list of all available packages?
To see all available packages, run the following command:
apt-cache pkgnames
How can I find the package name and description.
To find the package name and description before installing, use the "search" flag. Using "search" with apt-cache will display a list of matching packages with brief description. For example, if you want to find the description of the vsftpd package: to do this, the command would be:
apt-cache search vsftpd
To find and list all packages whose name starts with vsftpd , you can use the following command:
apt-cache pkgnames vsftpd
How can I view package information?
For example, if you want to see information about a package, with a short description showing the version number, checksums, size, size after installation, categories, and so on, you can use the "show" subcommand, as shown below:
apt-cache show netcat
How can I check the dependencies of a package?
To check the dependencies of a particular package, you can use the showpkg subcommand to see if those dependencies are installed or not. For example, use the showpkg command along with the package name.
apt-cache showpkg vsftpd
How can I view cache statistics?
The stats subcommand will display full statistics about the cache, such as the total number of packages found in the cache. Use this command:
apt-cache stats
How to update the list of packages in the system?
The update command is used to synchronize and update package index files. Synchronization occurs with the sources specified in the file /etc/apt/sources.list. This command can be used, for example, to keep track of important package updates.
Sudo apt-get update
How to update packages in the system?
The upgrade command is used to upgrade everything installed on this moment software on your system. Sometimes it may happen that an update cannot be installed due to some other package that requires an older version.
sudo apt-get upgrade
But if you want to upgrade regardless of package requirements, use the dist-upgrade subcommand:
sudo apt-get dist-upgrade
How can I install or update any specific package?
The install subcommand is used to install or upgrade a package.
sudo apt-get install netcat
How can I install multiple packages at once?
You can enter the names of several packages to install them at the same time. For example, to install the nethogs and goaccess packages, you can run the following command:
sudo apt-get install nethogs goaccess
How to install multiple packages by "mask" name
With regular expressions, you can add multiple packages with special characters. For example, you can use an asterisk to install all packages that contain the string "name" in their name:
sudo apt-get install *name*
How to install packages without updating.
Using the --no-upgrade flag will prevent packages that are already installed from being upgraded.
sudo apt-get install packageName --no-upgrade
How to only update certain packages?
The --only-upgrade flag will not install new packages, it will only upgrade existing ones.
sudo apt-get install packagename --only-upgrade
How can I install specific version package?
Let's imagine that you need to install a specific version of a package, just use an equal sign along with the package name and attribute the desired version.
sudo apt-get install vsftpd=2.3.5-3ubuntu1
How to remove packages without deleting settings?
To delete software packages without removing their configuration files (for later use), use the remove command as shown.
sudo apt-get remove vsftpd
How to completely remove packages?
To remove a package along with its configuration files, use the purge subcommand as shown below.
sudo apt-get purge vsftpd
Or you can combine both commands, like this:
sudo apt-get remove --purge vsftpd
How can I clear disk space?
The clean command is used to free up disk space by removing the resulting package .deb files in your local repository.
sudo apt-get clean
How to download the source code of the package?
To only download the source code of a package, you can use the --download-only source option with the package name, like so:
sudo apt-get --download-only source vsftpd
How can I download and unpack a package?
To download and unpack the source code of a package into a special directory, run the following command:
sudo apt-get source vsftpd
How can I download, unpack and compile the source code of a package?
You can also download, unpack and compile the package source using the '--compile' option, as shown below:
sudo apt-get --compile source goaccess
How to download a package without installation
Using the "download" option, you can download any package without installing it. For example, the following command will only download the nethogs package to the current working directory.
sudo apt-get download nethogs
How can I view the changelog of a package?
The changelog flag downloads the package's changelog and displays the version of the package, if installed.
sudo apt-get changelog vsftpd
How can broken dependencies be fixed?
The "check" command is a diagnostic tool, it is used to update the package cache and check for broken dependencies.
Sudo apt-get check
How can I find and build dependencies?
The build-dep command looks for and installs the built dependencies of the required package. If the package is not in the local repository, you will get an error.
sudo apt-get build-dep netcat
How can I automatically clear the Apt-Get cache?
The autoclean command removes all .deb files from /var/cache/apt/archives to free up space on your hard drive.
sudo apt-get autoclean
How can I automatically remove unnecessary packages?
The autoremove subcommand is used to automatic removal packages that were installed as dependencies of others but are no longer needed. For example, the following command will remove an installed package along with its dependencies.
sudo apt-get autoremove vsftpd
Information courtesy of the site. Thank you.
APT (short for Advanced Packaging Tool) is a set of utilities for installing, uninstalling, upgrading, finding packages on Linux, and managing repositories. APT is also called a package manager.
APT uses package repositories. The list of repositories for APT is stored in a file /etc/apt/sources.list, as well as in the directory /etc/apt/sources.list.d/.
APT is used in distributions based on Dedian and Ubuntu.
There are various utilities for managing APT, but the most popular ones are the apt-get and apt command-line utilities.
In this article, we will look at how to use the apt command, and also learn how apt differs from apt-get.
To briefly answer a very popular question, what is the difference between apt and apt-get commands?
apt is a utility that appeared as an alternative to apt-get. It performs almost all the same functions as apt-get, but it is easier and clearer to work with.
For example, all apt commands have a simple syntax: apt commandname. And apt-get has additional commands, For example, apt-cache. Thus, when using apt, the user does not need to remember additional sets of commands.
In addition to simplifying work with commands, apt displays information more clearly, seemingly trifles, but it is more convenient to work with. For example, apt can show a progress bar, and when executed apt update you can see how many packages can be upgraded.
It is worth noting that the apt-get utility is more functional than apt. But for the average user, apt will be more than enough.
The syntax for the apt command is as follows:
sudo apt
APT has a list of repositories from which packages are installed. The list is stored in text file /etc/apt/sources.list, as well as in the directory /etc/apt/sources.list.d/. When executing the command apt update, APT iterates through the list of repositories and from each repository in the list gets information about the packages in the repository. All this information is stored in the system.
If a new version of a package is released, APT will not know about it until the command is executed apt update. Therefore, if you install this package (without first running apt update), then the version of the package that is stored in the system at the moment will be installed.
No, before installing each package apt update of course it shouldn't be done. It is enough to run apt update periodically. If you have more than one package to install, you can first run apt update and then install the packages.
To update the packages installed on the system, use the command:
sudo apt upgrade
This command only updates packages to new versions, never removes or installs other packages.
There is another command to update packages:
Sudo apt full-upgrade
This command updates packages, and removes or installs new packages as needed to resolve dependencies.
To install the package use the command:
sudo apt install
To install multiple packages, their names are separated by a space:
sudo apt install
To install a specific package version, you need to specify the required version after the package name, through the equal sign:
sudo apt install=
To remove an installed package, use the command:
Sudo apt remove
apt-purge works similarly apt-remove, but also removes configuration files, related to the package. This means that if you installed some program, configured it, and then removed it with the command apt-remove, then the configuration file of this program will remain in the system. If you now install this program again, you will be able to use the previous configuration file, as it has not been removed.
apt-purge does not delete configuration files stored in your home directory.
If you removed the package with the command apt-remove, then you can do apt-purge for a given, already removed package, in order to “delete” its configuration files.
When you install a package, it often installs additional packages, which are its dependencies. If you now remove this package, then the dependencies will remain in the system. apt autoremove removes those dependencies, but only those that other installed packages don't need.
The apt list command is used to list packages based on some criteria.
List the packages installed on the system:
Apt list --installed
List packages that need to be updated (that have a newer version):
apt list --upgradable
List all packages available for your system:
Apt list --all-versions
This command searches for the specified words in the package name and in the package description. Regular expressions are supported.
You can only search by package names using the --names-only option:
Apt search --names-only
Searching for a package using regular expressions:
apt search --names-only "^python"
Displays information about the package. The version, size, description, dependencies, and other information is displayed.
Opens a file /etc/apt/sources.list V text editor for editing, after saving the changes and closing the editor, checks the file for errors. If there are errors, displays a suggestion for re-editing the file in order to correct the errors.
Team apt | Command analogue apt-get | Description |
---|---|---|
apt install | apt-get install | Install package |
apt-remove | apt-get remove | Delete a package |
apt-purge | apt-get-purge | Remove package and config files |
apt autoremove | apt-get autoremove | Remove unused packages |
apt update | apt-get update | Update package list |
apt upgrade | apt-get upgrade | Update packages |
apt full-upgrade | apt-get dist-upgrade | Update packages (remove and install new ones if required) |
apt list | Approximate analogue: dpkg-query --list | Package List |
apt search | apt-cache search | Package Search |
apt show | apt cache show | Package Information |
Sometimes there are situations when you need to find out which packages are installed on the system. This may be necessary if you want to backup installed packages, check their integrity, transfer all packages to another system and for many other tasks. On Debian, several methods can be used for this.
In today's article, we'll look at how to list installed Debian packages using the terminal, the curses interface, and the GUI. Such lists can be used not only for Reserve copy, but also to just iterate over and remove unnecessary programs, thereby clearing the system of debris.
The very first way to see installed Debian packages, this is the dpkg utility. It can be used not only in Debian, but in all distributions based on it:
dpkg --get-selections | grep -v deinstall
dpkg --get-selections | grep -v deinstall > mylist.txt
You can also remove all unnecessary information and keep only the package names:
dpkg -l | grep ^ii | awk "(print $2)" > mylist.txt
The next way to accomplish this task is to use the dpkg-query utility. It is similar to the previous version, but a little simpler. This command will list all installed packages along with information about them:
Here, too, you can only select package names with the -f option:
dpkg-query -f "$(binary:Package)\n" -W
The third method is the apt utility we are used to using to install applications, it has a list command:
apt list --installed
apt list --installed | grep python
We covered apt in more detail in the article. Another interesting feature of apt is to see which packages have been manually installed. To do this, type:
apt-mark showmanual
And another option using apt:
apt-cache pkgnames
The aptitude package management tool also allows you to list installed packages:
aptitude search "~i!~M"
Also, aptitude can run in curses mode, which is very convenient:
The last way to see the list of installed packages is in the /var/lib/apt/extended_states file. This is a database that contains installed programs debian in this format:
Package: package_name
Architecture: architecture
Auto-Installed: 0_or_1
cat /var/lib/apt/extended_states
Many users create a list of packages not just to look at, but for future recovery. If you made a list using dpkg, then it can be very easily restored to the system using a similar command:
sudo dpkg --clear-selections
$ sudo dpkg --set-selections< mylist.txt
Everything is very simple. To install packages after adding them to the list, use the command:
sudo apt dselect-upgrade
If you just have a list of package names, then you need to restore it a little differently. Just pass all these names to the apt command to install:
xargs< mylist.txt apt install -y
In this article, we looked at how to list installed Debian packages. This can be very useful and is quite easy to do. I hope this information was helpful to you.
Ubuntu 16.04 is out now and brings a lot of very interesting changes to its users such as support for file system BSD - ZFS support new technology package installations - snap and many others. But one thing you probably haven't heard of yet, because little things like that get lost a lot, is apt.
What is apt? This is a new package manager for Ubuntu ready to take on the job of apt-get. It was designed to be friendlier, more efficient and more secure. So what did Canonical have in mind when they introduced the new package manager? Are there really differences between apt vs apt-get? This is what we will find out in today's article.
Apt was implemented to make it easier to work with the package manager and to combine multiple commands into one. The functionality of apt-get has been redesigned to work correctly in apt.
Although these new commands are designed to work similarly to apt-get, they are based on new code to interact with packages.
The main reason for introducing apt is the very essence of Ubuntu - simplicity and ease of use. Whether people want to admit it or not, apt-get is an obsolete tool and its practicality is highly questionable. Apt has been designed from the ground up to be even more efficient and designed to be enjoyable for new users.
apt or apt-get. So what is the difference between these two solutions? For starters, you no longer need to use apt-get autoremove to clear the package cache. Also you don't need to type apt-cache search to find packages.
These commands have been replaced by apt search and apt remove. The main difference of apt is that it replaces all the commands apt-get, apt-cache, etc. All the functionality is combined in one utility.
Although this is not the only difference from apt-get. Software installation progress bars have been improved here. It also supports some additions that make the utility smarter than the previous one. For example, when updating software sources with apt-get, there is no easy way see the list of packages available for updating. You can just sudo apt-get update and then:
sudo apt list-upgradable
Of course, little things, but nice. New, modern output colors have also been added, and overall package installation is faster. Canonical is in no hurry to move away from apt-get, but they will make it a positive change.
Here is a list of commands supported by apt, taken directly from the --help output. These commands are very similar to the implementation of apt-get and apt-cache, but are more organized and grouped.
Basic commands:
For more information, run man apt in a terminal. The information stored there will help you thoroughly study the new utility.
Apt-get is a tried and true part of a software manager. This tool has been around for a long time and comes by default in many releases of Ubuntu and Debian. We always used it when it was necessary to update something, update software or even just clean the system of garbage.
However, it is getting old. The package manager no longer meets all the needs of users, and therefore it is slowly being replaced by apt. Ubuntu developers understand that they need to update their package manager to make it simpler, more elegant, and more secure. But while both utilities exist in the system, it is up to you to choose whether to use apt or apt-get. Will you be using the new package manager? Or are you already using it?