Ubuntu package
Package maintenance
- https://help.ubuntu.com/community/AptGet/Howto#Maintenance_commands
- 25 Useful Basic Commands of APT-GET and APT-CACHE for Package Management
- apt-get being replaced with apt? in Ubuntu 16.04 apt now comes with a progress bar, coloring, etc.
Security of deb packages
How DEB Packages Are Backdoored and How to Detect It
wajig: Simplyfying Debian Administration
- Wajig - Unified Package Management Front-end for Debian
- What is the real difference between “apt-get” and “aptitude”? (How about “wajig”?)
- wajig listfiles foo
- wajig whichpkg /usr/bin/foo
- Examples
- Install Rattle on Ubuntu
GNOME software
- https://en.wikipedia.org/wiki/GNOME_Software
- How to Install GNOME Software Center on Chrome OS
- When I use GNOME software to install "okular", the application is not found in the regular path? When I use it to open a pdf file, I see a new process "bwrap --args 36 okular XXX.pdf".
nala
- https://gitlab.com/volian/nala, https://github.com/volitank/nala
- Nala – A Feature-rich Commandline Frontend For APT Package Manager. Nala ships with the following distinct features out of the box.
- Pretty output formatting,
- History function,
- Parallel downloads,
- Fetch fastest mirror.
- Nala: A Beautiful and Structured Frontend for the APT Command
Package repository and /etc/apt/sources.list
- https://help.ubuntu.com/community/Repositories/CommandLine
- http://askubuntu.com/questions/197564/how-do-i-add-a-line-to-my-etc-apt-sources-list
echo "new line of text" | sudo tee -a /etc/apt/sources.list # OR # use 'add-apt-repository' command sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 886DDD89 sudo add-apt-repository "deb http://deb.torproject.org/torproject.org $(lsb_release -s -c) main" sudo apt-get update
sudo sh -c 'echo "deb http://cran.rstudio.com/bin/linux/ubuntu trusty/" >> /etc/apt/sources.list' # Or the following if the OS is Ubuntu # (other derived distributions like Linux Mint do not count) # because $(lsb_release -s -c) returns the CodeName which diffs from each Linux distributions. # sudo sh -c 'echo "deb http://cran.rstudio.com/bin/linux/ubuntu $(lsb_release -s -c)/" >> /etc/apt/sources.list' gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9 gpg -a --export E084DAB9 | sudo apt-key add - sudo apt-get update sudo apt-get -y install r-base
sources.list.d
This directory has more contents than the /etc/apt/sources.list file. For example, on my Mint 17.2
$ cat /etc/apt/sources.list #deb cdrom:[Linux Mint 17.2 _Rafaela_ - Release amd64 20150627]/ trusty contrib main non-free deb http://download.virtualbox.org/virtualbox/debian trusty contrib $ ls /etc/apt/sources.list.d additional-repositories.list google-chrome.list shutter-ppa-trusty.list docker.list mc3man-mpv-tests-trusty.list stebbins-handbrake-releases-trusty.list ekozincew-ppa-trusty.list official-package-repositories.list webupd8team-java-trusty.list getdeb.list openshot_developers-ppa-trusty.list wine-wine-builds-trusty.list
See an example of how to use it: https://apt.syncthing.net/
# Add the release PGP keys: curl -s https://syncthing.net/release-key.txt | sudo apt-key add - # Add the "stable" channel to your APT sources: echo "deb https://apt.syncthing.net/ syncthing stable" | sudo tee /etc/apt/sources.list.d/syncthing.list # Update and install syncthing: sudo apt-get update sudo apt-get install syncthing
Remove a repository
sudo add-apt-repository --remove ppa:<ppa_name> sudo add-apt-repository -r ppa:<ppa_name>
GPG
A Practical Guide to GPG.
- Part 1 Generate Your Keypair,
- Part 2 Encrypt and Decrypt Message,
- Part 3 Working with Public Key,
- Part 4 Digital Signature.
$ sudo apt update # today is 10/22/2020 W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ InRelease: The following signatures were invalid: EXPKEYSIG 51716619E084DAB9 Michael Rutter <[email protected]> ...
How to add a GPG key to the apt sources keyring?
wget -qO - https://deb.opera.com/archive.key | sudo apt-key add - $ apt-key list /etc/apt/trusted.gpg -------------------- ... pub rsa2048 2010-10-19 [SCA] [expired: 2020-10-16] E298 A3A8 25C0 D65D FD57 CBB6 5171 6619 E084 DAB9 uid [ expired] Michael Rutter <[email protected]> ...
The solution is to run the sudo apt-key again.
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 $ apt-key list pub rsa2048 2010-10-19 [SCA] [expires: 2027-09-30] E298 A3A8 25C0 D65D FD57 CBB6 5171 6619 E084 DAB9 uid [ unknown] Michael Rutter <[email protected]> sub rsa2048 2010-10-19 [E] [expires: 2027-09-30]
An example for installing R software on Ubuntu
sudo apt update -qq sudo apt install --no-install-recommends software-properties-common dirmngr wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc # -qO- will print to standard output screen # If we use "-q", it will save to the disk gpg --show-keys /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc # pub rsa2048 2010-10-19 [SCA] [expires: 2027-09-30] # E298A3A825C0D65DFD57CBB651716619E084DAB9 <--- fingerprint # uid Michael Rutter <[email protected]> # sub rsa2048 2010-10-19 [E] [expires: 2027-09-30] sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"
More info:
- Fixing "Key is stored in legacy trusted.gpg keyring" Issue in Ubuntu
- apt-key commands list/add/del
- apt-key list: This command lists the trusted keys that are currently stored in the /etc/apt/trusted.gpg file and the /etc/apt/trusted.gpg.d directory
- apt-key add [filename]
- apt-key del [keyid]
Setup APT Proxy
How to Setup APT Proxy on Ubuntu 20.04 LTS
E: Could not get lock /var/lib/dpkg/lock
I get the above message when I run sudo apt-get update on a virtual machine that I have not used for a long time (on Ubuntu click 'Show Applications' and type Logs). Many people also reported this problem. The following shows the reason why I got the error. My case seems to be related to the process apt.systemd.daily. Read the comment by Kjetil S from the link in Solution 1 below. One easy solution I did is to reboot the machine.
brb@ubuntu1804:~/Downloads$ sudo apt install mupdf E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable) E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it? brb@ubuntu1804:~/Downloads$ ps aux | grep -i apt root 1327 0.0 0.0 4628 772 ? Ss 09:26 0:00 /bin/sh /usr/lib/apt/apt.systemd.daily update root 1371 0.0 0.0 4628 1780 ? S 09:26 0:00 /bin/sh /usr/lib/apt/apt.systemd.daily lock_is_held update _apt 3902 3.0 0.2 88932 8636 ? S 09:29 0:05 /usr/lib/apt/methods/http brb 4516 0.0 0.0 21536 1032 pts/0 S+ 09:32 0:00 grep --color=auto -i apt
Solution 1:
Unable to lock the administration directory (/var/lib/dpkg/) is another process using it?.
I can reproduce the error from a clean boot. The most possible explanation is the answer from poolie:
the command-line apt overlaps with update-manager automatically polling. So if you try again in a few minutes that should fix it.
From my experience, after I wait about 10 minutes, ps -A | grep apt won't show anything.
Solution 2:
Fix “Unable to lock the administration directory (/var/lib/dpkg/)” in Ubuntu
# Method 1: Find and Kill all apt-get or apt Processes $ ps -A | grep apt 1760 ? 00:00:00 apt.systemd.dai 3489 ? 00:00:00 aptd $ sudo kill -9 1760 $ sudo kill -9 3489 $ sudo apt-get install keepass2 E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem. # Method 2: Delete the lock Files sudo rm /var/lib/apt/lists/lock # and sudo rm /var/lib/dpkg/lock
How To Force APT Package Manager To Use IPv4 In Ubuntu 16.04
https://www.ostechnix.com/how-to-force-apt-package-manager-to-use-ipv4-in-ubuntu-16-04/
dpkg error: Package is in a very bad inconsistent state
https://askubuntu.com/questions/148715/how-to-fix-package-is-in-a-very-bad-inconsistent-state-error
The following solution works for me (zramswap-enabler in this example).
# Remove the broken package via the following command: sudo dpkg --remove --force-remove-reinstreq zramswap-enabler # Install the package again: sudo apt-get install zramswap-enabler
Difference between dpkg and aptitude/apt-get/gdebi
- https://askubuntu.com/questions/309113/what-is-the-difference-between-dpkg-and-aptitude-apt-get
- What’s the Difference Between APT and dpkg in Ubuntu? When APT (or its cousin, Apt-get) installs a package, it's actually using dpkg on the back-end to accomplish that. In that way, dpkg acts more as an "under the hood" tool for APT's more user-friendly interface.
apt vs. apt-get
apt vs. apt-get: What’s the Difference on Linux?
Some useful apt commands
- 19 Ubuntu / Debian Linux apt Command Examples
- Linux package management with apt
- Finding software: apt search cockpit
- Package metadata: apt show cockpit
- What package provides a file?: apt-file search qmake-qt5
- What files are included in a package?: apt-file list cockpit
- Removing an application: sudo apt purge apt-file & sudo apt autoremove
deb file
Show deb file information
dpkg-deb -I XXX.deb dpkg-deb -c XXX.deb # list file content
Install a deb file (including dependencies): dpkg command
The dpkg -i command is lower level and has the following advantages: Direct control (you want to handle dependencies manually) and offline installation. On the other hand, the apt install command is higher level and has these advantages: Dependence resolution and repository access.
sudo apt install ./application.deb # OR # dpkg gives more clear about the error message sudo dpkg -i application.deb
Note:
1. Remember to add "./" before the package name when we use the "apt install" command because "apt install" expect a package name or a full path to a deb file ("application.deb" is neither a package name or a full path).
2. However, installing from a .deb file through dpkg does not resolve dependency issues the same way installation through apt will. See here and How to let dpkg Install Dependencies Automatically. So you should run sudo apt-get install -f to fix and install dependencies. After that, run the sudo dpkg -i application.deb again.
sudo apt install -f dep1.deb dep2.deb # NOT apt -f install XXX.deb
3. The advantage of using apt over dpkg is that apt will automatically resolve and install any dependencies required by the .deb package, whereas with dpkg you would have to manually resolve them using sudo apt-get install -f.
4. Another way to install a deb file is using the gdebi tool.
How to install .deb package with double click
Right click a deb file and choose "Software Install".
But if it is an upgrade of an existing software, it can only let you remove it and can't upgrade.
Remove deb packages
See the man page.
dpkg -l | grep 'tcl' sudo dpkg -r tcl8.4 # -r means remove/uninstall sudo dpkg -P tcl8.4 # -P means purge dpkg -l | grep 'tcl' (optional)
gdebi: an improvement over dpkg
sudo apt-get install gdebi-core # wget newPackage.deb # sudo gdebi -n newPackage.deb
deb files caches
See http://askubuntu.com/questions/444240/ubuntu-updates-blocked-apt-get
sudo rm -f /etc/apt/sources.list.d/* # PPA list sudo dpkg -i /var/cache/apt/archives/*.deb sudo dpkg --configure -a
apt-cache
How to Use apt-cache Command in Debian, Ubuntu and Other Linux Distributions
/var/lib/apt/lists
https://unix.stackexchange.com/questions/217369/clear-apt-get-list
List all available packages (from repositories)
apt-cache pkgnames # pkgnames is part of the command
Examples:
$ apt list | wc -l WARNING: apt does not have a stable CLI interface. Use with caution in scripts. 76113 $ apt list --installed | wc -l WARNING: apt does not have a stable CLI interface. Use with caution in scripts. 2816 $ apt-cache pkgnames | wc -l 71223
Show package information and list all versions
Note the <package> does not have to be installed.
apt-cache show <package_name> apt-cache show <package_name> | grep Version
What is the difference of apt show and apt-cache show?
How can I see all versions of a package that are available
We can use the show or madison parameter in apt-cache. For example,
apt-cache show <package_name> | grep Version apt-cache madison <package_name> # wide output, include repository URLs
Show the candidcate version and whether any version is installed
apt-cache policy <package_name>
For example, I don't have apache2 installed.
$ apt-cache policy apache2 apache2: Installed: (none) Candidate: 2.4.41-4ubuntu3.11 Version table: 2.4.41-4ubuntu3.11 500 500 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages 2.4.41-4ubuntu3.10 500 500 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages 2.4.41-4ubuntu3 500 500 http://us.archive.ubuntu.com/ubuntu focal/main amd64 Packages
Check dependencies for specific packages
How to List Dependencies of a Package in Ubuntu
$ apt depends r-base # or apt-cache depends r-base r-base Depends: r-base-core (>= 3.6.3-1bionic) Depends: r-recommended (= 3.6.3-1bionic) Recommends: r-base-html Recommends: r-doc-html Suggests: elpa-ess |Suggests: r-doc-info Suggests: r-doc-pdf $ apt-cache showpkg <package_name>
Show the recommended packages
Consider the example of the "r-base" package,
apt-cache show r-base # OR apt show r-base
Get a list of packages installed by the command
Consider the example of the calling "sudo apt-get build-dep r-base" package,
dpkg --get-selections > installed_packages_before.txt sudo apt-get build-dep r-base dpkg --get-selections > installed_packages_after.txt diff installed_packages_before.txt installed_packages_after.txt > installed_by_build-dep.txt
Checking dependencies and reverse dependencies with apt-rdepends
How to Check Dependencies of a Package in Ubuntu/Debian-based Linux Distributions
$ sudo apt install apt-rdepends $ apt-rdepends -r inxi Reading package lists... Done Building dependency tree Reading state information... Done inxi Reverse Depends: forensics-extra (2.14) forensics-extra Reverse Depends: forensics-full (2.14) forensics-full $ apt-rdepends -r sysbench Reading package lists... Done Building dependency tree Reading state information... Done sysbench Reverse Depends: hardinfo (0.6~alpha~git20211203~focal) hardinfo $ apt-cache depends hardinfo hardinfo Depends: pciutils pciutils:i386 Depends: zlib1g-dev Depends: dmidecode dmidecode:i386 Depends: fwupd Depends: lm-sensors Depends: sysbench Depends: usbutils usbutils:i386 Depends: libc6 Depends: libcairo2 Depends: libgdk-pixbuf2.0-0 Depends: libglib2.0-0 Depends: libgtk-3-0 Depends: libjson-glib-1.0-0 Depends: libpango-1.0-0 Depends: libpangocairo-1.0-0 Depends: libsoup2.4-1 Depends: libx11-6 Suggests: mesa-utils
List racing games package (kind of search packages by key words)
apt-cache search racing game apt-cache search vsftpd
depends, recommends and suggests
How to install suggested packages in apt-get
By default, apt-get installs recommended packages.
Your option --install-suggests adds in the suggested packages and their suggested dependencies.
Note that --install-suggests will be recursive. It may install a lot of packages.
Download debs and then upgrade
sudo apt-get upgrade --download-only sudo apt-get upgrade # sudo apt-get upgrade --no-download
Upgrade a package
apt-get install <package_name> sudo apt --only-upgrade install package_name # It won’t install the given package if it is not already installed
Install specific version of the package
Use the "=" with the package-name and append desired version.
sudo apt-get install vsftpd=2.3.5-3ubuntu1
Remove a package
Linux uninstall package / software using the CLI
sudo apt-get remove <package_name>
To completely remove a package including their configuration files
sudo apt-get purge <package_name> sudo apt-get remove --purge <package_name> # examples sudo apt remove --purge libreoffice sudo apt remove --purge thunderbird
What’s the difference between ‘remove‘ and ‘purge‘ ? 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.
Rollback an apt-get upgrade
http://www.cyberciti.biz/howto/debian-linux/ubuntu-linux-rollback-an-apt-get-upgrade/
Clean up disk space
The clean command is used to free up the disk space by cleaning retrieved .deb files from the local repository.
sudo apt-get clean
Auto clean up apt-get cache
sudo apt-get autoclean
The 'autoclean' command deletes all .deb files from /var/cache/apt/archives to free up disk space.
What is difference between the options "autoclean", "autoremove" and "clean"? From the apt-get man page: autoclean: Like clean, autoclean clears out the local repository of retrieved package files. The difference is that it only removes package files that can no longer be downloaded, and are largely useless. This allows a cache to be maintained over a long period without it growing out of control. The configuration option APT::Clean-Installed will prevent installed packages from being erased if it is set to off.
Download only source code of package
sudo apt-get --download-only source <package_name>
To download and unpack source code of a package
sudo apt-get source <package_name>
To download, unpack and compile a package
sudo apt-get --compile source <package_name>
Download without installing
sudo apt-get download <package_name>
Check change log of package
Note that the change log may not be found.
sudo apt-get changelog <package_name>
Simulate installing packages
$ sudo apt-get -s install packagename $ sudo apt-get -s build-dep packagename $ man apt-get
Generally, it is good to build-dep then install package.
Check broken dependencies
sudo apt-get check
Fix broken packages
sudo apt --fix-missing update sudo apt update sudo apt install -f
Not all updates can be installed: partial upgrade
Not all updates can be installed: partial upgrade, Not all updates can be installed in software updater
$ sudo update-manager $ sudo apt-get install -f
Search a package
- How to Install Zlib on Ubuntu Linux. Use the apt search command
- Using ‘apt search’ and ‘apt show’ Commands to Search and Find Details of Packages in Ubuntu
Search missing package's full name
Use the apt-file command. See this post
At first, install apt-file command and prepare it.
$ sudo apt-get install apt-file $ sudo apt-file update
To find zlib.h,
$ apt-file search zlib.h
It reports too many result. Let’s narrow down.
$ apt-file search /usr/include/zlib.h zlib1g-dev: /usr/include/zlib.h
Now you know zlib.h is in zlib1g-dev package.
$ sudo apt-get install zlib1g-dev
Find package information before installing it
Use "-s" option for simulation. No sudo is necessary.
apt-get -s install PACKAGENAME
The output is too much (include other dependences)
A better way is to use aptitude (which is not installed by default in Ubuntu)
aptitude search <package> -F "%c %p %d %V"
For example,
debian@beaglebone:~/qt-4.8.5/bin$ aptitude search qtcreator -F "%c %p %d %V" p qtcreator lightweight integrated development environme 2.5.0-2 p qtcreator:armel lightweight integrated development environme 2.5.0-2 p qtcreator-dbg debugging symbols for Qt Creator IDE 2.5.0-2 p qtcreator-dbg:armel debugging symbols for Qt Creator IDE 2.5.0-2 p qtcreator-doc documentation for Qt Creator IDE 2.5.0-2
If a package is already installed, we can use the following way to check version number.
apt-show-versions <package>
dpkg Command : View Package Information On Debian/Ubuntu/Mint Systems
dpkg -s r-base
aptitude Command : View Package Information On Debian/Ubuntu/Mint Systems
aptitude show htop
List files in a package
dpkg -L <package_name>
Search installed packages
dpkg -l libgtk* | grep -e '^i' dpkg -l libpng* | grep -e '^i' dpkg -l libjpeg* | grep -e '^i'
To search x-org related packages
udooer@udoo:~$ dpkg -l | grep xserver-xorg | awk '{$1=$3=$4=""; print $0}' # Skip columns 1,3,4 imx-xserver-xorg-extension-viv-9t6-hdmi Freescale Xorg server driver extension for HDMI performance imx-xserver-xorg-video-viv-9t6 Xorg server driver for imx6, vivante xserver-xorg X.Org X server xserver-xorg-core Xorg X server - core server xserver-xorg-dev Xorg X server - development files xserver-xorg-input-all X.Org X server -- input driver metapackage xserver-xorg-input-evdev X.Org X server -- evdev input driver xserver-xorg-input-synaptics Synaptics TouchPad driver for X.Org server xserver-xorg-input-wacom X.Org X server -- Wacom input driver xserver-xorg-video-all X.Org X server -- output driver metapackage xserver-xorg-video-fbdev X.Org X server -- fbdev display driver xserver-xorg-video-modesetting X.Org X server -- Generic modesetting driver xserver-xorg-video-omap X.Org X server -- OMAP display driver xserver-xorg-video-vesa X.Org X server -- VESA display driver
List of installed packages
apt list --installed | wc -l # Or using [https://wiki.debian.org/ListInstalledPackages dpkg-query] utility. dpkg-query -l dpkg --get-selections
Show A History Of Installed, Upgraded Or Removed Packages
https://www.linuxuprising.com/2019/01/how-to-show-history-of-installed.html?m=1
# recently installed packages, their version number grep "install " /var/log/dpkg.log # recently upgraded packages, as well as the old and new package version grep "upgrade " /var/log/dpkg.log # recently removed packages grep "remove " /var/log/dpkg.log
/var/log/dpkg.log contains the package install, update and remove history for the current month. For the previous month, read the /var/log/dpkg.log.1 log file. Want to go back even more in the dpkg history? Use zgrep instead of grep, and read /var/log/dpkg.log.2.gz, /var/log/dpkg.log.3.gz, /var/log/dpkg.log.4.gz and so on (up to 12 months),
grep "install " /var/log/dpkg.log.1 zgrep "upgrade " /var/log/dpkg.log.2.gz
Install a list of packages
How to get list of installed packages on Ubuntu / Debian Linux
Suppose we want to install all packages currently installed on server 1 onto server 2, we can do that by
# server 1 dpkg --get-selections | grep -v deinstall > mylist.txt # server 2 sudo dpkg --set-selections < mylist.txt
Show (sort) package size
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n
Check if a library is installed or not (ldconfig)
Use ldconfig -p | grep LIBNAME ('-p' is used to print the list stored in the current cache). For example, to check if libxml is installed or not, then following code will output the number of matches if it was found.
EXIST=`ldconfig -p | grep libxml | wc -l` if [ $EXIST -ne 0 ]; then echo $EXIST; fi
The following code will search "libQt" and the library version will be shown in the file name.
ldconfig -p | grep libQt # On Ubuntu 14.04, 16.04: # libQtGui.so.4 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libQtGui.so.4 # On Ubuntu 17.10, 18.04: # libQt5Gui.so.5 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
To install libQtGui.so.4 in Ubuntu 18.04, run the command
sudo apt-get install libqtgui4
See also the ldd command to print all dynamic dependencies of an executable program.
How to uninstall software
http://www.howtogeek.com/229699/how-to-uninstall-software-using-the-command-line-in-linux/
Upgrade software packages
Upgrade all the currently installed software packages on the system
sudo apt-get upgrade
If you want to upgrade, unconcerned of whether software packages will be added or removed to fulfill dependencies, use
sudo apt-get dist-upgrade
List of available (uninstalled) packages
aptitude -F "%p" search "?not(?installed)"
Check Change Log of Package
sudo apt-get changelog PKGNAME
Clean up/remove packages
PPA
A Guide to Using PPA Repositiories in Ubuntu
unmet dependencies when trying to install okular
This happened on Ubuntu 20.04
The following packages have unmet dependencies: okular : Depends: libokular5core9 (= 4:19.12.3-2ubuntu1) but it is not going to be installed Depends: phonon4qt5 but it is not going to be installed Recommends: okular-extra-backends but it is not going to be installed E: Unable to correct problems, you have held broken packages.
GNOME software can install Okular without any issue.
unmet dependencies after adding a PPA & apt --fix-broken
http://askubuntu.com/questions/140246/how-do-i-resolve-unmet-dependencies-after-adding-a-ppa
$ sudo apt-get install libgl1-mesa.dev Reading package lists... Done Building dependency tree Reading state information... Done Note, selecting 'libgl1-mesa-dev-lts-quantal' for regex 'libgl1-mesa.dev' Note, selecting 'libgl1-mesa-dev' for regex 'libgl1-mesa.dev' Note, selecting 'libgl1-mesa-dev-lts-saucy' for regex 'libgl1-mesa.dev' Note, selecting 'libgl1-mesa-dev-lts-trusty' for regex 'libgl1-mesa.dev' Note, selecting 'libgl1-mesa-dev-lts-utopic' for regex 'libgl1-mesa.dev' Note, selecting 'libgl1-mesa-dev-lts-vivid' for regex 'libgl1-mesa.dev' Note, selecting 'libgl1-mesa-dev-lts-raring' for regex 'libgl1-mesa.dev' libgl1-mesa-dev is already the newest version. libgl1-mesa-dev set to manually installed. Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: libgl1-mesa-dev : Conflicts: libgl-dev Conflicts: libgl1-mesa-dri-dev libgl1-mesa-dev-lts-utopic : Depends: mesa-common-dev-lts-utopic (= 10.3.2-0ubuntu1~trusty2) but it is not going to be installed Depends: libgl1-mesa-glx-lts-utopic (= 10.3.2-0ubuntu1~trusty2) but it is not going to be installed Conflicts: libgl-dev Conflicts: libgl1-mesa-dev Conflicts: libgl1-mesa-dri-dev libgl1-mesa-dev-lts-vivid : Depends: mesa-common-dev-lts-vivid (= 10.5.9-2ubuntu1~trusty2) but it is not going to be installed Depends: libgl1-mesa-glx-lts-vivid (= 10.5.9-2ubuntu1~trusty2) but it is not going to be installed Conflicts: libgl-dev Conflicts: libgl1-mesa-dev Conflicts: libgl1-mesa-dri-dev Conflicts: xorg-renamed-package-lts-utopic E: Unable to correct problems, you have held broken packages.
Unmet dependencies when trying to install r-base (Works on Ubuntu 16.04).
sudo apt --fix-broken install sudo apt-get update sudo apt-get upgrade
Another case: I installed R 4.0.0 using sudo add-apt-repository --yes ”ppa:edd/r-4.0” by following this, then I remove and install the official one. The above 3 commands does not help. (Ubuntu 18.04).
The following packages have unmet dependencies: r-base : Depends: r-recommended (= 4.0.0-1.1804.0) but 4.0.0-1.1804.1 is to be installed E: Unable to correct problems, you have held broken packages.
The solution is to use Aptitude command. See How to Fix Unmet Dependencies Error on Ubuntu
$ sudo aptitude install r-base 9:55:45 The following NEW packages will be installed: r-base{b} 0 packages upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 43.3 kB of archives. After unpacking 62.5 kB will be used. The following packages have unmet dependencies: r-base : Depends: r-recommended (= 4.0.0-1.1804.0) but 4.0.0-1.1804.1 is installed The following actions will resolve these dependencies: Keep the following packages at their current version: 1) r-base [Not Installed] Accept this solution? [Y/n/q/?] n The following actions will resolve these dependencies: Downgrade the following packages: 1) r-recommended [4.0.0-1.1804.1 (now) -> 4.0.0-1.1804.0 (bionic-cran40)] Accept this solution? [Y/n/q/?] The following packages will be DOWNGRADED: r-recommended The following NEW packages will be installed: r-base 0 packages upgraded, 1 newly installed, 1 downgraded, 0 to remove and 0 not upgraded.
Fix broken Ubuntu
How To Fix Broken Ubuntu OS Without Reinstalling It
$ sudo rm /var/lib/apt/lists/lock $ sudo rm /var/lib/dpkg/lock $ sudo rm /var/lib/dpkg/lock-frontend $ sudo dpkg --configure -a $ sudo apt clean $ sudo apt update --fix-missing $ sudo apt install -f $ sudo dpkg --configure -a $ sudo apt upgrade $ sudo apt dist-upgrade $ sudo reboot