Using scripts that deal with erasure of anything or using unspecified scripts made by unconfirmed authors.
There used to be this sneaky bash command, composed entirely of colons, semicolons, apostrophes and such. This command was equivalent to one of the black magic stuff you have mentioned in the point 2.
In case accidental deletion of something critical on the hard drive, I know the right drill is to immediately stop applying any further changes - in particular trying to solve the issue on own behalf, without required competence, that is - perhaps shut down the PC and contact data rescue centre of choice. Majority of time, even when gone from the hard drive, the deleted information is still stored in one of the 'memory boxes' on the hardware - only marked as 'overwritable' for potential next information coming in - therefore possible to be recovered. That is also why we do not want to introduce any further changes in such an errific situation, not to accidentally overwrite our vulnerable piece of data.
Unless you have Timeshift often making backup for you. Then you may try to recover the system image of certain step back in time. Just be sure your Timeshift maintenance is all-inclusive, which means, it saves everything, not just some portion of the system. Timeshift is probably one of the few pieces of software for the developers of which I could willingly donate to.
On the contrary, if we work with confidential information and want to - for example - give the computer to recycling, without risking the information being taken over by overly inquisitive parties having too much spare time on their hands, simply run a destructive disk check. It makes all the 'memory boxes' on the hard drive open and writes a pattern into each one of them, effectively turning everything into tabula rasa.