How can I reset the permissions of /var?
One way is to install another machine or VM with the same version of the OS and on that machine run this two commands:
find / -exec stat --format "chmod %a %n" {} \; > /tmp/restoreperms.sh
find / -exec stat --format 'chown %U:%G %n' {} \; >> /tmp/restoreperms.sh
command 'find' finds the root directory and checks for their permissions using 'chmod' and save it to a temporary permission file.
Or this one that combines both:
/usr/bin/find / -exec /usr/bin/stat --format="[ ! -L {} ] && /bin/chmod %a %n" {} \; -exec /usr/bin/stat --format="/bin/chown -h %U:%G %n" {} \; > /tmp/restoreperms.sh
then, copy the /tmp/restoreperms.sh
file to the machine with broken permissions:
scp /tmp/restoreperms.sh user@ip_address:/tmp/
scp securely copies the permissions stored to a temporary directory /tmp/ and execute it from there.
try this find /var -name "*" | while read -r dir ; do echo "$dir"; stat -c %a "$dir"; done
you will be able to find the file name with the permission and write it to a file and copy the file to your friend's computer and match each filename by writing another script there.note that chmod
has chmod --reference=RFile file
facility so you can search for each matching file and apply the reference there.