RHEL 8 and /var protection

ivansaez

New Member
Joined
Aug 17, 2023
Messages
6
Reaction score
1
Credits
83
Hi,

A colleague did a chmod -R 777 /var on de RHEL 8 server. Is there a fast way to restore the settings without restoring the server?
I took a similar (similar OS wise) server an did a

find /var -type f -exec stat --format 'chmod %a %n' {} \; >/tmp/restore_prots_files.sh
find /var -type d -exec stat --format 'chmod %a %n' {} \; >/tmp/restore_prots_dir.sh

And did copy the shell scripts to the affected server and did run it. But as the servers are not 100% similar I still have some files/dirs on the affected servers that have 777 protection and I'm not sure what it should be.

regards,

Ivan
 


# Create a fixpermission script
echo 'chmod -R 755 /bin /boot /dev /etc /home /lib /lib64 /media /mnt /opt /run /sbin /srv /usr /var
chmod -R 777 /initrd.img /vmlinuz
chmod -R 1777 /tmp
chmod -R 555 /sys
chmod -R 555 /proc
chmod -R 700 /root' > fixpermission
chmod +x fixpermission
 
Oh my, I hope you have a backup. At least you didn't use something like chmod -R .* I've used chown with recursion to change .* to change a hidden directory tree. The problem was that .. matched that. I had to restore my whole system. I was wondering why it was taking so long to change such a small directory tree.

Signed,

Matthew Campbell
 
Matthew,

Yes, I've a backup but as only /var and below folders were affected I was looking for a faster way (than restore). And it's a test server.
What my collegaue did (and I) I did put in my post. So no chmod -R .*

regards,

Ivan
 
I have found that the find command (/usr/bin/find) can be really helpful for tasks like this. It allows me to add some conditions.

Signed,

Matthew Campbell
 


Latest posts

Top