

If you considered the filesystem as a black-box, it technically wouldn't be possible at all (only the details of logical and physical layout of data allows you to do some damage control). rm is more permanent, to try to get the files back, you have to actually do some lower-level hacking (there are tools for that). Technically, inverse of cp is rm, unless something was overwritten (again, -i asks you about it). That's why -i switch exists, to ask you before overwriting. they can - you can even write a wrapper function that does something to protect you from foolish mistakes.įor instance, mv is easily reversible by just moving the file back where it came from, unless you have overwritten something. Note that this doesn't mean individual commands don't have "undo". It's up to you to know what you are doing. If you run a command, it is executed, whatever it does.

In most cases, it's not even clear what an undo would do - for instance, can you "unplay" a movie? Can you "unsend" an e-mail? What would "undo running firefox" even mean, for instance? You may close it, but bookmarks, downloads and history won't be the same.

It executes commands that you call - it's not the business of the shell to even know what the command does, you can call any executable you want. You should understand that bash is just an execution environment.
