PDA

View Full Version : I did it again!



FoolsGold
May 5th, 2007, 09:19 AM
This is the second time in two months I've typed rm -rf * when inside my home folder, while stupidly assuming I was in another folder, the one I actually wanted to clear.

I'm such a n00b, and my n00b-poking-stick broke already. Maybe I got punished via karma for abusing other Linux n00bs. :mad:

runningwithscissors
May 5th, 2007, 10:10 AM
n00bs should use the GUI for file-management. No shame in that.

zvacet
May 5th, 2007, 10:17 AM
You are learning hard way,but you are learning.No irony.Here are pages with CLI options

https://help.ubuntu.com/community/HowToGetHelp

http://www.oreillynet.com/linux/cmd/

igknighted
May 5th, 2007, 11:02 AM
you should really alias the rm command to "rm -i". This way it always asks "are you sure?" before deleting things adn you can catch mistakes.

saulgoode
May 5th, 2007, 03:17 PM
Get into the habit of using BASH's tab completion to display which files are to be deleted:


$ rm -rf [tab][tab]

will present you with all of the files and directories (top-level) and it will usually become obvious if you are in the wrong directory. Once you have seen the output, you can add the asterisk.

I have also gotten into the habit of always explicitly stating a directory if I wish to delete it or its contents. For example, if I am in my 'Images' directory and wish to delete all of its files and subdirectories:


$ cd ..
$ rm -rf Images/[tab][tab]

It may sound difficult but it soon becomes second nature. It has been years since I have deleted the wrong files and I use CLI for all of my file managing.

EndPerform
May 5th, 2007, 03:37 PM
Another useful command is : pwd. That will tell you the full path of where you are. Use that if you aren't sure where you are :)

plb
May 5th, 2007, 03:37 PM
n00bs should use the GUI for file-management. No shame in that.

go back to gentoo forums :)

Sunnz
May 5th, 2007, 04:02 PM
This is the second time in two months I've typed rm -rf * when inside my home folder, while stupidly assuming I was in another folder, the one I actually wanted to clear.

I'm such a n00b, and my n00b-poking-stick broke already. Maybe I got punished via karma for abusing other Linux n00bs. :mad:
No worries people learn from their mistakes - at least you are not afraid to try the CLI.

runningwithscissors
May 5th, 2007, 04:28 PM
go back to gentoo forums :)
On your forum, trolling your community.

3rdalbum
May 5th, 2007, 04:46 PM
Rather than alias "rm" to "rm -i", maybe you should have the following:


alias rm=echo "Not until you've learnt your lesson about rm'ing!"


It might force you to use the GUI a bit more :-P

Sorry mate, I hope you had a backup.

weatherman
May 5th, 2007, 05:56 PM
one that happens quite often to me using autocompletion is:
gcc -o something.c something
instead of
gcc -o something something.c
I've learned I should use different names for the binary and the source :-)

harlan
May 5th, 2007, 06:20 PM
If you want your deleted files from CLI go to your trash, do as follow:
$ gedit ~/.bashrc

and add this line at the end of the file
alias rm='mv --target-directory=/home/your_username/.Trash'

DoctorMO
May 5th, 2007, 07:18 PM
sudo echo "alias rm='mv --target-directory=~/.Trash/'" >> /etc/bash.bashrc

This should solve it for most people, even works for root if you mkdir /root/.Trash

teet
May 5th, 2007, 08:43 PM
Or you could just

gksudo nautilus

and delete the folder through a gui. Probably is easier/safer.

Don't feel too bad though...I once accidentally rm -rf *'ed a folder containing every episode of Seinfeld. Serves me right I guess.

-teet