Apt-get. Package management in Ubuntu
APT (Advanced Packaging Tool) is a utility in Debian-like systems that installs, updates packages, and tracks their dependencies. The purpose of creating the program was to automate the package management process, in particular updating and maintaining dependencies, which in the case of direct work with the dpkg manager occurred manually. Direct manipulation of packages is performed using the program apt-get, basic commands for working with which will be discussed below.
General apt-get command structure
apt-get [options] command package1 package2 ... packageNThe options below may be useful when working with apt-get:
Updating the list of packages available for installation
Performed this action using the command:
Apt-get update
Updating the list is especially important if you need to install the most recent and stable version package. When executing this command, the program scans the archives specified in the file /etc/apt/sources.list.
Installing the package
To install a package, use the command:
Apt-get install packagename
As a result, APT will search for the latest version of the specified package and check if it has dependencies. If there are dependencies, a list of them and an installation suggestion will be displayed.
Root@vps:~# apt-get install aee Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 The following NEW packages will be installed: aee libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 0 upgraded, 6 newly installed, 0 to remove and 44 not upgraded. Need to get 181 kB/1297 kB of archives. After this operation, 4366 kB of additional disk space will be used. Do you want to continue?
If there are no dependencies, the installation process will occur automatically without prompting any questions.
Also, when entering the command to install packages, you can specify the names of the packages that need to be removed. To do this, you must add a hyphen at the end of the name of the package to be removed. An example of this installation/removal method is given below:
Root@vps:~# apt-get install aee htop- Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 The following packages will be REMOVED: htop The following NEW packages will be installed: aee libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 0 upgraded, 6 newly installed, 1 to remove and 43 not upgraded. Need to get 1297 kB of archives. After this operation, 4157 kB of additional disk space will be used. Do you want to continue?
As you can see from the example, the aee package is prepared for installation, and the htop package is prepared for removal.
Reinstalling a package
If there is a need to reinstall the package (file damage, newer version appears), it can be done using the following command:
Apt-get --reinstall install packagename
Removing a package
There are two options for removing packages:
- Removing the package except configuration files (if any).
Usually this option may be required if you plan to reinstall this package in the future. This method of removal is performed with the command:
Apt-get remove packagename
It is also worth noting that if the package being removed has dependencies, it will be removed along with them.
- Complete package removal
Unlike the first method, all files that are related to the package being deleted, including configuration files, will be deleted. In this case, the command is used:
Apt-get --purge remove packagename
Packages that are marked for complete removal have a "*" at the end of their names.
- Uninstall and install in one command
In addition, when uninstalling, you can select a list of packages to install. To do this, you must specify “ + ” at the end of the package name. An example of such a command is given below:
Root@vps:~# apt-get --purge remove aee screen+ Reading package lists... Done Building dependency tree Reading state information... Done The following packages will be REMOVED: aee* The following NEW packages will be installed: screen 0 upgraded, 1 newly installed, 1 to remove and 43 not upgraded. Need to get 624 kB of archives. After this operation, 975 kB of additional disk space will be used. Do you want to continue?
Updating packages
Apt-get update
This will allow you to update information about available packages and their versions. After executing this command, you can proceed directly to updating installed packages on the system. This is done with the command:
Apt-get -u upgrade
Specified parameter -u used to get full list packages that will be prepared for the update.
Updating the distribution version
If a new version of your installed OS distribution appears, you can “upgrade” the entire system using the command.
Installing and uninstalling programs is one of the most important things for a computer user. Because we need to somehow get new, necessary programs, and also remove unnecessary ones. But removing packages in Ubuntu has some subtleties. After removal, dependencies may remain, packages installed as recommended, as well as configuration files.
In this article, we will look at how to remove the Ubuntu deb package, and remove it cleanly, so that there are no traces left on the system. We will also talk about completely removing the PPA, since we install many packages that are not in the official repositories from the PPA.
The easiest way to remove an Ubuntu package is to use one of the graphical utilities provided specifically for this purpose, such as Synaptic or Center Ubuntu applications. In fact, this is done in a couple of clicks. First, let's look at the procedure in the Ubuntu Application Center.
You can launch the Application Center from the Unity icon bar:
A list of all installed packages is on the tab Installed Here the applications are sorted into categories:
To remove an Ubuntu package, just left-click on it, and when the available actions appear, click the button Delete:
You will need to enter a password to complete the removal.
The package has been removed, but not quite as we would like. But more on that later.
Next, let's look at the Synaptic package manager. This is no matter how third-party software, but many people use it because of its great functionality and user-friendly interface. If the program is not already installed, you need to install it using the Application Center or by running in the terminal:
sudo apt install synaptic
You can run the program through the terminal by running the command:
Look installed packages you can by selecting the Status tab and then selecting Installed:
You can remove deb ubuntu by simply clicking right click mouse and in the context menu on the required package and selecting mark for deletion or mark for complete removal:
The program will show which other packages will be removed, these are the packages that depend on our package:
Now, to complete the removal, all you have to do is click the button Apply:
Now the program will show which packages will be removed. And the removal process will begin:
Simply deleting and completely deleting differs only in that with complete deletion, configuration files are deleted. But the problem with these tools is that packages installed as dependencies and recommended for the program are not removed and remain on the system. This behavior is observed in both Synaptic and the Ubuntu App Center. Therefore, we move on to describe the most flexible method - removing Ubuntu packages in the terminal.
How to remove an Ubuntu package in the terminal
In new versions of Ubuntu, you can use the new package manager - apt - to manage packages, including removal. The removal command looks like this:
sudo apt remove packagename
The package will be completely removed, including configuration files and dependencies, only recommended programs will remain.
If you want to use apt-get to remove ubuntu deb, then the procedure is slightly different. For normal removal package do:
sudo apt-get remove packagename
To remove a package along with its configuration files, run:
sudo apt-get purge package_name
And in order to also remove dependencies installed with the package, you need to run after one of the previous commands:
sudo apt-get autoremove
Not only explicitly specified dependencies will be removed, but also programs installed as recommended.
Well, we've sorted out the basics, now let's move on to more complex situations. What if you installed a program from a deb file and now you don't know exactly what its package is called in order to remove it?
This is very easy to find out, for example, from an executable file, for example executable file The TimeShift program is located at /usr/bin/timeshift, now we find out its package:
sudo dpkg -S /usr/bin/timeshift
timeshift: /usr/bin/timeshift
As you can see, the package is called timeshift. Now you can remove the Ubuntu program using one of the methods described above.
Very often we install missing software from a PPA, but not all of these packages are needed for a long time, and when updating the system, they can even cause errors. So how do you remove all packages installed from a PPA? For this there is special utility:ppa-purge.
If it is not already installed, install it with the command:
sudo apt install ppa-purge
Now, to remove all packages installed from a specific ppa use:
sudo ppa-purge -i ppa:ppaowner/ppaname
ppa:ppaowner/ppaname - usually all PPAs are written in this format. Protocol: owner/name.
You can find out the list of repositories in the application sources program:
With this command you can remove ubuntu packages installed from ppa in one fell swoop:
find /etc/apt/sources.list.d -type f -name "*.list" -print0 | \
while read -d $"\0" file; do awk -F/ "/deb / && /ppa\.launchpad\.net/ (print "sudo ppa-purge ppa:"$4"/"$5)" "$file"; done
If you installed an application from source code, then it is much more difficult to remove it, because it is not controlled by the package manager, and accordingly the system does not know which files belong to it.
But there is still a way, usually developers use the makefile script file, in addition to the install goal, they implement the uninstall goal, which allows you to perform the opposite action.
Ubuntu 16.04 is already out and provides its users with many very interesting changes, such as support for the BSD file system - ZFS, support for the new package installation technology - snap and many others. But one thing you probably haven't heard of yet, because little things like this often get lost, is apt.
What is apt? This is a new package manager for Ubuntu, ready to take over the work of apt-get. It was designed to be friendlier, more efficient and safer. So what did Canonical have in mind when introducing a new package manager? Is there really a difference between apt vs apt-get? This is what we will find out in today’s article.
Apt was implemented to make working with the package manager easier and to combine several commands into one. The apt-get functionality has been redesigned to work correctly in apt.
Although these new commands are designed to work similarly to apt-get, they rely 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 outdated tool and its practicality is very questionable. Apt was designed from the ground up to be even more powerful, and it's designed to be enjoyable for new users.
Apt vs Apt-get. What are the differences?
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 your package cache. Also you don't need to type apt-cache search to search for packages.
These commands have been replaced by apt search and apt remove. The main difference between apt is that it replaces everything apt-get commands, apt-cache, etc. All functionality is combined in one utility.
Although this is not the only difference from apt-get. The 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 using apt-get there is no simple way see the list of packages available for update. You can simply do 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 abandon apt-get, but they will make it a positive change.
New Apt commands
Here is a list of supported apt commands, taken directly from the output of --help. These commands are very similar to the apt-get and apt-cache implementations, but are more organized and grouped.
Basic commands:
- list- list of packages
- search- search for packages by name
- show- show detailed information about the package
- update- update lists of available packages
- install- install the package
- remove- remove package
- upgrade- install available new versions of packages
- full-upgrade- complete system update
- edit-sources- edit software sources file
You can find more information by running man apt in a terminal. The information stored there will help you thoroughly study the new utility.
conclusions
Apt-get is a tried and true piece of software manager. This tool has been in use for a long time and comes by default in many releases of Ubuntu and Debian. We always used it when we needed to update something, update software, or even just clean out junk from the system.
However, it is becoming outdated. The package manager no longer meets all user needs and is therefore slowly being replaced by apt. Ubuntu developers realize they need to update their package manager to make it simpler, more elegant, and more secure. But for now, both utilities exist in the system, and it’s 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?
Google, it's unclear how I find new programs to install (from the Internet) using apt-get (which is surprisingly powerful and easy from another Linux distribution).
I use Ubuntu Server 8.04 LTS (legacy system used for some odd work) so no GUI.
Anybody have quick advice Here?
I always use package.ubuntu.com
You can also use apt-cache search to apt-cache search on the command line. Or you can use the GUI package manager (Ubuntu Software Center/Synaptic) to search for software.
If you are looking for "nvidia settings".
Apt-cache search nvidia settings
Nvidia-settings - Werkzeug für die Configuration des NVIDIA-Grafiktreibers nvidia-settings-updates - Tool of configuring the NVIDIA graphics driver
You see 2 packages nvidia-settings and nvidia-settings-updates .
To find the associated binary with the nvidia-settings package.
Dpkg -L nvidia-settings | grep bin
/usr/bin /usr/lib/nvidia-settings/bin /usr/lib/nvidia-settings/bin/nvidia-settings
nvidia-settings is the binary name for running the program.
With binaries in particular, there is an application that will automatically launch if you run a command that is not installed. For example,
$ bonnie++ The program "bonnie++" is currently not installed. You can install it by typing: sudo apt-get install bonnie++
In addition, there are search queries: search apt-cache search
I think you mean the name of the binary program included in the package. I use this technique to find it:
just type dpkg -L
Let's see an example:
Anwar@edubuntu-lenovo:~$ dpkg -L gnome-screenshot /. /usr /usr/bin /usr/bin/gnome-screenshot /usr/share /usr/share/GConf /usr/share/GConf/gsettings /usr/share/GConf/gsettings/gnome-screenshot.convert /usr/share /applications /usr/share/applications/gnome-screenshot.desktop /usr/share/man /usr/share/man/man1 /usr/share/man/man1/gnome-screenshot.1.gz /usr/share/gnome -screenshot /usr/share/gnome-screenshot/gnome-screenshot.ui /usr/share/glib-2.0 /usr/share/glib-2.0/schemas /usr/share/glib-2.0/schemas/org.gnome.gnome -screenshot.gschema.xml /usr/share/doc /usr/share/doc/gnome-screenshot /usr/share/doc/gnome-screenshot/copyright /usr/share/doc/gnome-screenshot/NEWS.gz /usr /share/doc/gnome-screenshot/changelog.Debian.gz
Note that the gnome-screenshot package program name is gnome-screenshot.
You asked
Whether there is a standard way to know
For the desired program?
Sometimes the terminal may indicate your package name, which needs to be installed in order to have the program you want. This happens when the program is in the standard repository and you have enabled that repository.
For example, if I run gnome-documents when such a package is not installed, the terminal will say the following:
Anwar@edubuntu-lenovo:~$ gnome-documents The program "gnome-documents" is currently not installed. You can install it by typing: sudo apt-get install gnome-documents
But in this case I should at least know the name of the program
You can try the "aptitude" program from the command line. This is a graphical package manager. Be sure to add sudo to the program for any actual installations. "sudo aptitude". You can also use aptitude just like apt-get; "sudo aptitude install". I prefer apt-get for single packages that I know the names for.
Also, are you just on the command line? If you have a desktop, you can use System -> Preferences -Synaptic or Ubuntu Software Center. They work almost identically, but they have a simpler batch search.
You can get a (long) list of packages to install by typing apt-get install and then pressing TAB twice (to autocomplete). This is limited because it doesn't tell you what the packages do (Synaptic or Software Center would be better for this), but it can be useful when you can't remember the exact name of the package. You can also enter the first part of the package name (for example, openoffice) to get a shorter list of more relevant packages.
Use the command line tool if you know the package name you need. I don't use software center. You can get the package name through the software center and use it in the terminal if you really need to use the apt-get tool from the command line. And usually the package name is the same as the program name.
you can run (preferably in ~~/.bashrc)
. /etc/bash_completion
when entering:
Sudo apt-get in
it will prompt for installation and then start typing part of the name - for example, nvidia
and you will see the available options starting with nvidia