You are not logged in.

#26 2009-05-12 05:51:49

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: rm -rf on /home

There are also the -i or -I flags.

Offline

#27 2009-05-12 06:17:31

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,896
Website

Re: rm -rf on /home

alias then add -i to ask you if you are sure you want to delete

set up sudo

backup backup then backup

MrG

edit take a look at foremost


Mr Green

Offline

#28 2009-05-12 09:07:36

syntaxerrormmm
Member
From: Italy
Registered: 2008-10-22
Posts: 80
Website

Re: rm -rf on /home

jwcxz wrote:

It would be nice to patch rm so that if you try to delete an important directory like your home directory or /, it will ask for your password or the root password again.  Is this possible?

The program 'rm' was like you see it for about 30 years. Is there so much need to change it for someone that couldn't think twice before press 'enter'? When you are root, you are thought to administer your system (so you *must* watch your steps), not wishy washy. If you want to change some files, just fix the permission on them with root (one command, not definitive as 'rm') then modify them as simple user.


syntaxerrormmm - Homepage

Offline

#29 2009-05-12 13:09:05

andre.ramaciotti
Member
From: Brazil
Registered: 2007-04-06
Posts: 649

Re: rm -rf on /home

I disagree. First, you're assuming that the only important files are the files owned by root, but that's not the case. I praise my own documents much more than the system files. Besides, we can't be 100% of the time on full attention, we're humans, and we make mistakes. That's why I have '-i' in many of my alias, but it's not a complete solution. Some apps, like gcc, may overwrite your source file if you type 'gcc file.c -o file.c'. It may seem a silly mistake, but it's really easy to happen, especially if you're using the shell auto-completion.

This is a problem especially bacause there's no easy way to recover a file after a rm (or a mv/cp overwrite). Maybe a five minutes interval between the rm and the actual desallocation of the file blocks would be more than enough. Generally, the person realizes WTF they made shortly after pressing enter.

Sorry for the half off-topic rant. So, between my brother and my /home, I'd choose my /home, but I don't have a brother anyway. tongue

PS: rm having 30 years just says that it's old. We can't infer nothing about its quality just because of its age.

Last edited by andre.ramaciotti (2009-05-12 13:10:58)


(lambda ())

Offline

#30 2009-05-12 14:23:33

kgas
Member
From: Qatar
Registered: 2008-11-08
Posts: 718

Re: rm -rf on /home

It is also possible to recover the files deleted by rm command  http://www.cyberciti.biz/tips/linuxunix … files.html. IMO Linux expects the user is more responsible for what he/she is doing with the system tongue.

 Maybe a five minutes interval between the rm and the actual de allocation of the file blocks would be more than enough

A function in bashrc with alias to rm will do the job I believe (to execute the command with a final warning to the user) . wink

Last edited by kgas (2009-05-12 14:45:16)

Offline

#31 2009-05-27 07:02:34

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,722

Re: rm -rf on /home

http://www.xs4all.nl/~carlo17/howto/undelete_ext3.htmlyes, this seems helpful since the author made it.

I've googled a bit, and this thread is just another result where someone else asks for help and people answer, "Yeah,hopeless."
Shit I deleted my files too!
I was doing at $HOME: $ rm -f BG/anna-p<Tab><*><Enter>
just to delete all those freaking ugly pictures of anna-p***** after deleted several using Ctrl-del when viewing with feh... And there was only one left to delete! <Tab>hence brought a space at the end and I appended "*"...after the space! all files in my $HOME is dead and gone now. Well at least folders are left alone and alive...

Never press Enter too soon when you have rm with -f, never. Even you really feel it urgent to get rid of some garbage, always use -i.

Last edited by lolilolicon (2009-05-27 07:03:47)


This silver ladybug at line 28...

Offline

#32 2009-05-27 07:24:55

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: rm -rf on /home

agac wrote:

I have lost any important file.

Unfortunately my ex-ex-ex-ex-boss did this to some very important files with global financial data in them while moving a server. He spent days trying to recover them, to no avail.

This was his first lesson in making backups roll

Offline

#33 2009-05-27 11:43:31

andre.ramaciotti
Member
From: Brazil
Registered: 2007-04-06
Posts: 649

Re: rm -rf on /home

Backups won't help everytime*. Imagine you coded in a rush lots of lines of C, debugged it and then, when you were to compile it 'for real', you mistyped 'gcc file.c -o file.c' . You'll probably have no backup as it was a work in progress and you didn't stop to backup it, so say goodbye to your code. This may seem a silly example, but it does happen, especially when you rely on you shell autocompletion system.

*Well, I'm not saying 'make no backups, they will never help', but accidents that happen in between backups being made, and there's nothing you can do in such cases.

OT: fukawi2, you're not 1337 anymore tongue


(lambda ())

Offline

#34 2009-05-27 12:35:58

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: rm -rf on /home

andre.ramaciotti wrote:

OT: fukawi2, you're not 1337 anymore tongue

GADS! I completely missed my most 1337 post ever! yikes

Offline

#35 2009-05-27 12:44:41

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: rm -rf on /home

If backups don't help maybe put everything into RCS?

Offline

#36 2009-05-27 12:52:13

andre.ramaciotti
Member
From: Brazil
Registered: 2007-04-06
Posts: 649

Re: rm -rf on /home

If you remember to commit the changes every now and then, then it's fine.

But it still have the problem of changes that are made between commits can't be rescued.

Last edited by andre.ramaciotti (2009-05-27 12:53:04)


(lambda ())

Offline

#37 2009-05-27 13:59:23

jwcxz
Member
Registered: 2008-09-23
Posts: 239
Website

Re: rm -rf on /home

syntaxerrormmm wrote:
jwcxz wrote:

It would be nice to patch rm so that if you try to delete an important directory like your home directory or /, it will ask for your password or the root password again.  Is this possible?

The program 'rm' was like you see it for about 30 years. Is there so much need to change it for someone that couldn't think twice before press 'enter'? When you are root, you are thought to administer your system (so you *must* watch your steps), not wishy washy. If you want to change some files, just fix the permission on them with root (one command, not definitive as 'rm') then modify them as simple user.

I completely understand your point.  Ever since I accidentally typed rm foo * instead of rm foo* while in my home directory, I've always checked twice before issuing a rm command (imagine if I had used rm -rf instead!).  But the problem is that everyone makes mistakes sometimes.

I'm not talking about changing it for everyone; that would be stupid.  I too hate constantly being asked whether I *really* want to do something or not.  I'm just talking about changing it for me.  I think I was a little tired when I last posted; instead of patching, I meant wrapping.


-- jwc
http://jwcxz.com/ | blog
dotman - manage your dotfiles across multiple environments
icsy - an alarm for powernappers

Offline

#38 2009-05-27 14:21:17

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: rm -rf on /home

andre.ramaciotti wrote:

But it still have the problem of changes that are made between commits can't be rescued.

Than I suggest automatic saving of documents and rsynced backups off-site every 2 mins + tar & gzip into 'backup.09-05-27_16.18.25.tgz' :-D Those backups could be deleted after 48 hrs so you would be left only w/ your regular ones.

Last edited by karol (2009-05-27 14:22:20)

Offline

#39 2009-05-27 14:51:43

gazj
Member
From: /home/gazj -> /uk/cambs
Registered: 2007-02-09
Posts: 681
Website

Re: rm -rf on /home

I rsync off site every hour, has saved the day many times now smile  I also backup to a dds4 tape at the site and at the off site mirror.  I think (hope) I'm pretty safe smile

Offline

#40 2009-05-27 15:20:02

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: rm -rf on /home

Well, I see that there are benefits to slow typing ;-)
If you're about to do sth dangerous, you might want to 'dry-tun' it first.

Offline

#41 2009-05-27 17:36:01

gazj
Member
From: /home/gazj -> /uk/cambs
Registered: 2007-02-09
Posts: 681
Website

Re: rm -rf on /home

Another thing you  must do regulary with backups, try a restore once in a while. there's nothing worse than a backup that won't restore because you haven't tested it for 2 years since you set it up.

Offline

#42 2009-05-27 17:42:18

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: rm -rf on /home

Seems a no-brainer but I saw it happen several times: "*Of course* we have backups!" And and an hour later "Oooops ..." :-)

Offline

#43 2009-05-27 19:54:30

Lagaro
Member
From: /dev/null
Registered: 2009-05-27
Posts: 5

Re: rm -rf on /home

[metoo]
fsck once went up in flames and thought that every single file on my linux partition was a lost inode. I left it and it managed to put almost every single file into /lost+found/. Don't think I'll ever not make a backup for two months again. Damn, but that was a lot of time recovering from that one.
[/metoo]

In all seriousness, though. A decent backup system (even if it's just an external hard drive that you copy /home to every month!) is more than worth the money. A 500GB external hard drive nowadays is what? $150? $200? If you don't have many photos or much music or video, then that will last you a long time. Sure, it's no protection against an earthquake or a fire, but it's still better than nothing.

Remember this one rule: every once in a while, backup everything, *not* just what you think is important.

Side note: I use git to manage my configuration files. When I make a change, I commit the change. It works pretty well.


-- Lagaro

There is no darkness in Eternity/
Only light too dim for us to see.

Offline

#44 2009-05-27 20:07:15

Primoz
Member
From: Ljubljana-Slovena-EU
Registered: 2009-03-04
Posts: 688

Re: rm -rf on /home

After reading this thread I've decided to put some "security" in rm.
So I'll add this alias to my bashrc:

alias rm='echo = "last chance before screwing things up 10s..." && sleep 10s && rm'

It might be a bit of an overstatement but better than losing all my /home documents or /...

Last edited by Primoz (2009-05-27 20:10:55)


Arch x86_64 ATI AMD APU KDE frameworks 5
---------------------------------
Whatever I do, I always end up with something horribly mis-configured.

Offline

#45 2009-05-27 20:14:29

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: rm -rf on /home

What do you need that "=" for?

Offline

#46 2009-05-27 20:16:55

Primoz
Member
From: Ljubljana-Slovena-EU
Registered: 2009-03-04
Posts: 688

Re: rm -rf on /home

karol wrote:

What do you need that "=" for?

I don't know I thought that you need it for echo...
Guess I was wrong even though it still works big_smile.


Arch x86_64 ATI AMD APU KDE frameworks 5
---------------------------------
Whatever I do, I always end up with something horribly mis-configured.

Offline

Board footer

Powered by FluxBB