How to fix file permissions on debian
root
It just so happens I recently migrated a linux system from ext4 to btrfs and didn’t want to do a fresh install. So make a new partition, format it and copy the system over… Too bad I forgot to tell ‘cp’ to preserve the file permissions. I ended up with a system where every last file was owned by root and that obviously causes problem with everything that isn’t executed as root. And of course, the old partition was already gone - bad luck. Reinstalling is pretty much the only ‘solution’ I could find for this problem on the web. What follows are a few simple steps to resurrect a system to at least a runnable / good-enough state:
# most basic permission fixes
chmod 1777 /tmp
chown root:root /tmp
chown -R man:root /var/cache/man
# reinstall some core tools
aptitude reinstall bash
aptitude reinstall man-db manpages
aptitude reinstall dpkg apt aptitude-common apt-listchanges apt-utils aptitude debconf
# re-install all cached deb files
# obviously this only works if they are available, if you did an 'aptitude clean' you're out of luck
cd /var/cache/apt/archives
ls -1 | cut -d_ -f1 | sort -u | grep -v dpkg | grep -v debconf | xargs aptitude reinstall -y