Originally posted by Uresh Kuruhuri: Command pattern is aimed to decouple the tasks from the client besides providing a facility to undo an action (preferably last action).
The command pattern doesn't necessarily have anything to do with an undo facility (though they like using them). A command is basically a single method wrapped up in an object together with its invocation parameters. Once the command is set up that method can be executed by anyone with access to the execute interface.
The memento on the other hand simply stores information which reflects the current state of the originating class and it does so without revealing any of the state details to the caretaker which stores the memento.
Undo facilities which can simply undo by restoring the originator's previous state use mementos. In some systems however it isn't possible or feasible to store the entire state of the originator (which could be a complex composite). In that case the undo facility can use commands - whenever an action is received a compensating action is set up and stored in the undo facility. To undo you simply execute the commands in LIFO order until you undo all the necessary actions.
Undo with memento - undo by restoring a snapshot of the originator's state.
Undo with commands - undo by executing compensating actions.