Accidential CHMOD 755
Solution 1:
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
Solution 2:
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