LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-15-2004, 12:41 AM   #1
statmobile
Member
 
Registered: Aug 2003
Location: Chapel Hill, NC
Distribution: Gentoo, Windows 95 2000 & XP
Posts: 160

Rep: Reputation: 30
tips to avoid rm mistakes


Hey experts,
I'm looking for a little input on dealing with any
Code:
rm filename
or worse yet,
Code:
rm -r filename
mistakes. Do you have anything setup on your system, so that you can avoid any enormous disasters? I absolutely love Linux, but this is something that scares me. It's so easy, especially wiith tabbing, to accidentally remove a file. I'm a creature of habit, where I often just go through the routine, before taking the time to read through my commands. It's poor practice, I know, but I'm just looking for some advice from the gurus in LQ land.

Thanks!

P.S. Maybe even some tips on how to deal with a mistake that may have already happened as well.

P.P.S. "Don't be stupid, and think before you hit Enter" Does not count as a tip, although it is very good advice.
 
Old 01-15-2004, 12:54 AM   #2
PbO
Member
 
Registered: Nov 2003
Location: BC, Canada
Distribution: Slackware 11.0
Posts: 30

Rep: Reputation: 15
put alias rm='rm -i' in your .profile

This forces you to confirm each delete.
 
Old 01-15-2004, 12:55 AM   #3
quatsch
LQ Addict
 
Registered: Aug 2003
Location: New York, NY
Distribution: gentoo, gentooPPC
Posts: 1,661

Rep: Reputation: 48
above and don't ever use the
-f
option.
 
Old 01-15-2004, 12:56 AM   #4
megaspaz
Senior Member
 
Registered: Nov 2002
Location: Silly Con Valley
Distribution: Red Hat 7.3, Red Hat 9.0
Posts: 2,054

Rep: Reputation: 46
well redhat aliases the rm command to use rm -i which will prompt you if you really want to delete a file. just be careful with the -f flag as that will just delete anything without prompting you. also be careful with your spelling when deleting files whose filepaths start with "/". don't mistakenly put spaces in those kind of file paths. also be careful with the wildcard character, "*".
 
Old 01-15-2004, 01:14 AM   #5
statmobile
Member
 
Registered: Aug 2003
Location: Chapel Hill, NC
Distribution: Gentoo, Windows 95 2000 & XP
Posts: 160

Original Poster
Rep: Reputation: 30
Nobody uses the technique of keeping a "trash" directory. How writing a script that puts it into this directory, and then another script that deletes all files that are over 7 days old?

I once read a forum discussion on the repercussions of changing the rm command, and this is something that would need to be kept in mind.

Those tips are very useful, but I'm looking for something to protect me a little more. For instance, if I have to put a "yes" in every time I try to remove a file, then that will again be part of my regular routine. I make mistakes often, or make multiple files for backup, thus removing is a vital command in my library.

If I'm just being difficult here, then you should tell me. I was just wondering if there is any special approach that some of you gurus use.
 
Old 01-15-2004, 01:18 AM   #6
megaspaz
Senior Member
 
Registered: Nov 2002
Location: Silly Con Valley
Distribution: Red Hat 7.3, Red Hat 9.0
Posts: 2,054

Rep: Reputation: 46
you're being difficult.

really, though, if you're prompted if you want to delete a file, you shouldn't be giving it a cursory gloss over. you really need to think if the file you're going to delete is going to break something. in the gui, that's what the trash icon is for. so you can reverse a "delete" if you change your mind. in the shell that's what the -i is for. only really delete a file if you're pretty sure it's not a necessary file.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
SUSE 9.3 / 10.1 beta 4 / RC 1 Mistakes I made 1kyle SUSE / openSUSE 5 09-17-2005 08:14 PM
Useful article: "Linux File & Directory Permission Mistakes" sundialsvcs Linux - Security 1 08-15-2005 12:50 PM
new installation of 9.1 - some errors & mistakes ungua SUSE / openSUSE 0 01-15-2005 01:45 PM
How to check up a disk on presence of mistakes - logic and physical? ukrainet Linux - Newbie 2 11-19-2004 09:54 AM
My Sad Linux tale, can u pick out mistakes? genixpro Linux - Newbie 19 10-09-2004 11:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:47 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration