0

Might be the worst mistake I've made in Ubuntu. To give some context: I created a directory named "~" by accident in the home directory. Didn't want it so I recursively deleted the directory. Next thing I know is that all my files in the home directory are gone, and I can't used commands such as gcc and apt. Is there a way I can recover from this, or should I just take the L and move on? Also might be good to note that I don't have sudo permissions.

3
  • No backups, I assume? 😕
    – matigo
    Feb 12, 2022 at 6:34
  • Or a recent install with Ubuntu on ZFS?
    – zwets
    Feb 12, 2022 at 8:00
  • I'm in the 'take the L and move on' camp. If there's any data you can back up, go for it. If not, this is a very important lesson you learned, and you didn't even have to pay for a tutor! (The lesson being twofold - be careful when deleting stuff and have working backups.)
    – KGIII
    Feb 12, 2022 at 21:42

1 Answer 1

1

You did not state, but it looks like you recursively deleted ~ using a terminal command (e.g. rm -r ~). ~ expands to the absolute path of your home directory. What should have done what you wanted is:

rm -r '~'

Note the single quotes '. These tell the command interpreter, bash, not to try expanding the enclosed characters, so this would have removed a dile or directory named ~ in the current directory. Using an absolute path, the command would have been

rm -r ~/'~'

This explicitly refers to ~ in the home directory.

Directories and files are, indeed, effectively deleted. Recovering is not at all trivial where possible. So unfortunately, yes, these data are essentially lost, so it is hoped you have a good backup.

You must log in to answer this question.

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