I have problem with command using apt-get install in linux. what is worse is that fixing command(sudo dpkg --configure -a) doesn't work either. I had 3 different approach to solve this.
clay@4763e88da2a1:~/userdata/BeatlikeMichael$ sudo apt-get install locales
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
clay@4763e88da2a1:~/userdata/BeatlikeMichael$ sudo dpkg --configure -a
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
Setting up openssh-server (1:8.2p1-4ubuntu0.5) ...
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
invoke-rc.d: could not determine current runlevel
* Restarting OpenBSD Secure Shell server sshd
deleting elements in following folders didn't help me
clay@4763e88da2a1:~$ sudo rm /var/lib/dpkg/lock-frontend
clay@4763e88da2a1:~$ sudo rm /var/lib/dpkg/lock
clay@4763e88da2a1:~$ sudo rm -rf /var/lib/dpkg/updates/*
clay@4763e88da2a1:~$ sudo dpkg --configure -a
clay@4763e88da2a1:~/userdata/BeatlikeMichael$ locale
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
I see. If you cannot install the locales package with sudo apt-get install locales, then you may need to try a different approach. You could try manually downloading the package from the Ubuntu package archives and installing it using dpkg. Here are the steps you can follow:
sudo dpkg -i locales_*.deb
to install the package. If dpkg reports any unmet dependencies, you can try to resolve them by running sudo apt-get install -f to install any missing packages.I installed locales and set my locale with english but it didn't help me. So I tried to install dialog which could be a key to solve "sudo dpkg --configure -a". But it didn't work either.
clay@4763e88da2a1:~/userdata/BeatlikeMichael$ sudo dpkg --configure -a
Setting up openssh-server (1:8.2p1-4ubuntu0.5) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline
invoke-rc.d: could not determine current runlevel
* Restarting OpenBSD Secure Shell server sshd
sudo dpkg --remove openssh-server
clay@4763e88da2a1:~/userdata/BeatlikeMichael$ dpkg -l | grep openssh-server
rF openssh-server 1:8.2p1-4ubuntu0.5 amd64 secure shell (SSH) server, for secure access from remote machines
The status "rF" indicates that the package is marked for removal, but there are still files associated with it that have been marked for purging.
sudo dpkg --remove --force-remove-reinstreq openssh-server
sudo dpkg -P openssh-server
clay@4763e88da2a1:~/userdata/BeatlikeMichael$ dpkg -l | grep openssh-server
pF openssh-server 1:8.2p1-4ubuntu0.5 amd64 secure shell (SSH) server, for secure access from remote machines
This command will remove the package openssh-server forcefully even if it is marked for reinstallation.
The "-P" option will remove the package, as well as its configuration files, which may help resolve the issue.
after I removed openssh-server, sudo apt-get install command started to work. But I don't understand the reason.