4

I would like to know if there is a way to roll-back shell commands : for example rolling back a rm -rf command.

0

2 Answers 2

12

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
  • 1
    A way of no return :) I understand your answer ;)
    – A.B.
    Jul 30, 2015 at 15:11
6

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .