The famous devil command rm -rf / in the en
I often hear of failure stories that I've been doing with this command for a long time, but at last a familiar person has made it w
Therefore, we will consider measures to prevent recurrence.
This article is about prevention measures. If you arrive at this article after doing something, this article may be helpful.
rm -rf /
Simply put, the command to delete everything.
If you write each one super easily, it looks like this.
|rm||The delete comma|
|-r||Option to delete directories as well as files|
|-f||Option to recommend deletion without giving detailed messages|
See here for more information
I found something called trash-cli. When introduced, the following command is added:
- trash-put – Go to Recycle Bin
- trash-list – list of recycle bins
- trash-restore – restore from recycle bin
- trash-empty – empty the recycle bin
- trash-rm – delete individual files from recycle bin
ng the trash-put in
this with the rm command, deleted files and directories will once enter a dedicated recycle bin. (Can be restored from there arbitrarily)
The environment is Mac. It seems to be available in other environments, but I haven't tried it.
As of October 23, 2020,
it was v0.17.1.
$ brew install trash-cli
Set the alias of rm to trash-put
When rm is called,
set the alias to run trash-put instead.
The following .bash_aliase added to the ~/.bash_aliase page. If you don't have a file, create a new one.
if type trash-put &> /dev/null then alias rm=trash-put fi
Add the following to ~/.bashrc: If you don't have a file, create a new one.
if [ -f ~/.bash_aliases ]; then source ~/.bash_aliases fi
Apply ~/.bashrc to make sure the aliasing is going well.
$ . ~/.bashrc $ alias rm alias rm='trash-put'
I'll test it.
Try deleting it and try restoring it.
# Make a suitable file $ touch test.txt # Delete it $ rm test.txt # Check the contents of the recycle bin $ trash-list 2020-10-23 20:04:08 /Users/tabesala/Downloads/test.txt # Restore (this time, I want to restore file No.0, so enter 0) $ trash-restore 0 2020-10-23 20:04:08 /Users/tabesala/Downloads/test.txt What file to restore[0..0] : 0
A problem or something to be aware of
Since it seems that file recovery is not university, it
may be difficult to restore when you really rm -rf / w