Linux удаление неиспользуемых пакетов

Linux — удаляем ненужные пакеты

Manjaro — популярный Linux дистрибутив основанный на Arch Linux . Многие пользователи любят его за скорость, надежность и простоту в использовании и установке.

Команда разработчиков Manjaro использует для обновления своей системы не метод выхода новых версий, которые нужно постоянно переустанавливать, а систему так называемых rolling релизов . В этом случае, система постоянно получает свежие обновления ПО, ядра Linux и компонентов системы.

Таким образом, эта операционная система годами может стоять на вашем персональном компьютере, без необходимости переустанавливать ее. И это здорово, но у такого метода есть один недостаток.

За время жизни системы в ней скапливаются ненужные более пакеты и зависимости, которые принято называть «сиротами». И за несколько лет их может накопиться приличное количество, что разумеется негативно скажется на объеме вашего жесткого диска.

Но с этой проблемой можно легко справиться, для этого нам потребуется терминал и парочку команд.

Команда покажет все ненужные более пакеты, находящиеся в данный момент в вашей системе. Удалить их можно всего одной командой:

Для ее выполнения потребуются права суперпользователя, так что придется ввести пароль.

Данную команду можно использовать не только для удаления ненужных системе пакетов, но и в случае удаления приложений, которые имели множество зависимостей.

Так что если у вас «пунктик» на чистоту в системе, как и у меня. То теперь вы знаете как сделать Manjaro чуточку «чище».

Не забываем ставить палец вверх и подписываться на канал. Впереди еще много интересного!

Источник

Remove unused packages in Ubuntu? [4 Methods]

One of the most common operations when using an operating system is the package installation process. In this process, package(s) are installed, but sometimes unused packages remain in the system. These packages can sometimes cause problems in package dependencies.

In this article, we will share information about removing unused packages on Ubuntu, which is a Debian based distribution.

Different methods to remove unused packages in Ubuntu

To delete unused packages in Ubuntu can be done with apt package manager and packages installed with this package manager. Let’s explain what to do with apt, then how to remove unused packages using a few packages. Finally, let’s delete unused packages with a useful script.

Читайте также:  Запуск venv python linux

Method -1- Using apt parameters

While apt-get is used as the package manager in old ubuntu distributions, apt is used in new version Ubuntu. The package manager’s parameters are used to remove unused packages. Let’s look at the parameters of apt in order.

autoremove

The autoremove parameter is used to remove packages that are automatically installed to meet the dependencies of other packages. These packages are no longer needed because their dependencies have changed or the package(s) that need them have been removed.

root@foc-ubuntu21:/# apt autoremove Reading package lists. Done Building dependency tree. Done Reading state information. Done 0 upgraded, 0 newly installed, 0 to remove and 248 not upgraded.

After the command, unused packages are listed and deleted after confirmation.

clean

The clean cleans the local repository of imported package files. Removes everything but the lock file from the /var/cache/apt/archives/ and /var/cache/apt/archives/partial/ directories.

root@foc-ubuntu21:/# apt clean

autoclean

The autoclean cleans the local repository of received package files like the clean parameter. The difference is that it only removes package files that are no longer downloadable and largely useless.

root@foc-ubuntu21:/# apt autoclean Reading package lists. Done Building dependency tree. Done Reading state information. Done 

Method -2- Using the popcon-largest-unused command

The popcon-largest-unused command, which comes with the popularity-contest package, lists the unused packages.

First, install it on the system:

root@foc-ubuntu21:/# apt install popularity-contest -y

When you want to run the post-installation command, you will receive the following warning. In the same warning, you will be shown what you need to do:

root@foc-ubuntu21:/# popcon-largest-unused warning: Missing required file /var/log/popularity-contest. info: Run 'popularity-contest > /var/log/popularity-contest' to generate it. 

Then run the following command:

root@foc-ubuntu21:/# popularity-contest > /var/log/popularity-contest

Now get a list from most used package to least used:

root@foc-ubuntu21:/# popcon-largest-unused
. 32 libencode-locale-perl 31 libhtml-tagset-perl 31 libfile-listing-perl 30 libwacom-bin 30 gkbd-capplet 29 libhttp-date-perl 27 perl-openssl-defaults 27 liblwp-protocol-https-perl 25 libextutils-pkgconfig-perl 22 tcl 19 libnet-smtp-ssl-perl

Now remove the least used package:

root@foc-ubuntu21:/# apt remove libnet-smtp-ssl-perl Reading package lists. Done Building dependency tree. Done Reading state information. Done The following package was automatically installed and is no longer required: libauthen-sasl-perl Use 'sudo apt autoremove' to remove it. The following packages will be REMOVED: libmailtools-perl libnet-smtp-ssl-perl 0 upgraded, 0 newly installed, 2 to remove and 248 not upgraded. After this operation, 248 kB disk space will be freed. Do you want to continue? [Y/n]

With your approval, the package is removed from the system. You can see that the package was installed automatically and is no longer needed.

Читайте также:  Linux can bus interface

Method -3- Using the deborphan command

The deborphan, finds packages that don’t have packages linked to the package typed after the command.

Run the following command for installation:

root@foc-ubuntu21:/# apt install deborphan -y
Usage: deborphan [OPTIONS] [PACKAGE].
root@foc-ubuntu21:/# deborphan -a main/admin deborphan main/web firefox-locale-en main/perl libauthen-sasl-perl main/kernel linux-generic-hwe-20.04 main/misc popularity-contest main/python python3-cffi-backend main/utils shim-signed main/metapackages ubuntu-minimal main/metapackages ubuntu-standard

The -a parameter checks all packages. It is best used with —priority (if used at all). This option means —show-section.

root@foc-ubuntu21:/# apt remove firefox-locale-en Reading package lists. Done Building dependency tree. Done Reading state information. Done The following package was automatically installed and is no longer required: libauthen-sasl-perl Use 'sudo apt autoremove' to remove it. The following packages will be REMOVED: firefox-locale-en 0 upgraded, 0 newly installed, 1 to remove and 247 not upgraded. After this operation, 1.169 kB disk space will be freed. Do you want to continue? [Y/n]

After your confirmation, the package will be deleted. After the deletion, the system will not have any problems, because it was not used anyway.

Method -4- Using unusedpkg (Bash Script)

This script is maintained by a third party owner on GitHub. Please make sure you test it thoroughly or go through the script before using it.

There is a bash script called unusedpkg, we will download this script and use. Download the file with the following command:

foc@foc-ubuntu21:~$ wget https://github.com/epinna/Unusedpkg/archive/refs/heads/master.zip --2022-11-28 14:31:20-- https://github.com/epinna/Unusedpkg/archive/refs/heads/master.zip . HTTP request sent, awaiting response. 200 OK Length: unspecified [application/zip] Saving to: ‘master.zip’ master.zip [ ] 26,30K --.-KB/s in 0,09s 2022-11-28 14:31:21 (281 KB/s) - ‘master.zip’ saved [26928] 

Then extract the downloaded zip file and enter the directory:

foc@foc-ubuntu21:~$ unzip master.zip && cd Unusedpkg-master

Give unusedpkg file execute permission:

foc@foc-ubuntu21:~/Unusedpkg-master$ chmod +x unusedpkg
foc@foc-ubuntu21:~/Unusedpkg-master$ ./unusedpkg * UnusedPkg 1.0 Find unused packages in your Linux system. Database /home/foc/.unusedpkg/pkglist doesn't exist (first run?). Automatically executing './unusedpkg update'. 1476 packages available. [18%] gir1.2-javascriptcoregtk-4.0:amd64 [21%] gnome-shell-extension-appindicator . [79%] network-manager-config-connectivity-ubuntu [90%] speech-dispatcher-audio-plugins:amd64 Database update done. WARNING: The reported idle days may be wrong. Before removing packages, check timestamps with 'unusedpkg info ' or check the timestamps with 'ls -alu'. See README for more info. Minimum packages size: 1MB IDLE DAYS SIZE PACKAGE NAME 2497 3MB tzdata 1057 1MB printer-driver-m2300w 1029 2MB x11-apps 913 2MB printer-driver-foo2zjs-common . 

UnusedPkg is a tool to find unused packages in Ubuntu operating system (All Debian based operating systems) sorted by their idle time. The packet with the largest idle time is at the beginning of the queue.
After this output, you can perform the deletion by looking at the dependencies of the relevant package.

Читайте также:  Astra linux ssh config

For example, you can delete the printer-driver-foo2zjs-common package like this:

foc@foc-ubuntu21:~$ sudo apt remove printer-driver-foo2zjs-common Reading package lists. Done Building dependency tree. Done Reading state information. Done The following packages were automatically installed and are no longer required: dc mscompress Use 'sudo apt autoremove' to remove them. The following packages will be REMOVED: printer-driver-foo2zjs printer-driver-foo2zjs-common 0 upgraded, 0 newly installed, 2 to remove and 249 not upgraded. After this operation, 3.339 kB disk space will be freed. Do you want to continue? [Y/n]

If you approve, the package will be deleted.

Summary

We explained how to delete unused packages on Ubuntu with the apt package manager, popcon-largest-unused and deborphan command.

You can get the parameters of the Deborphan package, and information about the popcon-largest-unused command from the popularity-contest package’s man page.

If it is about the apt command, you can use the local manual page:

root@foc-ubuntu21:/# man apt apt - command-line interface DESCRIPTION apt provides a high-level commandline interface for the package management system. It is intended as an end user interface and enables some options better suited for interactive usage by default compared to more specialized APT tools like apt-get(8) and apt- cache(8). . 

References

Didn’t find what you were looking for? Perform a quick search across GoLinuxCloud

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can either use the comments section or contact me form.

Thank You for your support!!

Источник

Оцените статью
Adblock
detector