Linux+: Applications 21 - Diagnose Package Issues with Apt-Get


Jarret W. Buse

Linux+: Applications 21 - Diagnose Package Issues with Apt-Get

Many people like the aspect of downloading free applications. When Linux downloads a package for installation, many things can happen to the package. At times, it is important to be able to check the packages which have been installed.

If a package causes errors, most issues have to do with package dependencies. If certain dependencies are missing, applications will not start or function properly. To fix these problems, the apt-get subcommand used is:

  • check

Basically, the check subcommand will update the package lists and then check for broken dependencies.

When the check is done, the repository list update is similar to the command “apt-get update”. Clean also fixes the broken dependencies like the command “apt-get -f install”.

The process of using “apt-get check” is as follows:

  • lock apt-get list file
  • lock dpkg lock file
  • open /etc/apt/sources.list
  • download package list from repositories in sources.list
  • open /etc/apt/sources.list.d
  • download package list from repositories in sources.list.d
  • use package list to check installed dependencies for install packages
  • missing dependencies are downloaded to /var/cache/apt/archives/
  • missing dependencies are installed using dpkg
  • missing dependencies are marked as installed in /var/lib/dpkg/status

The process is a fairly straight-forward one. Whenever “apt-get” is used, the lock file is marked as locked. When locked, another process using “apt-get” cannot perform updates to prevent the data files from being corrupted. One process cannot update the package list from a repository while another is trying to read it for updates. The locked file is “/var/lib/apt/lists/lock”.

The “apt-get” command uses the “dpkg” command in the background to download and install files. For this reason, “dpkg” also has a lock on it. The lock is the file “/var/lib/dpkg/lock”. If either file is locked, then an error will be issued and the second process attempting to use “apt-get” will fail.

After the “apt-get” process has a lock, the sources.list is opened to obtain a list of repositories. These repositories are contacted and the package list is retrieved. The same occurs for the sources.list.d file with more lists gathered from more repositories.

Now, the repository lists are updated and the lists can be scanned for package dependencies. Any dependencies found on the list and not on the system are then downloaded. The files are downloaded from the specified repository and placed in /var/cache/apt/archives/. Once the dependencies are downloaded, “dpkg” is used to install the dependency.

Once installed, the status of the dependency is marked as installed in /var/lib/dpkg/status.

Hopefully, this will give you a better overview of “apt-get” and what is going on “under the hood” when it is used.


  • slide.jpg
    32.9 KB · Views: 28,162
$100 Digital Ocean Credit
Get a free VM to test out Linux! Hosting Donations
Consider making a donation

Members online

No members online now.