LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-03-2006, 07:31 AM   #1
RySk8er30
Member
 
Registered: Jul 2004
Location: Buffalo, NY
Distribution: Mandriva 2005LE
Posts: 274

Rep: Reputation: 30
rm -Rf = I am an idiot


I think I know my answer already; I am just posting to confirm it.

I was trying to remove a folder in my home directory. It would not delete because I was using it to install an application as root. I opened a terminal, sued into root and started to type rm -Rf ./ and I meant to type the folder name after the /. Turns out my fat fingers hit the enter key. There went my whole user directory, configuration (. folder names) and all. I looked in my recycle bin (and found out there was no recycle bin as I deleted it). I looked in the root recycle bin, nothing there. Is there any way I can recover this data? The directory was on it's own partition (/dev/hdc). It is an ext3 file system.

From what I've read, I'm SOL. Am I right?

Help!
Ryan
 
Old 01-03-2006, 07:36 AM   #2
jimvin
Member
 
Registered: May 2004
Posts: 71

Rep: Reputation: 15
Quote:
Originally Posted by RySk8er30
I've read, I'm SOL. Am I right?

Help!
Ryan
Afraid so. It's time to restore from backup. You do have a backup, right? Doh!

Consider it a lesson learned as I think everyone has done this at some point in their life. The smart fish start to back up their important stuff after a tragedy such as this.

Jimvin
 
Old 01-03-2006, 07:50 AM   #3
spoody_goon
Member
 
Registered: Sep 2003
Location: Michigan USA
Distribution: Mandrake, DamnSmallLinux, VectorLinux
Posts: 416

Rep: Reputation: 30
Stupid fingers!!! Mine are against me too.
 
Old 01-03-2006, 08:21 AM   #4
cuiq
Member
 
Registered: Aug 2004
Location: Philly
Distribution: Debian Lenny, FreeBSD
Posts: 577

Rep: Reputation: 30
You could always try this tool. Maybe it will help, or maybe it won't, however nothing beats a fail but a try

http://www.sleuthkit.org/autopsy/desc.php
 
Old 01-03-2006, 08:22 AM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
You can, in principle, recover deleted files by using tools that access the raw device. I have no personal experience, however.

Note the HUGE difference between "rm -rf ./" and "rm -rf /".......
 
Old 01-03-2006, 08:32 AM   #6
RySk8er30
Member
 
Registered: Jul 2004
Location: Buffalo, NY
Distribution: Mandriva 2005LE
Posts: 274

Original Poster
Rep: Reputation: 30
Quote:
Consider it a lesson learned as I think everyone has done this at some point in their life. The smart fish start to back up their important stuff after a tragedy such as this.
That brings me to my next question. If I want to setup a cron job to tar my /home/rzaleski directory and back it up to /backup/date.gz. How do I do this?

Also, on a separate note, I want to run a cron job to update my urpmi media. How do I do this?

Ryan
 
Old 01-03-2006, 08:58 AM   #7
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Have you got some kind of Linux introductory text? eg Linux in a Nutshell from O'Reilly.
Another good trick is to Google for tutorials---eg "cron script tutorial linux". I have found some killer tutorials this way.
 
Old 01-03-2006, 09:10 AM   #8
notorp
LQ Newbie
 
Registered: Sep 2005
Distribution: Fedora 10/9/8/6 - FC3 - RH9 + Puppy Dog
Posts: 27

Rep: Reputation: 15
When at Uni I taught my supervisor the command rm -rf to remove old datasets from our diffractometer however one day he too decided to rm -rf in the wrong place and removed 13 GB of data some of which was mine and I've never been able to get it back.

Backups are good but for the next run I would recommend:

alias the rm command to rm -i in your .bashrc file

you can override it but you will have to think about what your doing and it slows down the whole random finger effect!
 
Old 01-03-2006, 09:29 AM   #9
jimvin
Member
 
Registered: May 2004
Posts: 71

Rep: Reputation: 15
Hi,
To edit your cron jobs type:
Code:
crontab -e
NEVER edit your crontab file by hand; the crontab command will sanity check your jobs an make sure that you don't save any b0rked entries.

You can read the man page for crontab for details in how to create cron jobs.
Code:
man 5 crontab
Take a look at this and the examples below should make some sense

To back up your home directory you could use this crontab entry.
Code:
# Backup my home dir every day at midnight
00 00 * * * /bin/tar czvf /backup/`/bin/date '+%Y%m%d'`.tgz /home/rzaleski
Note the backticks (`) in the command line. This causes the command /bin/date to be exeucted and the output used in the filename of your backup.

To update your urpmi update source, you could use the following.
Code:
# Update my urpmi update source at 05:00
00 05 * * * urpmi.update --update
Again we just create a crontab entry with a single command, in this case urpmi. If you want to do something a but more complicated you can write a shell scripts with a list of commands to execute.

Regards,
Jimvin
 
Old 01-03-2006, 01:09 PM   #10
Sepero
Member
 
Registered: Jul 2004
Location: Tampa, Florida, USA
Distribution: Ubuntu
Posts: 734
Blog Entries: 1

Rep: Reputation: 33
Quote:
Originally Posted by notorp
Backups are good but for the next run I would recommend:

alias the rm command to rm -i in your .bashrc file
I was taught from guru's past, that I should not ever use such an alias. The reason why:
"you should never replace a standard command with an alias or a function"

1. It causes a user to become careless.
2. If the safety net is somehow not loaded (single user mode) or the user is temporarily on a different system, then the worst is certain to occur. (Murphy's Law)


A more proper alias would be:
alias rmi="rm -i"
 
Old 01-03-2006, 01:42 PM   #11
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
The rm="rm -i" alias is useless in this situation anyway, as rm -rf becomes rm -i -rf, which overrides the -i from the alias anyway.

Been there, lost three weeks of University work. Ouch.

Dave
 
Old 01-07-2006, 06:24 AM   #12
notorp
LQ Newbie
 
Registered: Sep 2005
Distribution: Fedora 10/9/8/6 - FC3 - RH9 + Puppy Dog
Posts: 27

Rep: Reputation: 15
Quote:
Originally Posted by Sepero
I was taught from guru's past, that I should not ever use such an alias. The reason why:
"you should never replace a standard command with an alias or a function"

1. It causes a user to become careless.
2. If the safety net is somehow not loaded (single user mode) or the user is temporarily on a different system, then the worst is certain to occur. (Murphy's Law)


A more proper alias would be:
alias rmi="rm -i"
I strongly disagree!

Login as root and go to your home directory then type more .bashrc (assuming you use bash?)

You will get:

Code:
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
................
These are setup by default to try and stop acts of forgetfullness under most Fedora/RedHat distros I've worked with.
 
Old 01-07-2006, 06:39 AM   #13
jimvin
Member
 
Registered: May 2004
Posts: 71

Rep: Reputation: 15
I have to say that I don't like relying on aliases for standard commands; it breaks the rule of least suprise. I have been on systems where someone has put braindead aliases which significantly alter the function of a command. The alias is this case breaks if you use the full path to the `rm` command e.g. /usr/bin/rm. I think it's fine to use for normal lusers but NEVER alias commands for root. This is the path to the dark side.

Jimvin
 
Old 01-07-2006, 06:44 AM   #14
phil.d.g
Senior Member
 
Registered: Oct 2004
Posts: 1,272

Rep: Reputation: 154Reputation: 154
Quote:
Originally Posted by Sepero
I was taught from guru's past, that I should not ever use such an alias. The reason why:
"you should never replace a standard command with an alias or a function"

1. It causes a user to become careless.
2. If the safety net is somehow not loaded (single user mode) or the user is temporarily on a different system, then the worst is certain to occur. (Murphy's Law)


A more proper alias would be:
alias rmi="rm -i"
Agreed, and, notorp just because Fedora Core put those aliases in .bashrc by default doesn't make it the correct thing to do, if you were to do a `cat .bashrc` on my system you'll find those aliases don't exist, assuming a default .bashrc

Last edited by phil.d.g; 01-07-2006 at 06:45 AM.
 
Old 01-07-2006, 07:55 AM   #15
Hammett
Senior Member
 
Registered: Aug 2003
Location: Barcelona, Catalunya
Distribution: Gentoo
Posts: 1,074

Rep: Reputation: 59
Sad story is this one. I had a couple of idiot procedures as well. I think doing rm with root should come with confirmation. I know you can do it by making the alias in your .basrhrc file, but it would be easier to make it implemented.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
I am an idiot!!!! jdmarti1 Linux - Software 5 09-23-2005 10:14 PM
I am an idiot darealgodfather Linux - Newbie 5 06-20-2005 03:04 AM
Im an Idiot. Help! didlin Linux - Newbie 2 01-03-2004 01:15 PM
I'm an idiot... smudge Slackware 13 12-25-2003 06:45 AM
Help Idiot is here again! elizabetheanera General 2 06-13-2001 01:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration