[comp.unix.questions] rm *

drabik@lifia.UUCP (Pascal Drabik) (09/12/87)

   Is there anybody who know how to retrieve files removed by th "rm" command ?

   A person in our laboratory, working on a SUN under UNIX 4.2, ran the command
"rm *" in his directory. The SUN's disk is divided in 2 partitions : "/"
and "/usr". The problem happened under "/usr".
   Since the files were destroyed, nobody has touch this partition.
   Is it possible to patch the directory file to reconsider the destroyed
files ?
   How can we proceed with the inodes table ?

   Thanks in advance.
-- 
DRABIK Pascal                Tel: (33) 76-43-37-66   ext. 399  % You'll never %
Laboratoire LIFIA INPG                                         %  know until  %
46, avenue Felix Viallet     UUCP : drabik@lifia.imag.fr       %  you try...  %
38031 Grenoble CEDEX France  BITNET : drabik@frcicg71.bitnet   % ~~~~~~~~~~~~~%

aiv@euraiv1.UUCP (Eelco van Asperen) (09/15/87)

in article <2830@lifia.UUCP>, drabik@lifia.UUCP (Pascal Drabik) says:
>    Is there anybody who know how to retrieve files removed by th "rm" command ?

yep; refer to your last backup..... ;-}

d757@sphinx.uchicago.edu (Lawrence Lerner) (09/16/87)

Here are some commands that have been implemented here.  We run B 4.2 on a
Pyramid 90x.  These commands go in your .cshrc file.


 
#bye along with rm and unrm allows you to get rid of files temporarily and
#then flushes them when you log out normally.  If you have not logged using
#the "bye" alias the files will not disappear.  This is especially useful for
#system crashes.  If you wish to retrieve them you can use
#unrm, this ONLY works if you have not yet logged out. Rm stores them in the
#limbo directory which you must first create in order to use these procedures.
   
alias bye 'chmod 755 $HOME/limbo/.* >& /dev/null;chmod 755 $HOME/limbo/* >& /dev/null;\rm $HOME/limbo/.* >& /dev/null; \rm $HOME/limbo/* >& /dev/null;close limbo'

alias rm 'mv \!* $HOME/limbo'    
alias unrm 'mv $HOME/limbo/\!* $cwd'     
-- 
           "...nothing kills that does not know ye."
                  -Meg Davis, `The Elf Glade' 
UUCP: ihnp4!gargoyle!sphinx!d757       d757@sphinx.uchicago.edu    
      Lawrence Lerner    University of Chicago Computation Center   

d757@sphinx.uchicago.edu (Lawrence Lerner) (09/16/87)

Grrrr, I have been painfully reminded of something.

Iforgot to include a standard disclaimer, my previous posting is *NOT*
UC Comp Center policy etc. etc.  I stole it from a friend, flames, bugs
to me.

Sorry

-- 
           "...nothing kills that does not know ye."
                  -Meg Davis, `The Elf Glade' 
UUCP: ihnp4!gargoyle!sphinx!d757       d757@sphinx.uchicago.edu    
      Lawrence Lerner    University of Chicago Computation Center   

schaefer@ogcvax.UUCP (Barton E. Schaefer) (09/18/87)

In article <sphinx.2284> d757@sphinx.UUCP (Lawrence Lerner) writes:
>#bye along with rm and unrm allows you to get rid of files temporarily and
>#then flushes them when you log out normally.  If you have not logged using
>#the "bye" alias the files will not disappear.  This is especially useful for
>#system crashes.  If you wish to retrieve them you can use
>#unrm, this ONLY works if you have not yet logged out. Rm stores them in the
>#limbo directory which you must first create in order to use these procedures.
>   
>alias bye 'chmod 755 $HOME/limbo/.* >& /dev/null;chmod 755 $HOME/limbo/* >& /dev/null;\rm $HOME/limbo/.* >& /dev/null; \rm $HOME/limbo/* >& /dev/null;close limbo'
>
>alias rm 'mv \!* $HOME/limbo'    
>alias unrm 'mv $HOME/limbo/\!* $cwd'     

What is "close limbo" ?  We have no such command here (VAX 11/780 UNIX 4.3 +
NFS (U. of Wisc.)).  And where's the "logout" in this alias?  (Perhaps that's
what "close" does?)

Some other funnies in the "bye" alias:
	chmod 755 $HOME/limbo/.*	changes the modes of . and ..
	\rm $HOME/limbo/.*		attempts to rm . and ..

The latter is OK only because rm won't do directories without the -r option.
The former quietly changes the modes of $HOME !

What are the chmods for anyway?  If it's to keep rm from asking about over-
riding protections, why not use "\rm -f" ?

And then there's what happens if you type
	rm -r some_directory
with the "rm" alias above ... yup, you get an error message from mv.

Ah, well, no easy way around the "rm -r" problem (except substituting a shell
script for rm), but "bye" can be fixed up:

# Hard quotes here make $HOME be expanded at execute time, not aliasing time
alias	bye	'source $HOME/.bye ; logout'

in $HOME/.bye:

# Cleanup, to be done only when the user logs out with "bye"
/bin/rm -f $HOME/limbo/.??* >& /dev/null
/bin/rm -f $HOME/limbo/* >& /dev/null
close limbo	# left because I don't know what it does

I'd also suggest substituting a name beginning with "." for "limbo", e.g.
".limbo", so it won't normally show up in "ls" listings.

If you don't like having the extra file ".bye", then do

alias	bye	'set flush_limbo ; logout'

and in ".logout" put

if ($?flush_limbo) then
# stuff from .bye, above
endif

Incidentally, around here the default (new-user) ".cshrc" contains

alias	rm	"rm -i"
alias	RM	"/bin/rm"

which catches most of the "rm *" problems without resorting to the
mv-to-limbo technique.

-- 
Bart Schaefer			CSNET:	schaefer@Oregon-Grad
				UUCP:	...{tektronix,verdix}!ogcvax!schaefer
"Face it ... computers have revolutionized the workplace."
"Right.  The Ayatollah did the same thing to Iran."		-- J. MacNelly