Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 9 down vote accepted

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

share|improve this answer
+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

share|improve this answer
The tag says "ubuntu-server". And rpm -a --setperms. – Ignacio Vazquez-Abrams Jun 7 '10 at 1:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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