Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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, "*".
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.