Can't remove package on Raspberry Pi - File name too long
When I try to remove linux-raspi-headers-5.4.0-1032
to upgrade it, dpkg
gives a weird error about a file name being too long:
(Reading database ... 237046 files and directories currently installed.)
Removing linux-raspi-headers-5.4.0-1032 (5.4.0-1032.35) ...
dpkg: error processing package linux-raspi-headers-5.4.0-1032 (--purge):
unable to securely remove '/usr/src/linux-raspi-headers-5.4.0-1032/arch/arm/include/asm/mach/p��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������': File name too long
Errors were encountered while processing:
linux-raspi-headers-5.4.0-1032
How do I get past this?
Big picture here is first show inode of file we wish to delete then specify that inode when we run the delete command
sudo -i # become root to remove root owned file
# get into dir of file we wish to delete
cd /usr/src/linux-raspi-headers-5.4.0-1032/arch/arm/include/asm/mach/
ls -la -i # parm -i says to show inode values
now look at output of above to identify inode value of chosen file which is shown as left most column ... lets say 6561977 is inode value for the file you wish to delete ... then to delete that file specify using its inode as per
find . -maxdepth 1 -type f -inum 6561977 -delete
in above replace 6561977 with actual inode value shown ... notice first parm of find
command is the directory of action ... here we gave it a period which indicates current directory which is OK since we issued cd
command to get into parent dir of file in question
ls -la -i # list directory again to confirm file has been zapped