Accidently deleted /usr contents.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Accidently deleted /usr contents.
# 15  
Old 01-30-2013
Quote:
Originally Posted by Neo

Never, ever, run a script that deletes files (especially as root) without testing first and confirming the script is working as intended.

Edit: Note that ZB recommends a similar approach in his reply above.
Quote:
Originally Posted by zazzybob
This is why whenever I run rm -rf from a script, my first run is ALWAYS:
Code:
...
#rm -rf $something
echo "we will be removing: $something"
...

i.e. initially comment out the rm and have it echo what we'll be removing instead. If it looks sane, then go ahead and uncomment the rm.

Another lesson here - backups - but you have probably heard enough about that already...
Well learned that lesson the hard way.

NEVER DELETE ANYTHING AS SUPERUSER WITHOUT TESTING IT OUT FIRST!!

And thanks for the tip.
# 16  
Old 01-30-2013
Lightbulb

Quote:
Originally Posted by chacko193
Well learned that lesson the hard way.

NEVER DELETE ANYTHING AS SUPERUSER WITHOUT TESTING IT OUT FIRST!!

And thanks for the tip.
Yes, if you follow that rule, you will have a much happier life as a system admin.

Also, don't forget an equally important rule:

NEVER WORK ON PRODUCTION (CRITICAL) SYSTEMS AS SUPERUSER WITHOUT A FULL, CURRENT OFF-SERVER BACKUP IN PLACE.
This User Gave Thanks to Neo For This Post:
# 17  
Old 01-30-2013
Quote:
Originally Posted by Scrutinizer
I was not suggesting that the script might have reinstalled anything, but enquiring about the possibility that somebody else of some other process could have been installing or reinstalling something in /usr/bin after the script had previously removed the directory (perhaps even as a response to it, for example some form of configuration management)
I'm not sure is any such provison exists.

Those files may have not been deleted because they were in use by some other process.Thats's the conclusion that I have reached.

The script went ahead and deleted every in /usr as it selected that as the oldest file as you said earlier.Some files were not deleted because they were in use.

So some files were left behind and most files got deleted.
# 18  
Old 01-30-2013
Quote:
Originally Posted by chacko193
I'm not sure is any such provison exists.

Those files may have not been deleted because they were in use by some other process.Thats's the conclusion that I have reached.

The script went ahead and deleted every in /usr as it selected that as the oldest file as you said earlier.Some files were not deleted because they were in use.

So some files were left behind and most files got deleted.
So maybe the rm command stopped when it tried to remove itself from /usr/bin or stopped working correctly after it removed itself from /usr/bin...

You said three files starting with "r" were left in /usr/bin; remsh was one of them but you didn't say whether rm was one of them.
# 19  
Old 01-30-2013
Just another tip as you probably have heard the "have backups and test thoroughly when working as root" probably often enough now to hit home:

If your "/usr/bin/ls" binary is already missing you can emulate it by using

Code:
echo *

and use the wildcard expansion of the shell instead as a makeshift-ls.

I hope this helps.

bakunin
# 20  
Old 01-30-2013
Quote:
Originally Posted by Don Cragun
So maybe the rm command stopped when it tried to remove itself from /usr/bin or stopped working correctly after it removed itself from /usr/bin...

You said three files starting with "r" were left in /usr/bin; remsh was one of them but you didn't say whether rm was one of them.
Well it may be as you you said,but i forgot wat the other two files were.I just remember that it started with 'r'.

Quote:
Originally Posted by bakunin
Just another tip as you probably have heard the "have backups and test thoroughly when working as root" probably often enough now to hit home:

If your "/usr/bin/ls" binary is already missing you can emulate it by using

Code:
echo *

and use the wildcard expansion of the shell instead as a makeshift-ls.

I hope this helps.

bakunin
Thanks for the the tip.But I already copied most of the lost files from other server with same configuration and it seems to be working.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Solaris

Contents deleted from /var/sadm

Hi, Somebody/somebody removed all contents /vat/sadm on Solaris 10 Sparc box. As of now server is up and running. There is no backup for this server. If we copy contents from another equivalent server, can it work ? We don't know if it will be fixed by booting form DVD also. Any suggestions? (4 Replies)
Discussion started by: solaris_1977
4 Replies

2. BSD

FreeBSD: /usr/bin/ld not looking in /usr/local/lib

I'm not sure if this is the default behavior for the ld command, but it does not seem to be looking in /usr/local/lib for shared libraries. I was trying to compile the latest version of Kanatest from svn. The autorgen.sh script seems to exit without too much trouble: $ ./autogen.sh checking... (2 Replies)
Discussion started by: AntumDeluge
2 Replies

3. BSD

NetBSD Accidently deleted crontab for root

Someone can told me where from get the default crontab settings of root for NetBSD 6.0 please :) ### SOLVED ### The default crontab rules are in etc.tgz /var/cron/tabs/root # $NetBSD: crontab,v 1.15 2002/11/27 15:09:17 perry Exp $ # # /var/cron/tabs/root - root's crontab for NetBSD #... (0 Replies)
Discussion started by: batence
0 Replies

4. AIX

Which files can be deleted in /usr in an aix hacmp node?

Hi Can ony one advise which files can be deleted in /usr in an aix hacmp node ? Im new to aix and Im not sure which files can be deleted ? #df -g /usr Filesystem GB blocks Free %Used Iused %Iused Mounted on /dev/hd2 7.00 1.00 86% 67013 22% /usr ... (4 Replies)
Discussion started by: samsungsamsung
4 Replies

5. Solaris

Accidentally deleted s. link /usr/lib/secure/s8_preload.so.1

I have accidentally deleted the sim link: /usr/lib/secure/s8_preload.so.1 -> /.SUNWnative/usr/lib/brand/solaris8/s8_preload.so.1 and now I can't do almost anything in my Solaris 8 container. I still have an open session to the machine. I can not create the link again because trying to run:... (1 Reply)
Discussion started by: qwertysas
1 Replies

6. Solaris

How do I link ld in /usr/ucb/ to /usr/ccs/bin?

Hi all, below is the problem details: ora10g@CNORACLE1>which ld /usr/ucb/ld ora10g@CNORACLE1>cd /usr/ccs/bin ora10g@CNORACLE1>ln -s /usr/ucb/ld ld ln: cannot create ld: File exists ora10g@CNORACLE1> how to link it to /usr/ccs/bin? (6 Replies)
Discussion started by: SmartAntz
6 Replies

7. UNIX for Dummies Questions & Answers

deleted /usr

I accidentally deleted the usr on/. How can I start the server again? (5 Replies)
Discussion started by: rahmantanko
5 Replies

8. Solaris

Directory should not be deleted, But the contents can be

Hi Guys, I have an user's home directory set to /home/A And A contains the following directories B & C Is there some way in solaris by which i can prevent the directories B and C from getting deleted by the user but the contents of the directories B & C can be deleted ? Also i have... (2 Replies)
Discussion started by: localhost
2 Replies

9. UNIX for Dummies Questions & Answers

crontab deleted accidently

I issued crontab -r accidently instead of crontab -e..n the crontab file got deleted.. is there a way to retrive it?:-( thank you:( (3 Replies)
Discussion started by: unisam
3 Replies
Login or Register to Ask a Question