A Freelance DevOps doing container stuff and automating unhealthy amounts of software.
Need something automated or containerized? Feel free to hit me up :)
I just commented this on another post, I thought it might fit here too.
As you perfectly said:
using -rf flag, verify you're in the right directory by using $ pwd command, then proceed to delete files.
If you want to prevent deleting any important directory via rm -rf <directory/>*, there is a neat trick.
Create a file named -i in all directories you want to protect. This can be done using touch -- -i
or touch ./-i
The * in rm -r * will expand the -i File to the command line, so your command ultimately becomes rm -rf -i
Thus rm will prompt you before deleting anything. You can put this file in your /, /home/, /etc/, and so on.
Example:
Thanks, Habereder! you're the best this is something awesome I'll definitely do this in future like server host and local ... and will save our life. I love this hack!
I just commented this on another post, I thought it might fit here too.
As you perfectly said:
If you want to prevent deleting any important directory via
rm -rf <directory/>*
, there is a neat trick.Create a file named -i in all directories you want to protect. This can be done using
touch -- -i
or
touch ./-i
The * in
rm -r *
will expand the -i File to the command line, so your command ultimately becomesrm -rf -i
Thus rm will prompt you before deleting anything. You can put this file in your /, /home/, /etc/, and so on.
Example:
Thanks, Habereder! you're the best this is something awesome I'll definitely do this in future like server host and local ... and will save our life. I love this hack!
I use
rm -rf directory
often, but never userm -rf "$directory"