Alright, I accidentially chomdded everything to 755, which isn't as terrible as chowning everything to the local user. How insecure is this and how would I restore it easily, without reinstalling?


Reinstall is the best option. I personally would always have the nagging feeling of something not done right even if the following work.

  1. Use another Ubuntu system to reference your permissions. Same Ubuntu version and architecture.
    reference$ find / ! -type l \
             -path "^/tmp" -prune \
             -o -path "^/dev" -prune \
             -o -path "^/sys" -prune \
             -o -printf "%m %p\n" > /root/perms.txt
  2. copy /root/perms.txt to your main system
  3. Use /root/perms.txt to reference and modify permissions

    main$ cat /root/perms.txt | while read LINE; do
    perm=echo -E "$LINE" | awk '{print $1}'
    filename=echo -E "$LINE" | sed 's/^$perm //'

    if [ -a $filename ]; then echo -E "$filename" >> /root/chmod-success.log chmod $perm $filename else echo -E "$filename" >> /root/chmod-failure.log fi done

  4. check the errors in /root/chmod-success.log and /root/chmod-failure.log

Anyway, there are just too many edge cases here that I cannot even imagine if this would work perfectly. Test on another non-production system first. And test on the main production system without the chmod $perm $filename line first

  • 2
    +1 for reinstall. I've done exactly the same thing, and after banging my head against the wall for 2 days trying to right all the wrongs, I wound up reinstalling anyway. – Jeff Leyser Jun 7 '10 at 2:03

If you have an RPM based distro like Fedora/Redhat or CentOS you could run

rpm -qa | xargs rpm --setperms

That will fix all files that were installed via rpm.. the rest will have to be fixed by hand

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.