• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Is there a recycle bin for linux

Brazen

Diamond Member
I need help. This is a basic command line only install of Ubuntu Server. I just removed a directory with "rm -rdf /the/path" and it's the wrong directory! Can I get it back?

Is there anyway to recover the deleted directory?

The file system is XFS, by the way.
 
Well, the files were probably just unlinked and not overwritten so if you haven't done any more writing to that partition the files are still there. But yeah, of course backups are easier to restore from.
 
I've spent all morning setting this up, which entailed coordinating some things with other people, so.... no backups.

Stupid slip of the fingers, I was going to delete a temporary directory and I somehow slipped and hit 'enter' before I finished typing the path.
 
I just checked and my laptop running Ubuntu 6.10 has a trash directory but I'm running Gnome rather than command line only. It's located in ~/.Trash I looked in there and I usually do a shift-Del so there's nothing in it. I created a file called test.txt and removed it with a 'rm test.txt' command. The file went away but not into the trash. I created another file called test.txt while in Nautilus and deleted it (not shift-Del) and it did go into the ~/.Trash directory.
 
Originally posted by: Robor
I just checked and my laptop running Ubuntu 6.10 has a trash directory but I'm running Gnome rather than command line only. It's located in ~/.Trash I looked in there and I usually do a shift-Del so there's nothing in it. I created a file called test.txt and removed it with a 'rm test.txt' command. The file went away but not into the trash. I created another file called test.txt while in Nautilus and deleted it (not shift-Del) and it did go into the ~/.Trash directory.

Unfortunately for me, that is apparently handled by Gnome. Since I am running CLI only, I have no such thing. I was hoping there would be an undelete command like there is with ext2.

Oh well, I've already pretty much redone everything I did this morning. I may look into aliasing the rm command to mv in the future.
 
I just removed a directory with "rm -rdf /the/path" and it's the wrong directory! Can I get it back?

Unrelated but why are you using the -d option? From looking at the man page it looks like it's a good way to mess up your filesystem.

I may look into aliasing the rm command to mv in the future.

Unless mv supports the same switches (mostly -r and -f) which it doesn't, that won't work out too well. You could write a wrapper script parse rm switches and then use mv on them, but that seems like overkill and would most likely bit you in the ass the minute you ended up on a system without that script. It's better to just get used to slowing down and verifying dangerous commands before you execute them.

There was an undelete for ext2 because of the simplicity of the filesystem, it's not as easy with journaling filesystems and I don't think anyone's ever created one consistent enough to release. It's possible some forensics tools might be able to recover the files, but that's probably a lot more time consuming than just recreating the work.
 
Originally posted by: Brazen
I need help. This is a basic command line only install of Ubuntu Server. I just removed a directory with "rm -rdf /the/path" and it's the wrong directory! Can I get it back?

Is there anyway to recover the deleted directory?

The file system is XFS, by the way.



if you are using the -f switch the systems is assuming you are sure you want to delete it. You are specifically telling the OS NOT to prompt me for verification. Unitl you have backups its probably best to not use the -f option and 'y' your way through the prompts.

rm -rf is a lesson every good admin learns first hand.

here is a free one from a long time unix admin, always use absolute paths when using rm -rf. never ever ever ever use rm -rf * , the one time you dont check your pwd, you will be in a whole world of hurt..

but then again, i'm an production operations kinda guy and dont take needless chances.
 
Originally posted by: Dravic
Originally posted by: Brazen
I need help. This is a basic command line only install of Ubuntu Server. I just removed a directory with "rm -rdf /the/path" and it's the wrong directory! Can I get it back?

Is there anyway to recover the deleted directory?

The file system is XFS, by the way.



if you are using the -f switch the systems is assuming you are sure you want to delete it. You are specifically telling the OS NOT to prompt me for verification. Unitl you have backups its probably best to not use the -f option and 'y' your way through the prompts.

rm -rf is a lesson every good admin learns first hand.

here is a free one from a long time unix admin, always use absolute paths when using rm -rf. never ever ever ever use rm -rf * , the one time you dont check your pwd, you will be in a whole world of hurt..

but then again, i'm an production operations kinda guy and dont take needless chances.

rm only prompts you if you use "-i". Aliasing "rm" to "rm -i" by default is an abomination that seems to have started in the Linux world. It's a horrible horrible horrible thing, and it makes me sad. 🙁
 
Originally posted by: Markbnj
Originally posted by: OSX
pwned
Ah, I see the Linux Community End-user Support Team just got back from lunch.
Thanks for making it worse troll.
Originally posted by: Dravic
if you are using the -f switch the systems is assuming you are sure you want to delete it. You are specifically telling the OS NOT to prompt me for verification. Unitl you have backups its probably best to not use the -f option and 'y' your way through the prompts.
Not that I'd argue with the advice (and I'm sure Brazen knows that he should have been more careful 😛), but I don't see the -f option really mattering one way or the other. If your files are all writable then you won't get any prompts anyway and if just some of them aren't you have a good chance of having deleted other stuff before you get to those files. If you have a habit of making important files unwritable for this purpose then it's another story. Maybe using the -i flag is safer (but certainly tedious for anything recursive) 🙂
 
Originally posted by: kamper
Originally posted by: Markbnj
Originally posted by: OSX
pwned
Ah, I see the Linux Community End-user Support Team just got back from lunch.
Thanks for making it worse troll.
Originally posted by: Dravic
if you are using the -f switch the systems is assuming you are sure you want to delete it. You are specifically telling the OS NOT to prompt me for verification. Unitl you have backups its probably best to not use the -f option and 'y' your way through the prompts.
Not that I'd argue with the advice (and I'm sure Brazen knows that he should have been more careful 😛), but I don't see the -f option really mattering one way or the other. If your files are all writable then you won't get any prompts anyway and if just some of them aren't you have a good chance of having deleted other stuff before you get to those files. If you have a habit of making important files unwritable for this purpose then it's another story. Maybe using the -i flag is safer (but certainly tedious for anything recursive) 🙂

The thing is, it wasn't that I wasn't being careful about what I was deleting, and I was using the absolute path... I guess I should just not try to type so fast :brokenheart: This makes me think, it would be nice if using the -f switch (or always) that it would just prompt you ONCE to ask if this is really what you want to do for the whole thing.
 
Originally posted by: Brazen
The thing is, it wasn't that I wasn't being careful about what I was deleting, and I was using the absolute path... I guess I should just not try to type so fast :brokenheart: This makes me think, it would be nice if using the -f switch (or always) that it would just prompt you ONCE to ask if this is really what you want to do for the whole thing.

No, it wouldn't be nice. '-f' means DO IT, DO IT NOW! Prompting is unreasonable in this situation.
 
Originally posted by: n0cmonkey
Originally posted by: Brazen
The thing is, it wasn't that I wasn't being careful about what I was deleting, and I was using the absolute path... I guess I should just not try to type so fast :brokenheart: This makes me think, it would be nice if using the -f switch (or always) that it would just prompt you ONCE to ask if this is really what you want to do for the whole thing.

No, it wouldn't be nice. '-f' means DO IT, DO IT NOW! Prompting is unreasonable in this situation.

fine then. They need a "prompt me once for the whole thing" switch then. It seems reasonable, for something so destructive.
 
Originally posted by: Brazen
Originally posted by: n0cmonkey
Originally posted by: Brazen
The thing is, it wasn't that I wasn't being careful about what I was deleting, and I was using the absolute path... I guess I should just not try to type so fast :brokenheart: This makes me think, it would be nice if using the -f switch (or always) that it would just prompt you ONCE to ask if this is really what you want to do for the whole thing.

No, it wouldn't be nice. '-f' means DO IT, DO IT NOW! Prompting is unreasonable in this situation.

fine then. They need a "prompt me once for the whole thing" switch then. It seems reasonable, for something so destructive.

It's open source, so submit a patch! 🙂
 
Originally posted by: Brazen
Originally posted by: n0cmonkey

It's open source, so submit a patch! 🙂

Touche! Just as soon as I learn to program...

Pay someone else to do it.

One of the great things about unix-like systems is that they give you a lot of tools. It is up to you to learn how to use those tools, or to use them wisely.

Adding an option to GNU's cp like the one you are proposing just hurts people in the long run. It'll be YAGOF (Yet Another GNU Only Feature) that isn't portable to other systems. So if someone is used to using that option, the lack of it may blow up in their faces (or make scripts less portable). Your best bet is to take your time, especially when using something as powerful as rm.

And yes I'm speaking as someone that's blown away the wrong data plenty of times, and probably will do it again. :evil:
 
fine then. They need a "prompt me once for the whole thing" switch then. It seems reasonable, for something so destructive.

But that would break scripts that rely on rm being non-interactive with -f. I guess you could add another switch or extend -i to prompt once when -f is used, but that's only a bandaid for the real problem.
 
Back
Top