1

How to reinstall APT package

Hi all.

to trouble shoot my old issue i have removed apt package.now new issue is as follows. to refer my previous issue kindly refer this link :

SyntaxError while setting up python3-aptdaemon

$sudo apt-get update
sudo: apt-get: command not found

ariel@ariel:~$ sudo dpkg -install apt
dpkg: error: unknown option -n

Type dpkg --help for help about installing and deinstalling packages [*];
Use 'apt' or 'aptitude' for user-friendly package management;
Type dpkg -Dhelp for a list of dpkg debug flag values;
Type dpkg --force-help for a list of forcing options;
Type dpkg-deb --help for help about manipulating *.deb files;

Options marked [*] produce a lot of output - pipe it through 'less' or 'more' !

ariel@ariel:~$ sudo dpkg -install apt-get
dpkg: error: unknown option -n

Type dpkg --help for help about installing and deinstalling packages [*];
Use 'apt' or 'aptitude' for user-friendly package management;
Type dpkg -Dhelp for a list of dpkg debug flag values;
Type dpkg --force-help for a list of forcing options;
Type dpkg-deb --help for help about manipulating *.deb files;

Options marked [*] produce a lot of output - pipe it through 'less' or 'more' !

ariel@ariel:~$ sudo dpkg -i *

dpkg: error: archive 'Desktop' is not a regular file

ariel@ariel:~$ sudo dpkg -i *

dpkg: error: archive 'Desktop' is not a regular file

ariel@ariel:~$ wget http://security.ubuntu.com/ubuntu/pool/main/a/apt/apt_1.0.1ubuntu2.17_amd64.deb -O apt.deb
--2019-08-11 21:04:37--  http://security.ubuntu.com/ubuntu/pool/main/a/apt/apt_1.0.1ubuntu2.17_amd64.deb
Resolving security.ubuntu.com (security.ubuntu.com)... 91.189.88.24, 91.189.91.26, 91.189.91.23, ...
Connecting to security.ubuntu.com (security.ubuntu.com)|91.189.88.24|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2019-08-11 21:04:38 ERROR 404: Not Found.

ariel@ariel:~$ sudo dpkg -i apt.deb

dpkg-deb: error: 'apt.deb' is not a Debian format archive

dpkg: error processing archive apt.deb (--install):
 dpkg-deb --control subprocess returned error exit status 2

Errors were encountered while processing:
 apt.deb

ariel@ariel:~$ pkexec dpkg -i apt.deb

dpkg: error: cannot access archive 'apt.deb': No such file or directory

ariel@ariel:~$ 

after 1st solution of N0rbert:

$ sudo apt-get update

apt-get: error while loading shared libraries: libapt-pkg.so.5.0: cannot open shared object file: No such file or directory

ariel@ariel:~/Downloads$ sudo apt install --reinstall apt-utils ubuntu-minimal ub

apt: error while loading shared libraries: libapt-pkg.so.5.0: cannot open shared object file: No such file or directory

ariel@ariel:~/Downloads$ sudo apt update

apt: error while loading shared libraries: libapt-pkg.so.5.0: cannot open shared object file: No such file or directory

after 2nd solution :

$lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.2 LTS
Release:    18.04
Codename:   bionic

thanks guys it did worked after installation of library file but giving two more error. but i am not understanding it and its importance as well.kindly suggest if you are aware. is any solution for these new error ??

$ wget http://mirrors.kernel.org/ubuntu/pool/main/a/apt/libapt-pkg5.0_1.6.11_amd64.deb

--2019-08-11 23:37:16--  http://mirrors.kernel.org/ubuntu/pool/main/a/apt/libapt-pkg5.0_1.6.11_amd64.deb
Resolving mirrors.kernel.org (mirrors.kernel.org)... 198.145.21.9, 2001:19d0:306:6:0:1994:3:14
Connecting to mirrors.kernel.org (mirrors.kernel.org)|198.145.21.9|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://mirrors.edge.kernel.org/ubuntu/pool/main/a/apt/libapt-pkg5.0_1.6.11_amd64.deb [following]
--2019-08-11 23:37:17--  http://mirrors.edge.kernel.org/ubuntu/pool/main/a/apt/libapt-pkg5.0_1.6.11_amd64.deb
Resolving mirrors.edge.kernel.org (mirrors.edge.kernel.org)... 147.75.95.133, 2604:1380:3000:1500::1
Connecting to mirrors.edge.kernel.org (mirrors.edge.kernel.org)|147.75.95.133|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 806284 (787K) [application/octet-stream]
Saving to: ‘libapt-pkg5.0_1.6.11_amd64.deb’

libapt-pkg5.0_1.6.11_amd64.deb      100%[=================================================================>] 787.39K  20.3KB/s    in 43s     

2019-08-11 23:38:01 (18.4 KB/s) - ‘libapt-pkg5.0_1.6.11_amd64.deb’ saved [806284/806284]

$ sudo dpkg -i libapt-pkg5.0_1.6.11_amd64.deb

Selecting previously unselected package libapt-pkg5.0:amd64.
(Reading database ... 182918 files and directories currently installed.)
Preparing to unpack libapt-pkg5.0_1.6.11_amd64.deb ...
Unpacking libapt-pkg5.0:amd64 (1.6.11) ...
Setting up libapt-pkg5.0:amd64 (1.6.11) ...
Processing triggers for libc-bin (2.28-10) ...

$ sudo apt update

Hit:1 http://in.archive.ubuntu.com/ubuntu bionic InRelease
Get:2 http://in.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]                                                                 
Get:3 http://in.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]                                                               
Hit:4 http://ppa.launchpad.net/diesch/testing/ubuntu bionic InRelease                                    
Get:5 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 DEP-11 Metadata [282 kB]        
Get:6 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]                                     
Ign:7 http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu bionic InRelease                                                      
Get:8 http://in.archive.ubuntu.com/ubuntu bionic-updates/main DEP-11 48x48 Icons [66.7 kB]                                                   
Get:9 http://in.archive.ubuntu.com/ubuntu bionic-updates/main DEP-11 64x64 Icons [138 kB]                                                    
Get:10 http://in.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 DEP-11 Metadata [252 kB]                                            
Err:11 http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu bionic Release                                                       
  404  Not Found [IP: 91.189.95.83 80]
Get:12 http://in.archive.ubuntu.com/ubuntu bionic-updates/universe DEP-11 48x48 Icons [197 kB]    
Get:13 http://in.archive.ubuntu.com/ubuntu bionic-updates/universe DEP-11 64x64 Icons [438 kB]         
Get:14 http://in.archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 DEP-11 Metadata [2,464 B]
Get:15 http://in.archive.ubuntu.com/ubuntu bionic-backports/universe amd64 DEP-11 Metadata [7,700 B]
Get:16 http://security.ubuntu.com/ubuntu bionic-security/main amd64 DEP-11 Metadata [22.7 kB] 
Get:17 http://security.ubuntu.com/ubuntu bionic-security/main DEP-11 48x48 Icons [10.4 kB]                             
Get:18 http://security.ubuntu.com/ubuntu bionic-security/main DEP-11 64x64 Icons [31.7 kB]
Get:19 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 DEP-11 Metadata [42.1 kB]
Get:20 http://security.ubuntu.com/ubuntu bionic-security/universe DEP-11 48x48 Icons [16.4 kB]
Get:21 http://security.ubuntu.com/ubuntu bionic-security/universe DEP-11 64x64 Icons [116 kB]
Get:22 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 DEP-11 Metadata [2,464 B]

(appstreamcli:6798): GLib-CRITICAL **: 23:39:19.478: g_atomic_ref_count_dec: assertion 'g_atomic_int_get (arc) > 0' failed
Reading package lists... Done
E: The repository 'http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu bionic Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

4th solution to fix last error :

$ sudo add-apt-repository -r ppa:ubuntu-wine/ppa

sudo: add-apt-repository: command not found

5th solution :

$ sudo apt-get install software-properties-common

Reading package lists... Done
Building dependency tree       
Reading state information... Done
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:
 software-properties-common : Depends: python3-software-properties (= 0.96.24.32.9) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

$ sudo add-apt-repository -r ppa:ubuntu-wine/ppa

sudo: add-apt-repository: command not found

Solution 6th :

i have run command $ sudo apt-get upgrade which executed successfully without returning an error. then i have run below command which returns same error.hence i have restart system and again run below command which is returning same error.

$ sudo apt-get install software-properties-common

Reading package lists... Done
Building dependency tree       
Reading state information... Done
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:
 software-properties-common : Depends: python3-software-properties (= 0.96.24.32.9) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

$ sudo add-apt-repository -r ppa:ubuntu-wine/ppa

sudo: add-apt-repository: command not found

as it is showing kind of dependancy for Python 3 software properties, i suspect that it is related to issue for which i have raised question earlier (link of syntaxerror while setting up python3-aptdeamon) is it ??


7th solution :

after running command in comment box output is as follows :

$ grep -r ubuntu-wine /etc/apt --include="*.list"
/etc/apt/sources.list.d/ubuntu-wine-ubuntu-ppa-bionic.list:deb http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu bionic main
/etc/apt/sources.list.d/ubuntu-wine-ubuntu-ppa-bionic.list:# deb-src http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu bionic main
/etc/apt/sources.list.d/ubuntu-wine-ubuntu-ppa-bionic.list:# deb-src http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu bionic main

solution no 8 :

without restarting sudo apt-get dist-upgrade executed sucessfully. but sudo apt-get update returns error below.

$ sudo apt-get update

Hit:1 http://in.archive.ubuntu.com/ubuntu bionic InRelease
Get:2 http://in.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]                                                                 
Hit:3 http://ppa.launchpad.net/diesch/testing/ubuntu bionic InRelease                                                                        
Get:4 http://in.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Get:5 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]                                                         
Ign:6 http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu bionic InRelease                              
Get:7 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 DEP-11 Metadata [282 kB]
Get:8 http://in.archive.ubuntu.com/ubuntu bionic-updates/main DEP-11 48x48 Icons [66.7 kB]                                                   
Get:9 http://in.archive.ubuntu.com/ubuntu bionic-updates/main DEP-11 64x64 Icons [134 kB]                                   
Err:10 http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu bionic Release                                                      
  404  Not Found [IP: 91.189.95.83 80]
Get:11 http://in.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 DEP-11 Metadata [252 kB]                          
Get:12 http://in.archive.ubuntu.com/ubuntu bionic-updates/universe DEP-11 48x48 Icons [195 kB]        
Get:13 http://in.archive.ubuntu.com/ubuntu bionic-updates/universe DEP-11 64x64 Icons [437 kB]       
Get:14 http://in.archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 DEP-11 Metadata [2,468 B]
Get:15 http://in.archive.ubuntu.com/ubuntu bionic-backports/universe amd64 DEP-11 Metadata [7,712 B]

(appstreamcli:3027): GLib-CRITICAL **: 00:51:25.846: g_atomic_ref_count_dec: assertion 'g_atomic_int_get (arc) > 0' failed
Reading package lists... Done
E: The repository 'http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu bionic Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

$ sudo apt-get dist-upgrade

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages were automatically installed and are no longer required:
  docbook-xml librarian0 rarian-compat sgml-base sgml-data xml-core
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  linux-headers-5.0.0-23 linux-headers-5.0.0-23-generic linux-image-5.0.0-23-generic linux-modules-5.0.0-23-generic
  linux-modules-extra-5.0.0-23-generic
The following packages will be upgraded:
  linux-generic-hwe-18.04 linux-headers-generic-hwe-18.04 linux-image-generic-hwe-18.04
3 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 66.9 MB of archives.
After this operation, 330 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-modules-5.0.0-23-generic amd64 5.0.0-23.24~18.04.1 [13.6 MB]
Get:2 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-image-5.0.0-23-generic amd64 5.0.0-23.24~18.04.1 [8,356 kB]        
Get:3 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-modules-extra-5.0.0-23-generic amd64 5.0.0-23.24~18.04.1 [33.1 MB] 
Get:4 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-generic-hwe-18.04 amd64 5.0.0.23.80 [1,884 B]                      
Get:5 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-image-generic-hwe-18.04 amd64 5.0.0.23.80 [2,564 B]                
Get:6 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-headers-5.0.0-23 all 5.0.0-23.24~18.04.1 [10.7 MB]                 
Get:7 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-headers-5.0.0-23-generic amd64 5.0.0-23.24~18.04.1 [1,135 kB]      
Get:8 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-headers-generic-hwe-18.04 amd64 5.0.0.23.80 [2,524 B]              
Fetched 66.9 MB in 55s (1,214 kB/s)                                                                                                          
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package linux-modules-5.0.0-23-generic.
(Reading database ... 182970 files and directories currently installed.)
Preparing to unpack .../0-linux-modules-5.0.0-23-generic_5.0.0-23.24~18.04.1_amd64.deb ...
Unpacking linux-modules-5.0.0-23-generic (5.0.0-23.24~18.04.1) ...
Selecting previously unselected package linux-image-5.0.0-23-generic.
Preparing to unpack .../1-linux-image-5.0.0-23-generic_5.0.0-23.24~18.04.1_amd64.deb ...
Unpacking linux-image-5.0.0-23-generic (5.0.0-23.24~18.04.1) ...
Selecting previously unselected package linux-modules-extra-5.0.0-23-generic.
Preparing to unpack .../2-linux-modules-extra-5.0.0-23-generic_5.0.0-23.24~18.04.1_amd64.deb ...
Unpacking linux-modules-extra-5.0.0-23-generic (5.0.0-23.24~18.04.1) ...
Preparing to unpack .../3-linux-generic-hwe-18.04_5.0.0.23.80_amd64.deb ...
Unpacking linux-generic-hwe-18.04 (5.0.0.23.80) over (4.18.0.25.74) ...
Preparing to unpack .../4-linux-image-generic-hwe-18.04_5.0.0.23.80_amd64.deb ...
Unpacking linux-image-generic-hwe-18.04 (5.0.0.23.80) over (4.18.0.25.74) ...
Selecting previously unselected package linux-headers-5.0.0-23.
Preparing to unpack .../5-linux-headers-5.0.0-23_5.0.0-23.24~18.04.1_all.deb ...
Unpacking linux-headers-5.0.0-23 (5.0.0-23.24~18.04.1) ...
Selecting previously unselected package linux-headers-5.0.0-23-generic.
Preparing to unpack .../6-linux-headers-5.0.0-23-generic_5.0.0-23.24~18.04.1_amd64.deb ...
Unpacking linux-headers-5.0.0-23-generic (5.0.0-23.24~18.04.1) ...
Preparing to unpack .../7-linux-headers-generic-hwe-18.04_5.0.0.23.80_amd64.deb ...
Unpacking linux-headers-generic-hwe-18.04 (5.0.0.23.80) over (4.18.0.25.74) ...
Setting up linux-headers-5.0.0-23 (5.0.0-23.24~18.04.1) ...
Setting up linux-headers-5.0.0-23-generic (5.0.0-23.24~18.04.1) ...
Setting up linux-modules-5.0.0-23-generic (5.0.0-23.24~18.04.1) ...
Setting up linux-image-5.0.0-23-generic (5.0.0-23.24~18.04.1) ...
I: /vmlinuz.old is now a symlink to boot/vmlinuz-4.18.0-25-generic
I: /initrd.img.old is now a symlink to boot/initrd.img-4.18.0-25-generic
I: /vmlinuz is now a symlink to boot/vmlinuz-5.0.0-23-generic
I: /initrd.img is now a symlink to boot/initrd.img-5.0.0-23-generic
Setting up linux-headers-generic-hwe-18.04 (5.0.0.23.80) ...
Setting up linux-modules-extra-5.0.0-23-generic (5.0.0-23.24~18.04.1) ...
Setting up linux-image-generic-hwe-18.04 (5.0.0.23.80) ...
Setting up linux-generic-hwe-18.04 (5.0.0.23.80) ...
Processing triggers for linux-image-5.0.0-23-generic (5.0.0-23.24~18.04.1) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.0.0-23-generic
/etc/kernel/postinst.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.0.0-23-generic
Found initrd image: /boot/initrd.img-5.0.0-23-generic
Found linux image: /boot/vmlinuz-4.18.0-25-generic
Found initrd image: /boot/initrd.img-4.18.0-25-generic
Found linux image: /boot/vmlinuz-4.18.0-21-generic
Found initrd image: /boot/initrd.img-4.18.0-21-generic
Adding boot menu entry for EFI firmware configuration
done

solution no 9:

wine ppa removed sucessfully.

$ sudo rm -v /etc/apt/sources.list.d/ubuntu-wine-ubuntu-ppa-bionic.list
removed '/etc/apt/sources.list.d/ubuntu-wine-ubuntu-ppa-bionic.list'

solution no 10: sudo apt update executed succesfully without returning an error.

$sudo apt update

Hit:1 http://in.archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://in.archive.ubuntu.com/ubuntu bionic-updates InRelease                                                                           
Hit:3 http://in.archive.ubuntu.com/ubuntu bionic-backports InRelease                                                                         
Hit:4 http://ppa.launchpad.net/diesch/testing/ubuntu bionic InRelease                                                           
Get:5 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]                            
Fetched 88.7 kB in 2s (40.2 kB/s)                             
Reading package lists... Done
Building dependency tree       
Reading state information... Done
All packages are up to date.
Ariel
  • 37
  • $ sudo apt-get update apt-get: error while loading shared libraries: libapt-pkg.so.5.0: cannot open shared object file: No such file or directory ariel@ariel:~/Downloads$ sudo apt install --reinstall apt-utils ubuntu-minimal ub apt: error while loading shared libraries: libapt-pkg.so.5.0: cannot open shared object file: No such file or directory ariel@ariel:~/Downloads$ sudo apt update apt: error while loading shared libraries: libapt-pkg.so.5.0: cannot open shared object file: No such file or directory – Ariel Aug 11 '19 at 17:53
  • do i have to update/ install library files separately ?? – Ariel Aug 11 '19 at 17:59

1 Answers1

4

Please ensure that your device is connected to the internet and download apt/apt-get's package manually and install it on the low-level:

cd ~/Downloads
wget http://mirrors.kernel.org/ubuntu/pool/main/a/apt/apt_1.6.11_amd64.deb
sudo dpkg -i apt_1.6.11_amd64.deb

reinstall package with libapt-pkg.so.5.0 library:

wget http://mirrors.kernel.org/ubuntu/pool/main/a/apt/libapt-pkg5.0_1.6.11_amd64.deb
sudo dpkg -i libapt-pkg5.0_1.6.11_amd64.deb

and then use APT as usual:

sudo apt-get update
sudo apt-get upgrade

To fix last error with Wine PPA simply remove it with:

sudo rm /etc/apt/sources.list.d/ubuntu-wine-ubuntu-ppa-bionic.list

and then install all new dependencies with

sudo apt-get update
sudo apt-get dist-upgrade
N0rbert
  • 99,918
  • Stirred with a root stick. – waltinator Aug 11 '19 at 17:14
  • @https://askubuntu.com/users/66509/n0rbert i have followed steps you have mention and 'man apt' is working as well but for 'sudo apt-get update' error is apt-get: error while loading shared libraries: libapt-pkg.so.5.0: cannot open shared object file: No such file or directory kindly suggest – Ariel Aug 11 '19 at 17:46
  • hi norbert thank you so much.its working now. but after updatating apt i found two more error. does those release files really matters in ubuntu. what is importance of those release file. i have updated ques after installing library filesin details. but suggest on errors please. E: The repository 'http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu bionic Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. – Ariel Aug 11 '19 at 18:21
  • $ sudo add-apt-repository -r ppa:ubuntu-wine/ppa sudo: add-apt-repository: command not found – Ariel Aug 11 '19 at 18:28
  • does it mean that my all packages are broken ?? – Ariel Aug 11 '19 at 18:35
  • is it realated to python3-aptdemon which i have removed ?? – Ariel Aug 11 '19 at 19:11
  • @norbert please check – Ariel Aug 11 '19 at 19:18
  • sudo apt-get update its returning with same error .but 'sudo apt-get dist-upgrade 'but its is executed successfully. does it required restart ?? – Ariel Aug 11 '19 at 19:25
  • thank you so much Norbert for your help. there are some installation which i have to do tomorrow. and i am sure i will face some new issues.thank you for new knowledge. have a great day !!!!! – Ariel Aug 11 '19 at 19:43
  • OK. I think you may remove your comments to keep discussion clear :) Good luck! – N0rbert Aug 11 '19 at 19:44