28
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
  apt apt-transport-https apt-utils dpkg libapt-inst2.0 libapt-pkg5.0 ntpdate
  oracle-java8-installer oracle-java8-set-default thermald
10 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/4,389 kB of archives.
After this operation, 8,192 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Preconfiguring packages ...
dpkg: unrecoverable fatal error, aborting:
 files list file for package 'linux-generic' is missing final newline
E: Sub-process /usr/bin/dpkg returned an error code (2)

I already tried the usual stuff like:

 sudo dpkg --configure -a 
 sudo apt-get -f install
 sudo apt-get clean
 sudo apt-get update && sudo apt-get upgrade

Any help, thanks!

cat -net /var/lib/dpkg/info/linux-generic.list
     1  ^LbM-BM-^FRq^MU^Evalueq^NK^HubU^Mcertificationq^ONU^Hoverviewq^PNU$
     2  updated_atq^QNU^Vavailable_translationsq^RNU^Dyearq^SMM-CM-^]^GU^Fimagesq^TNU^Bidq^UNU^Ipaused_atq^VNU^Eindex
pa4080
  • 29,351
  • 10
  • 85
  • 161
Johnny Wong
  • 377
  • 1
  • 3
  • 6
  • Please [edit] your question to include the output of `cat -net /var/lib/dpkg/info/linux-generic.list` – steeldriver Apr 27 '17 at 23:40
  • I tried copying the linux-generic.list from a good ubuntu machine and it still doesn't work. – Johnny Wong May 07 '17 at 18:41
  • Copied how exactly? the `cat -net` output you posted earlier appears to show a mess of Windows control characters (`CR` endings and byte order mark) - did you use a word processing program (Word / LibreOffice) by any chance? – steeldriver May 07 '17 at 18:44
  • the corrupted linux-generic.list was output was copied from putty I used scp to copy from a working ubuntu machine to the corrupted one, replacing the bad one – Johnny Wong May 07 '17 at 19:36

5 Answers5

30

I had similar issues with the following error:

dpkg: unrecoverable fatal error, aborting:
 files list file for package 'libboost-regex1.55.0:armhf' is missing final newline
E: Sub-process /usr/bin/dpkg returned an error code (2)

However, the folder /var/lib/dpkg/info/linux didn't exist on my system, as in previous post. (I was running Raspbian on a Raspberry pi 3)

I moved the following files:

/var/lib/dpkg/info/libboost-regex1.55.0:armhf.postrm
/var/lib/dpkg/info/libboost-regex1.55.0:armhf.list

Then ran:

sudo dpkg --configure -a
sudo apt update
sudo apt upgrade

It fixed the problem for me.

Leendert
  • 409
  • 4
  • 4
  • 3
    For this particular question, you would run: `sudo rm /var/lib/dpkg/info/linux-generic.list` and then you might need to reinstall the package: `sudo apt install --reinstall linux-generic` – mchid Nov 10 '19 at 17:38
  • 3
    Thanks that worked. BUT I had to do a `sudo apt-get install --reinstall ` as the final step – Wavesailor Nov 20 '19 at 16:28
  • Worked for me with a the aforementioned reinstallation. Otherwise, throws "dpkg: warning: files list file for package 'PACKAGENAME' missing; assuming package has no files currently installed" – M1GEO Jan 08 '21 at 16:21
8

I finally had some time to fix this on my own. For future reference

I moved all the linux* files to somewhere else. ex: ~/ (home) sudo mv /var/lib/dpkg/info/linux* ./

sudo dpkg --configure -a
sudo apt update
sudo apt upgrade

That fixed it

Johnny Wong
  • 377
  • 1
  • 3
  • 6
  • 4
    Did not work for me. It did add extra errors: `dpkg: warning: files list file for package 'linux-base' missing; assuming package has no files currently installed dpkg: warning: files list file for package 'linux-libc-dev:armhf' missing; assuming package has no files currently installed` – Qwertie Feb 19 '19 at 12:34
7

Firstly you have to remove that missing file

sudo rm /var/lib/dpkg/info/linux-generic.list 

Now you can again reinstall it

sudo apt-get install linux-generic --reinstall 
Ankit Kumar
  • 79
  • 1
  • 2
  • Don't be afraid! I had an issue with `nginx` and after removing the file I had the same issue with `'perl-openssl-defaults:arm64`. So I also removed this file and then `apt install nginx --reinstall` successfully ran! BTW: The files returned some gibberisch upon `cat`. Either my SD card is failing or there was a problem when I removed some packages. – bomben Jul 23 '22 at 09:38
2

I had a very similar issue and resolved it a different way, so I thought I'd share what I did. While attempting a sudo apt upgrade I received the following dpkg error:

dpkg: unrecoverable fatal error, aborting:
 files list file for package 'python3-xdg' is missing final newline
E: Sub-process /usr/bin/dpkg returned an error code (2)

I found python3-xdg.list in the /var/lib/dpkg/info/ directory and ran cat on the file. What printed out was something like this, with the command prompt immediately following the contents:

user@device:/var/lib/dpkg/info$ cat python3-xdg.list
sEDUsEDUsEDUuser@device:/var/lib/dpkg/info$

I thought I'd try editing the file, giving it the missing final newline, so printing the file would then display:

user@device:/var/lib/dpkg/info$ cat python3-xdg.list
sEDUsEDUsEDU
user@device:/var/lib/dpkg/info$

After this I had no more issues.

1

I had this issue:

dpkg: unrecoverable fatal error, aborting:
 files list file for package 'rockchip-fstab' is missing final newline
E: Sub-process /usr/bin/dpkg returned an error code (2)

sudo dpkg --configure -a also did not work for me.

So, I had to edit by vim /var/lib/dpkg/info/rockchip-fstab.list as:

/. from V\H

Which fixed the issue.

Rakib Fiha
  • 266
  • 1
  • 11