Linux 4 All

Best Linux tricks source

People do stupid things. Most common is to recursively change all permission on / instead of just a folder:

chown -R user / var/www/html

Ooops, I accidentally added a space there and now I’m screwed. I will have to reinstall the system. 🙁 Well, not exactly. If you were careful enough to get ACL backup of your file system, you might have a chance:

getfacl -epR / | sed -e 's/\/\//\//g' >$(hostname).acl

Restoring all the permissions from an acl file is easy. All you need is running the following command:

setfacl --restore=$(hostname).acl

If you didn’t destroy everything, but just a folder, first you will need to use a text parser like awk, sed, perl or whatever suits you to get a specific folder ACL from the file you now have. Below example restores /etc

sed -n '/^#\ file:\ \/etc/,/^$/p' $(hostname).acl > etc.acl
setfacl --restore=etc.acl

How to run Apache with mod_fastcgi and php-fpm arrow-right
Next post

arrow-left How to get IPV4 address from a log file
Previous post

Leave a Reply

Your email address will not be published. Required fields are marked *