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?
2 Answers
Reinstall is the best option. I personally would always have the nagging feeling of something not done right even if the following work.
- 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
- copy
/root/perms.txt
to your main system Use
/root/perms.txt
to reference and modify permissionsmain$ 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
- 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
- 226
- 2
- 3
-
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 07 '10 at 02: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
- 21,910
- 7
- 55
- 79