You are not logged in.

#1 2009-05-12 16:07:11

namik
Member
From: Bosnia and Herzegowina,Austria
Registered: 2009-05-12
Posts: 6

Lost file with rm command

Hello all,

I don't know what I wanted to do with this command but I did it ^^

-----------------------------------------------------------------------------

# rm YYYYY.data Whitecastle

rm: cannot remove `Whitecastle': No such file or directory

-----------------------------------------------------------------------------

After this clever action I can't see the YYYYY.data file in the folder, is it still on my HDD or gone forever?

Thanks in advance.

Last edited by Namik Delilovic (2009-05-12 16:07:46)

Offline

#2 2009-05-12 16:25:15

tomd123
Developer
Registered: 2008-08-12
Posts: 565

Re: Lost file with rm command

what file system are you using? there have been many problems like this already, search the forums and google "linux undelete from ext3 filesystem" assuming it's ext3 tongue

Offline

#3 2009-05-12 16:25:25

Ashren
Member
From: Denmark
Registered: 2007-06-13
Posts: 1,229
Website

Re: Lost file with rm command

Well, you removed it so its not there anymore (not listed anyway).

Depending on your filesystem there is a chance you could undelete it.

http://bbs.archlinux.org/viewtopic.php?id=71879&p=2

http://bbs.archlinux.org/viewtopic.php?id=63091

Search the forum and use google.

Offline

#4 2009-05-12 16:28:22

perbh
Member
From: Republic of Texas
Registered: 2005-03-04
Posts: 765

Re: Lost file with rm command

ooops !
well, in linux/unix the theme is: "You asked for it, you got it!"
The windows side of the coin:
Are you sure you want to do this (y/n)? y
Are you really, really sure(y/n)? y
If you do this, the file might be lost forever - do you still want to delete it (y/n)? y
Ok, done! But in case you change your mind it can be found in your trashcan.

Now - which scenario would you prefer?

One lives and learns and I bet that in the future you may be tad more careful with the 'rm' command!

Offline

#5 2009-05-12 16:39:16

namik
Member
From: Bosnia and Herzegowina,Austria
Registered: 2009-05-12
Posts: 6

Re: Lost file with rm command

Well I am lucky it was just a movie (600mb) , but I was wondering what happened to it:)

Thanks for your reply.

Offline

#6 2009-05-12 18:35:27

thisperishedmin
Member
Registered: 2008-11-04
Posts: 164

Re: Lost file with rm command

"trashcans" are an implementation by desktop environment where files are sent to a temporary holding place until you explicitly remove them.  for example, if you did this from a gnome GUI, it would move it to some hidden and remote location, but would let you restore it.

when you use rm from the terminal, it immediately "deletes" the file bypassing any use of a trashcan. Fortunately, most filesystems wont actually REMOVE the data, but merely mark its location on your harddrive as "usable" by other file writes.  Because of this, you may still be able to recover the item.

as stated, google for file recovery and your type of file system and you may be in luck.  but be more careful with rm next time....especially if you start tacking on -rf and slashes =P

Offline

#7 2009-05-12 18:45:53

namik
Member
From: Bosnia and Herzegowina,Austria
Registered: 2009-05-12
Posts: 6

Re: Lost file with rm command

thisperishedmin wrote:

"trashcans" are an implementation by desktop environment where files are sent to a temporary holding place until you explicitly remove them.  for example, if you did this from a gnome GUI, it would move it to some hidden and remote location, but would let you restore it.

when you use rm from the terminal, it immediately "deletes" the file bypassing any use of a trashcan. Fortunately, most filesystems wont actually REMOVE the data, but merely mark its location on your harddrive as "usable" by other file writes.  Because of this, you may still be able to recover the item.

as stated, google for file recovery and your type of file system and you may be in luck.  but be more careful with rm next time....especially if you start tacking on -rf and slashes =P

"when you use rm from the terminal, it immediately "deletes" the file bypassing any use of a trashcan. Fortunately, most filesystems wont actually REMOVE the data, but merely mark its location on your harddrive as "usable" by other file writes.  Because of this, you may still be able to recover the item."

Nice to know that, i never thought about it smile

Thanks

Offline

#8 2009-05-13 11:46:37

thisperishedmin
Member
Registered: 2008-11-04
Posts: 164

Re: Lost file with rm command

Namik Delilovic wrote:

"when you use rm from the terminal, it immediately "deletes" the file bypassing any use of a trashcan. Fortunately, most filesystems wont actually REMOVE the data, but merely mark its location on your harddrive as "usable" by other file writes.  Because of this, you may still be able to recover the item."

Nice to know that, i never thought about it smile

Thanks

sure thing!  I believe you can modify your ~/.bashrc to change the behavior of rm to reflect a trash can...I'm not sure if this works in Arch as I havent tried it here - but it *SHOULD* of course.

make a trash directory first:

cd ~/
mkdir .Trash

~/.bashrc:

alias rm="mv ~/.Trash"

If you now rm a file or directory as the user with the new .bashrc, it should go to trash.  log out and back in or reboot first though.  additionally, rm now behaves like mv - keep this in mind!  If for example, ~/.Trash contains a file named "foobar" and you delete "foobar" from somewhere else on your system...mv now overwrites (replaces) the foobar that was already in the trash with the foobar you just moved.  obviously, the above solution isnt perfect, but its a quick and dirty way to save your butt from time to time.

If you hunt around I'm sure you could find a script to more intelligently handle deletions and put an alias in for rm to call that from /usr/bin or something.

you can also edit ~/.bashrc to contain

alias rm = 'rm -i'

which will interactively ask for confirmation...personally - this is a PITA if you ask me - but many people like it. additionally, i just got in the habit to confirm anything and then in the case that I did type the wrong thing, i confirmed it anyway. a bit of windows dialog syndrome, if you will... haha

handling your deletion all comes down to how careful you can be...hopefully one of the above suggestions helps save you further turmoil down the line tongue

Last edited by thisperishedmin (2009-05-13 11:48:37)

Offline

#9 2009-05-13 12:46:48

namik
Member
From: Bosnia and Herzegowina,Austria
Registered: 2009-05-12
Posts: 6

Re: Lost file with rm command

Creating a trash folder in Linux is a good idea, but if I do it ill find some good scripts to handle that for me tongue

This was my first post, and I must say the community of Arch Linux is excellent, thank you all.

Offline

#10 2009-05-13 15:36:25

thisperishedmin
Member
Registered: 2008-11-04
Posts: 164

Re: Lost file with rm command

Namik Delilovic wrote:

Creating a trash folder in Linux is a good idea, but if I do it ill find some good scripts to handle that for me tongue

This was my first post, and I must say the community of Arch Linux is excellent, thank you all.

I'll post back if I get the chance to look and find anything useful...

Secondly, welcome to the forums and welcome to Arch! We do what we can tongue

Offline

#11 2009-05-13 16:07:26

kamiheku
Member
Registered: 2009-05-11
Posts: 42

Re: Lost file with rm command

There is a package called 'trash' in AUR, I believe this is exactly what you people are looking for.
http://aur.archlinux.org/packages.php?ID=9874


"Click clack, clicketyclacketyclick!"
-- IBM Model M

Offline

Board footer

Powered by FluxBB