Package management with APT
Package management via apt-get runs hand-in-hand with the /etc/apt/sources.list file. For information on editing or updating your sources list see SourcesList.
Introduction
This page describes how to handle the packages on your system using apt-get and related commands. For example, you can install a new package, remove an installed package, or update all installed packages to the latest versions.
Commands
Installation commands
-
This command installs a new package.
auto-apt
Maintenance commands
Removal commands
- This command removes an installed package, leaving configuration files intact.
- This command completely removes a package and the associated configuration files. Configuration files residing in
- This command removes an installed package and dependencies.
Search commands
This command determines which installed package owns <package_name>. It shows files from installed packages that match <package_name>, with the name of the package they came from. Consider this to be a "reverse lookup" utility.
Typical usage example
I want to feel the wind in my hair, I want the adrenaline of speed. So let’s install a racing game. But what racing games are available?
It gives me a lot of answers. I see a game named "torcs". Let’s get some more information on this game.
Hmmm. it seems interesting. But is this game not already installed on my computer? And what is the available version? Which repository is it from (Universe or Main)?
Ok, so now, let’s install it!
What is the command I must type in the console to launch this game? In this example, it’s straightforward ("torcs"), but that’s not always the case. One way of finding the name of the binary is to look at what files the package has installed in "/usr/bin". For games, the binary will be in "/usr/games". For administrative programs, it’s in "/usr/sbin".
The first part of the command display all files installed by the package "torcs" (try it). With the second part, we ask to only display lines containing "/usr/games/".
Hmmm, that game is cool. Maybe there are some extra tracks?
But I’m running out of space. I will delete the apt cache!
Oh no, my mother asked me to remove all games from this computer. But I want to keep the configuration files so I can simply re-install it later.
If I want to also remove config files :
Setting up apt-get to use a http-proxy
These are three methods of using apt-get with a http-proxy.
Temporary proxy session
This is a temporary method that you can manually use each time you want to use apt-get through a http-proxy. This method is useful if you only want to temporarily use a http-proxy.
Enter this line in the terminal prior to using apt-get (substitute your details for yourproxyaddress and proxyport).
If you normally use sudo to run apt-get you will need to login as root first for this to work unless you also add some explicit environment settings to /etc/sudoers, e.g.
APT configuration file method
This method uses the apt.conf file which is found in your /etc/apt/ directory. This method is useful if you only want apt-get (and not other applications) to use a http-proxy permanently.
Add this line to your /etc/apt/apt.conf file (substitute your details for yourproxyaddress and proxyport).
Save the apt.conf file.
BASH rc method
This method adds a two lines to your .bashrc file in your $HOME directory. This method is useful if you would like apt-get and other applications for instance wget, to use a http-proxy.
Add these lines to the bottom of your
/.bashrc file (substitute your details for yourproxyaddress and proxyport)
Save the file. Close your terminal window and then open another terminal window or source the
Test your proxy with sudo apt-get update and whatever networking tool you desire. You can use firestarter or conky to see active connections.
If you make a mistake and go back to edit the file again, you can close the terminal and reopen it or you can source
/.bashrc as shown above.
How to login a proxy user
If you need to login to the Proxy server this can be achieved in most cases by using the following layout in specifying the proxy address in http-proxy. (substitute your details for username, password, yourproxyaddress and proxyport)
Как удалить пакет Ubuntu
Установка и удаление программ одна из самых важных вещей для пользователя компьютера. Поскольку нам нужно как нибудь получать новые, нужные программы, а также удалять лишние. Но удаление пакетов в Ubuntu имеет некоторые тонкости. После удаления могут остаться зависимости, пакеты установленные, как рекомендованные, а также конфигурационные файлы.
В этой статье мы разберем как удалить deb пакет Ubuntu, при чем удалить чисто, так, чтобы после него не осталось следов в системе. Также поговорим о полном удалении PPA, поскольку много пакетов, которых нет в официальных репозиториях мы устанавливаем из PPA.
Как удалить пакет Ubuntu
Самый простой способ удалить пакет Ubuntu, это воспользоватся одной из графических утилит, поставляемых специально для этого, например Synaptic или Центр приложений Ubuntu. По сути это делается в пару кликов. Сначала рассмотрим порядок действий в Центре приложений Ubuntu.
Запустить центр приложений вы можете из панели значков Unity:
Список всех установленных пакетов находится на вкладке Установлено, здесь приложения рассортированы по категориям:
Чтобы удалить пакет Ubuntu, достаточно кликнуть по нему левой кнопкой мыши, и когда появляться доступные действия нажать кнопку Удалить:
Для завершения нужно будет подтвердить удаление и ввести пароль.
Пакет удален, но не совсем так, как нам хотелось бы. Но об этом позже.
Дальше рассмотрим пакетный менеджер Synaptic. Это как ни как стороннее программное обеспечение, но многие его используют из-за большого функционала и удобного интерфейса. Если программа еще не установлена, ее нужно установить с помощью центра приложений или выполнив в терминале:
sudo apt install synaptic
Запустить программу можно через терминал, выполнив команду:
Посмотреть установленные пакеты вы можете выбрав вкладку состояние, а затем выбрав Установленные:
Удалить deb ubuntu вы можете просто нажав правой кнопкой мыши и в контекстном меню на нужном пакете и выбрав отметить для удаления или отметить для полного удаления:
Программа покажет, какие еще пакеты будут удалены, это те пакеты, которые зависят от нашего пакета:
Теперь, чтобы завершить удаление, осталось нажать кнопку Применить:
Теперь программа покажет какие пакеты будут удалены. И пойдет процесс удаления:
Просто удаление и полное удаление отличается только тем, что при полном удалении удаляются конфигурационные файлы. Но проблема этих инструментов в том, что пакеты установленные как зависимости и рекомендованные к программе не удаляются и остаются в системе. Такое поведение наблюдается как в Synaptic, так и в Центре приложений Ubuntu. Поэтому мы переходим к описанию самого гибкого способа — удаление пакетов Ubuntu в терминале.
Как удалить пакет Ubuntu в терминале
В новых версиях Ubuntu для управления пакетами, а в том числе и удаления можно использовать новый менеджер пакетов — apt. Команда удаления выглядит таким образом:
sudo apt remove имя_пакета
Будет выполнено полное удаление пакета, включая конфигурационные файлы и зависимости, только рекомендованные программы останутся. Если вы хотите использовать apt-get чтобы удалить deb ubuntu, то порядок действий немного другой. Для обычного удаления пакета выполните:
sudo apt-get remove имя_пакета
Для удаления пакета вместе с его конфигурационными файлами, выполните:
sudo apt-get purge имя_пакета
А чтобы, также удалить зависимости, установленные вместе с пакетом, нужно после одной из предыдущих команд выполнить:
sudo apt autoremove
Будут удаленны не только явно указанные зависимости, но и программы установленные как рекомендованные.
Ну с основами разобрались, теперь перейдем к более сложным ситуациям. Что если вы устанавливали программу из deb файла и теперь не знаете точно, как называется ее пакет, чтобы удалить?
Это очень просто узнать, например по исполняемому файлу, допустим исполняемый файл программы TimeShift находится по адресу /usr/bin/timeshift, теперь узнаем ее пакет:
sudo dpkg -S /usr/bin/timeshift
Как видите, пакет так и называется — timeshift. Теперь можно удалить программу Ubuntu, одним из выше описанных способов.
Очень часто мы устанавливаем недостающее нам программное обеспечение из PPA, но не все эти пакеты нужны нам на протяжении долгого времени, а при обновлении системы, могут даже вызвать ошибки. Так как же удалить все пакеты установленные из PPA? Для этого есть специальная утилита: ppa-purge.
Если она еще не установлена, устанавливаем командой:
sudo apt install ppa-purge
Теперь, чтобы удалить все пакеты установленные из определенного ppa используйте:
sudo ppa-purge -i ppa:владелец_ppa/имя_ppa
Обратите внимание на ppa:владелец_ppa/имя_ppa — обычно в таком формате записываются все PPA: протокол:владелец/имя.
Узнать список репозиториев можно в программе источники приложений:
Такой командой можно одним махом удалить пакеты ubuntu, установленные из ppa:
find /etc/apt/sources.list.d -type f -name «*.list» -print0 | \
while read -d $’\0′ file; do awk -F/ ‘/deb / && /ppa\.launchpad\.net/
Если вы устанавливали приложение из исходных кодов, то удалить его намного сложнее, потому что оно не контролируется менеджером пакетов, и соответственно система не знает какие файлы ему принадлежат.
Но все же способ есть, обычно, разработчики в файле сценариев makefile, кроме цели install реализуют цель uninstall, которая дозволяет выполнить обратное действие.
Поэтому если у вас осталась папка с исходным кодом той программы можно просто перейти в нее и выполнить make uninstall чтобы удалить приложение Ubuntu:
cd /папка/с/исходниками
$ sudo make uninstall
Выводы
В этой статье мы рассмотрели все, что поможет вам удалить приложение Ubuntu. При чем удалить полностью, а не только файлы программы. Если у вас остались вопросы, пишите в комментариях.
Обнаружили ошибку в тексте? Сообщите мне об этом. Выделите текст с ошибкой и нажмите Ctrl+Enter.
Как удалить пакет в linux
5.4. Работа с пакетами при помощи dpkg
ЗАМЕТКА dpkg или apt ?
5.4.1. Установка пакетов
Пример 5.2. Установка пакета при помощи dpkg
Пример 5.3. Раздельная распаковка и настройка
ВНИМАНИЕ Эффективное использование —force-*
5.4.2. Удаление пакета
Пример 5.4. Полное удаление пакета debian-cd
5.4.3. Запросы к базе данных dpkg и анализ файлов .deb
К ОСНОВАМ Синтаксис опций команд
Пример 5.5. Получение информации с помощью dpkg
УГЛУБЛЯЕМСЯ Сравнение версий
5.4.4. Файл журнала dpkg
5.4.5. Поддержка мультиархитектуры
5.4.5.1. Включение мультиархитектуры
ЗАМЕТКА Поддержка мультиархитектуры в APT
НА ПРАКТИКЕ Использование собственнических двоичных файлов i386 в системах amd64
Uninstalling Packages With Apt Package Manager
If you’re running a Debian or Ubuntu-based distribution and want to get rid of a package, you can do so in several methods. However, knowing when to use each technique and what sets them apart can be difficult. Using the apt package manager, we will explore the different options for finding and removing packages. We’ll break down when you should use the “purge” instruction versus the “remove” one. More than that, we will provide you with some helpful instructions to run after an uninstall to ensure a clutter-free operating environment. When you’re done reading this article, you’ll have a firm grasp on how to uninstall software packages quickly and easily.
Find The Package You Want To Uninstall
First things first, we need to find the package which we want to uninstall. We can very easily locate our package’s exact name with the following :
This helps us to locate the exact package which we would require for the future steps. Once, we have located out desired package, we can move onto the next step.
Obtaining a list of installed packages
1. Using dpkg
Obtaining a list of installed packages in Linux is beneficial for a variety of purposes, including tracking installed software and creating a backup of the system. Thankfully, there are several methods to complete this task.
The dpkg command, which is a package manager for Debian-based systems, is a common method. By executing the following command in the terminal, a catalog of all installed packages can be obtained:
This command outputs an extensive list of all installed packages, including the package name, version, and a brief description of each package.
2. Using apt
Using the apt command, which is a package manager constructed on top of dpkg, is another useful method. Using apt, we can obtain a list of all installed applications by entering the following command in the terminal:
This command provides a complete detail of installed packages, including the package name and version number.
If you are still confused on which package manager to use here’s an amazing article that compares apt vs dpkg.
Uninstalling Packages With Apt
When talking about uninstalling packages using apt package manager, we have the following two options :
- remove
- purge
1. Using apt remove
To remove a package using ‘remove‘ simply type :
2. Using apt purge
We can very easily remove packages with the ‘purge’ command as such :
What’s the difference between ‘remove‘ and ‘purge‘ ?
So the begging question here is ‘remove‘ and ‘purge‘ and when to use what ?
The primary difference being ‘remove‘ and ‘purge‘ is that ‘remove‘ only gets rid of the package leaving any configuration files untouched. Whereas ‘purge‘ not only removes the package but also removes all configuration files OUTSIDE THE HOME DIRECTORY.
A Fun Little Secret
Quite contrary to what their primary function is, both ‘purge‘ and ‘remove‘ can be used to INSTALL packages. This can be achieved by appending a ‘+‘ at the end of the package name as such :
Post Uninstall Clean Up
At this point, we have successfully removed/purged our package. Now, we can run some commands to perform post-removal clean up out of good practice
We can clear the cache of the old/outdated packages with :
We can remove unrequired packages with :
Finally, any failed/broken installs can be fixed with :
Conclusion
Finally, with the apt package manager, removing software from a Linux machine is a breeze. To begin, we can use the dpkg command to find the package we wish to remove. The apt program can then be used to uninstall or clean the package. The main distinction between the two is that remove does not delete setup files, whereas purge does. Furthermore, by adding a + to the package name, either command can be used to install it. Finally, it’s recommended that you clear the cache, remove any unused packages, and repair any broken installs using apt after uninstalling packages.
References
If you want to learn more on apt, here’s Ubuntu’s official documentation to get you going.