I would like to know if there is a way to roll-back shell commands : for example rolling back a rm -rf
command.
2 Answers
There is no way to "roll back" shell commands.
If you removed a file using rm
command, you can only try to restore it using testdisk or a similar software.
Some of shell commands can be rolled back by other shell commands.
For example, if file.txt
did not exist, command
echo "bla bla bla" > file.txt
can be rolled back by
rm file.txt
If file.txt
had some content, the first command can't be rolled back.
So you need to be very careful using shell commands!
-
1
In general, a shell command could do anything to the system, and there is no omnipotent undo mechanism within Ubuntu.
However, if you run Ubuntu as a guest inside a virtual machine, you could take a snapshot of the virtual machine, which would give you the ability to rollback to the snapshot.