Ubuntu проверить ошибки пакетов

Во время установки программ с помощью пакетного менеджера apt в любом из дистрибутивов, использующих этот пакетный менеджер, вы можете столкнуться с ошибкой, что у вас зафиксированы сломанные пакеты. Это пакеты, которые не установились полностью потому что им не хватает зависимостей или процесс установки был по какой-либо причине прерван.

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

Как исправить у вас зафиксированы сломанные пакеты?

1. Обновите списки пакетов

Возможно вам не удалось установить нужные пакеты потому что списки репозиториев устарели, и там ещё не было нужных пакетов. Для обновления списка пакетов выполните:

sudo apt update --fix-missing

2. Установите битые пакеты

После обновления списка пакетов из репозиториев может помочь установка битых пакетов. Этот шаг поможет особенно если вы устанавливали пакет с помощью dpkg и теперь нужно доустановить его зависимости с помощью пакетного менеджера. Для этого есть специальная команда:

sudo apt install -f

3. Очистите лишние пакеты

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

sudo apt clean

Затем:

sudo apt autoremove

Утилита отобразит список всех битых пакетов, которые не установлены, вы можете попытаться их удалить с помощью команды:

sudo dpkg --remove -force --force-remove-reinstreq имя_пакета

4. Используйте dpkg

Вместо apt вы можете использовать команду dpkg чтобы посмотреть какие пакеты вызывают проблему. Просто выполните:

sudo dpkg --configure -a

Команда покажет проблемные пакеты, а потом вы сможете их удалить той же командой:

sudo dpkg --remove -force --force-remove-reinstreq имя_пакета

5. Разрешите зависимости

Битые пакеты чаще всего появляются из-за того, что пакетный менеджер не может найти для них нужные зависимости. Если вам всё же очень нужно установить такой пакет, просто разрешите эти зависимости. Для этого можно скачать и установить их вручную или если вы уверенны, что зависимости в пакете указаны неверно, можно скачать его распаковать и удалить мешающие зависимости. Подробнее об этом читайте в этой статье.

Выводы

В этой небольшой статье мы рассмотрели что делать если в вашей системе появились битые пакеты и как их исправить. Здесь решение проблемы очень сильно зависит от вашей ситуации, но здесь приведены основные варианты решения, которые должны помочь вернуть пакетный менеджер к работе. Иногда рекомендуют удалить пакет вручную из базы данных dpkg /var/lib/dpkg/status, однако лучше этого не делать и найти путь решить проблему по другому, ручное редактирование подобных файлов может создать ещё больше проблем.

Обнаружили ошибку в тексте? Сообщите мне об этом. Выделите текст с ошибкой и нажмите Ctrl+Enter.

Creative Commons License

Статья распространяется под лицензией Creative Commons ShareAlike 4.0 при копировании материала ссылка на источник обязательна .

Об авторе

Основатель и администратор сайта losst.ru, увлекаюсь открытым программным обеспечением и операционной системой Linux. В качестве основной ОС сейчас использую Ubuntu. Кроме Linux, интересуюсь всем, что связано с информационными технологиями и современной наукой.

Introduction

Linux packages are compressed archives containing programs and files necessary to run them. The package distribution system is designed to be robust and simplify the application installation process.

However, a bad internet connection or misconfigured third-party installers can corrupt packages and cause problems on your system.

This article will show you how to troubleshoot and fix broken packages on Ubuntu using the available APT and DPKG tools.

How to fix broken packages in Ubuntu

Prerequisites

  • An account with sudo privileges
  • An Ubuntu system

Check for Updates

Start troubleshooting by rebuilding the list of dependencies. The --fix-missing option tells APT to ignore missing packages. The option ensures the update process is performed without APT returning an error.

sudo apt update --fix-missing
The --fix-missing option tells APT to ignore the missing packages

Force APT to Correct Missing Dependencies or Broken Packages

Missing package dependencies are a common reason for package-related errors.

1. Use apt install with the -f flag to tell APT to locate the missing packages and install them.

sudo apt install -f

APT lists the missing packages on your system.

The apt install tells APT to locate the missing packages and install them

2. Press ENTER to start the installation.

Note: If troubleshooting has led to Ubuntu needing to be reinstalled, please refer to our reinstallation guide How to Reinstall Ubuntu.

Force Reconfigure or Remove Broken Packages with DPKG

Broken packages may cause package manager configuration problems.

1. Reconfigure DPKG, the base package management system, with the following command:

sudo dpkg --configure -a

2. Check if DPKG marked some packages as needing a reinstall.

sudo dpkg -l | grep ^..R

3. If the command above returns a list of one or more packages, try removing the packages by typing:

sudo dpkg --purge --force-all [package-name]

The example below shows how to remove the corrupted vlc-plugin-base package.

Remove the corrupted vlc-plugin-base package

Warning: The dpkg --purge --force-all command removes a package even if the removal causes further dependency issues. Use the command with care.

4. After you finish troubleshooting, run the following command to clean up the system:

sudo apt clean

5. Then update the repositories again:

sudo apt update

Resolve DPKG Lock Issue

The DPKG lock error appears when trying to install a package while another process is using DPKG.

The DPKG lock error appears when trying to install a package while another process is using DPKG

However, sometimes the error occurs even if no other processes are using the package management system.

1. To fix the problem, remove the lock file manually:

sudo rm /var/lib/apt/lists/lock

2. Also, remove the lock in cache:

sudo rm /var/cache/apt/archives/lock

Deleting the lock enables you to use APT and DPKG again.

Conclusion

The article provided common ways of resolving problems caused by broken packages on Ubuntu.

For more information related to package management on Ubuntu, read:

  • How to List Installed Packages on Ubuntu
  • A Comprehensive Guide to Using Snap Packages on Ubuntu
  • How to Install Deb Files (Packages) on Ubuntu

Broken packages need repairing or the software won’t run. Here’s how to find the broken packages and fix them in Linux.

fix-broken-packages-linux

Package managers on Linux allow you to control the installation and removal of packages. In addition, package managers also help you find broken packages on your system and reinstall them to fix various issues associated with Linux packages.

If you are unaware of which commands to use to find and fix broken packages in Linux, then this guide is for you. We will briefly discuss what broken packages are, how you can check if your system contains broken packages, and how to reinstall them properly to fix the error.

What Are Broken Packages in Linux?

When you install a new package in Linux, your system’s package manager is in charge of the whole installation process. These package managers have built-in methods to handle exceptions and errors. But sometimes, in case of unexpected issues, the installation halts and the complete package isn’t installed. Such packages are called broken packages.

Package managers like APT do not allow further installation if it finds a broken package on the system. In such a situation, repairing the broken package is the only option.

How to Find and Fix Broken Packages in Linux

Every package manager handles different types of packages. For example, DNF and YUM work with the Red Hat Package Manager (RPM) to download and install RPM packages. Similarly, APT acts as a frontend wrapper for the base dpkg software on Debian-based distributions.

Reinstalling Broken Packages on Ubuntu and Debian

APT is the default package manager that comes preinstalled on every Debian-based distribution. Apart from APT, Debian and Ubuntu users can download and install packages manually using dpkg as well.

The steps mentioned below will also work if you want to fix broken packages on Kali Linux, since after all, Kali is a Debian-based distro.

To fix broken packages on Debian-based distributions using APT:

  1. Open the terminal by pressing Ctrl + Alt + T on your keyboard and enter:
     sudo apt --fix-missing update 
  2. Update your system’s package list from the available sources:
     sudo apt update 
  3. Now, force the installation of the broken packages using the -f flag. APT will automatically search for broken packages on your system and reinstall them from the official repository.
     sudo apt install -f 

If the aforementioned steps do not work for you, you can try to solve the issue using dpkg.

  1. Force dpkg to reconfigure all the pending packages that are already unpacked but need to undergo configuration. The -a flag in the following command stands for All:
     sudo dpkg --configure -a 
  2. Pipe grep with dpkg to get a list of all the packages marked as Required:
     sudo dpkg -l | grep ^..r 
  3. Use the —remove flag to delete all the broken packages:
     sudo dpkg --remove --force-remove-reinstreq 
  4. Clean up the package cache and install scripts using apt clean:
     sudo apt clean 
  5. Now, update your system’s package lists using the following command:
     sudo apt update 

Fix Broken Packages on Fedora/CentOS and RHEL

Although YUM and DNF are great when it comes to managing broken packages automatically, sometimes problems do arise as there are thousands of packages installed on a Linux system. In such situations, you can use RPM, the base package manager for Fedora and CentOS, to fix such issues quickly.

  1. Verify all the packages on your system using the -V flag:
     sudo rpm -Va 
  2. You will see a long list containing all the installed packages on your system. Reinstall the package that you think might be causing the broken package issue with:
     sudo dnf --refresh reinstall packagename 

The above steps are highly inconvenient—identifying which package is causing the problem from a list of hundreds is tiresome. Although RPM is a powerful package manager and you will rarely run into such issues, knowing how to fix these problems is still important in case you bump into a similar situation in the near future.

Managing Packages on Linux Distributions

Package managers on Linux are capable of handling most of the issues including failed installations. But sometimes, various problems occur that you can only solve intuitively. The solution to fixing broken packages comprises several steps—identifying the broken package, reinstalling it, and updating the system’s package list.

There are countless Linux distributions available that are worth trying, but deep down, each one of them has a similar foundation.

Desktop environments set each distribution apart by providing a unique user experience. Choosing an ideal desktop environment that suits your taste should be your priority if you have finally decided to go ahead with Linux.

When I try to google how to do this, all the results I get are «How to fix broken packages«.

Could you give me a hint how to only list them in the console one by one?

muru's user avatar

muru

194k53 gold badges475 silver badges725 bronze badges

asked May 15, 2016 at 9:04

OccamRazor's user avatar

1

It seems that nobody has recommended this:

sudo apt-get check

also for more info try

apt-get --help

Zanna's user avatar

Zanna

69.3k56 gold badges217 silver badges327 bronze badges

answered Nov 21, 2017 at 18:14

JesseB's user avatar

JesseBJesseB

1711 silver badge5 bronze badges

You can list broken packages :

dpkg -l | grep ^..r 

r state (on the third field) means: reinst-required (package broken, reinstallation required)

dpkg fields explanation

Community's user avatar

answered May 15, 2016 at 9:29

EdiD's user avatar

EdiDEdiD

4,3573 gold badges23 silver badges40 bronze badges

1

To get the list of partially installed packages (with architecture information) preceded by their states, one by line, run

dpkg-query -W -f='${db:Status-Abbrev} ${binary:Package}\n' | grep -E ^.[^nci]

See man dpkg-query for information about the states etc. (I suppose the Reinst-required i.e. R flag can not appear with states n, c or i. If it could, the extended regular expression in grep command should be modified.)

answered May 13, 2017 at 7:46

jarno's user avatar

jarnojarno

5,3175 gold badges49 silver badges77 bronze badges

I did a dist-upgrade which completed, but had puked some errors during the process. So I wanted to validate the errors weren’t merely just noise.

apt-get check -v returned NO faults.

HOWEVER: Suspicious the previous command didn’t provide correct feedback, I next executed:

dpkg -C

This command DID validate the errors

Given the above experience, I’d suggest not to take the output of apt-get check -v as the gospel everything is clean…

answered Feb 7 at 19:21

F1Linux's user avatar

F1LinuxF1Linux

99615 silver badges22 bronze badges

You must log in to answer this question.

Not the answer you’re looking for? Browse other questions tagged

.

Introduction

Broken packages are a common issue for Ubuntu users, and they can cause a lot of trouble. When a package is broken, it means that there is an error in the installation process or post-installation scripts. This results in a situation where the package cannot be installed, upgraded, or even removed from your system.

Broken packages can cause programs to malfunction and leave the system unstable, which can result in loss of data and other problems. It is crucial to fix broken packages as soon as possible to avoid further issues with your system stability.

Identifying Broken Packages

Using the Terminal to check for broken packages

The Terminal is a powerful tool that can be used to check for broken packages in Ubuntu. To do so, open the Terminal and use the following command −

sudo apt-get check 

This command will scan the system for any broken dependencies or missing files required by installed packages. If there are any issues, a message will appear listing the problematic packages and dependencies that need to be fixed. Additionally, another useful command is −

sudo dpkg --audit 

This command checks for any inconsistencies in installed packages and their files. It identifies missing files or incorrect permissions on certain files.

Using Synaptic Package Manager to identify broken packages

Synaptic Package Manager is a graphical user interface (GUI) tool that can also be used to identify broken packages in Ubuntu. To use it, open Synaptic from the Applications menu, then click on «Status» on the left-hand side of the window and select «Broken».

This will display a list of all the broken package dependencies on your system. The list displays each package’s name along with its current state (broken) and a brief explanation of why it’s broken.

Fixing Broken Packages

Once you have identified the broken packages on your Ubuntu system, it’s time to fix them. There are two main ways you can go about fixing broken packages: by using the Terminal and its command-line interface or by using Synaptic Package Manager, which provides a more user-friendly graphical interface.

Using the Terminal to Fix Broken Packages Using apt-get and dpkg Commands

One way to fix broken packages is by using the Terminal. This method is particularly useful for those who are comfortable with using a command-line interface. Here are the steps −

  • Open up your Terminal and enter the following command −

sudo apt-get update 

    This will ensure that your package lists are up-to-date.

  • If there are any updates available, run this command next −

sudo apt-get upgrade

    This will update all installed packages on your system.

  • If you still have broken packages after running an upgrade, you can try to fix them with this command −

sudo apt-get install -f 

    The «-f» flag stands for «fix» and will attempt to correct any issues with dependencies or missing files.

  • If none of these commands work, you may need to use another tool called dpkg.

Here’s how −

  • Type in this command −

sudo dpkg --configure -a  

    This will configure all previously installed but unconfigured packages.

  • If there were any issues with dependencies during installation, run this command next −

sudo apt-get install -f

Using Synaptic Package Manager to Fix Broken Packages

Synaptic Package Manager is a graphical tool that allows you to fix broken packages in a more user-friendly way. Here’s how −

  • Open up Synaptic Package Manager by searching for it in your application menu or typing «sudo synaptic» in the Terminal.

  • Click on the «Status» button on the bottom left-hand corner of the window.

  • Select «Broken Dependencies» from the filter options. This will display all packages with broken dependencies.

  • Right-click on any package with broken dependencies and select «Mark for Reinstallation».

  • Click on the «Apply» button in Synaptic Package Manager. This will reinstall all marked packages, including those with missing dependencies.

Removing Broken Packages

Sometimes, fixing a broken package is not possible, and removing the package becomes necessary. In such cases, it’s essential to remove the broken package completely from the system before attempting to install it again. Leaving remnants of a broken package on the system can lead to further issues during installation or upgrades.

There are two primary methods for removing broken packages in Ubuntu: using the Terminal and using Synaptic Package Manager. Both methods work effectively, and it comes down to personal preference which method you choose.

Using the Terminal

To remove a broken package using the Terminal, you first need to identify its name. You can do this by running either of these commands −

sudo dpkg --list | grep -i 
sudo apt list --installed | grep -i 

Once you have identified the package name, use one of these commands to remove it −

sudo apt-get remove -f 
sudo dpkg --remove --force-remove-reinstreq 

The first command uses apt-get remove with the force (-f) option to uninstall any remaining files associated with the package. The second command uses dpkg with force-remove-reinstreq option that forces removal of files even if they are marked as essential or already installed.

Using Synaptic Package Manager

If you prefer using GUI over Terminal Commands, you can use Synaptic Package Manager tool for removing packages. Open Synaptic Package Manager from Ubuntu Dash or Menu and search for your desired program/package that needs removal.

Once identified, right click on it and select «Mark for Complete Removal». This will not only delete all dependencies but also configurations files related to that program/package.

Preventing Broken Packages in the Future

Best practices for avoiding future issues with package management

Preventing broken packages in Ubuntu is a crucial step to avoid issues that may arise from package management. Although it may be impossible to avoid all problems, there are several best practices you can follow to minimize the risk. The first practice is to always install software from official Ubuntu repositories only.

This applies even when using a third-party tool like apt-fast or aptitude, which should always use the official Ubuntu sources. Another best practice for avoiding future broken packages in Ubuntu is to perform regular system updates.

Keeping software up-to-date

One of the most common causes of broken packages in Ubuntu is outdated software. In addition to keeping your system updated, it’s essential to keep all installed applications up-to-date as well. While this can be done manually by checking for new releases periodically, using tools like Aptitude or Synaptic Package Manager can make the process much easier.

Avoiding third-party repositories

Although third-party repositories may provide access to additional software not available on official Ubuntu repositories, they can also be risky and cause conflicts with existing packages on your system leading to broken packages. To avoid such issues, you should only install applications from trusted third-party sources and ensure they have been designed explicitly for use with Ubuntu.

Properly removing software

Another common cause of broken packages in Ubuntu is improper removal of installed applications. When uninstalling software in Ubuntu, you should always use the standard package management tools such as Synaptic Package Manager or the Terminal instead of manually deleting files from your file system.

Conclusion

Broken packages can cause inconvenience and frustration for Ubuntu users. However, with the right tools and knowledge, fixing these packages can be a straightforward process. By using the Terminal or Synaptic Package Manager to identify and fix broken packages, Ubuntu users can take control of their package management system.

And by following best practices for package management such as keeping software up-to-date, avoiding third-party repositories, and properly removing software when necessary, users can prevent future issues with broken packages. Remember to always check for broken packages before installing new software or updating existing programs.

  • Related Articles
  • How To Fix Broken Ubuntu OS Without Reinstalling It?
  • How to fix broken images automatically in jQuery?
  • A Comprehensive Guide to Using Snap Packages on Ubuntu
  • How to Fix \»W: Some index files failed to download.\» Error In Ubuntu?
  • How to Fix sub-process usrbindpkg returned an error code (1) in Ubuntu?
  • How to Fix \’add-apt-repository command not found\’ on Ubuntu & Debian?
  • How to Fix “Could not get lock /var/lib/dpkg/lock” Error on Ubuntu?
  • How to Fix Username is not in the sudoers file. This incident will be reported in Ubuntu?
  • How To Fix and Protect The Linux Server Against the Dirty COW Vulnerability on Ubuntu
  • How to compile packages in Java
  • How to fix android.os.NetworkOnMainThreadException?
  • How to Fix \»ERR_SSL_VERSION_OR_CIPHER_MISMATCH\»?
  • How to Fix java.lang.ClassCastException in TreeSet?
  • How to Find Broken Symlinks in Linux
  • How to Fix Absolute Imports in TypeScript?
Kickstart Your Career

Get certified by completing the course

Get Started

Понравилась статья? Поделить с друзьями:
  • Ubuntu постоянные ошибки
  • Unb ошибка на стиральной машине haier что делать
  • Ubuntu ошибки apache
  • Unb ошибка на стиральной машине haier как сбросить
  • Ubuntu ошибка репозиториев