Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I accidentially copied my whole home directory into one of my subdirectories, causing me to exceed my disk quota on a server.

Or does anyone know how to undo a command in general?

share|improve this question
1  
In addition to "Here's a nickle, kid. Get yourself a better computer." old unix programers and admins like to say "You recover from your backup. You do have a backup don't you?". Though in this case it is only the original contents of the sub-directory that are likely to be lost. –  dmckee Jan 5 '12 at 21:57
add comment

3 Answers

up vote 3 down vote accepted

Bash is just a command-line interpreter - it does what you tell it to do and doesn't have an undo helper program. You're best of just deleting the subdirectory with something like:

chmod -R 775 ~/yoursubdir && rm -rf ~/yoursubdir
share|improve this answer
    
Can you explain what the first part of that command does? Thanks :) –  Chuck Testa Jan 5 '12 at 19:36
    
That first part is setting the rwx (read, write, execute) permissions to your user and group - for all the files and folders just to be sure you will not encounter permission problems upon deleting. –  Herman Torjussen Jan 5 '12 at 19:56
add comment

I'm pretty sure there's no such thing. If there was, that would be pretty interesting.

For your case you can just remove the subdirectory

rm -rf /path/to/subdirectory

But be careful with that command, as it can fully delete any files from the sub-directory without any confirmation. ;)

share|improve this answer
add comment

When it comes to the shell, you are the undo. The opposite of copying is deleting (rm), so delete the copies.

I recommend installing the trash-cli package, and then setting these Bash aliases:

alias rm='trash'
alias rrm='rm -i'

Of course, in your case, since you're out of disk space, you probably don't want to trash the files first. Even so, it's a good practice to use the trash.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.