How Not to Use Shell Commands

Jun 20, 2007 / By Alex Gorbachev

Tags: ,

Here are a few nice typos that had quite disastrous consequences.

After having fought some network problems to get a distribution of Oracle installation binaries from OTN to a Linux box, a colleague found a revolutionary way to unpack a cpio archive:

$ cpio -idmv > ship.db.lnx32.cpio

We saved few gigs of space, by the way, but the installer didn’t work — ksh: ./runInstaller: not found. Weird.

Another interesting case involves changing permissions on a directory tree starting from current working directory:

/opt (root)# chown -R oracle:dba .*

Hm… it turned out that it wasn’t necessary — the whole OS was owned by oracle anyway.

Now more serious one. The best way to tar your database files:

/oracle/opt/oradata/ORCL> ls
control01.ctl     logmnr_tbs01.dbf  system01.dbf
control02.ctl     redo01.log        temp01.dbf
control03.ctl     redo02.log        temp02.dbf
dbmd01.dbf        redo03.log        tools01.dbf
dbmd_idx01.dbf    strmtbs01.dbf     undotbs01.dbf
dbvb01.dbf        sysaux01.dbf      users01.dbf
/oracle/opt/oradata/ORCL> tar cvf * ../ORCL.tar

Right, a controlfile is good but a “stuffed” controlfile is much better! Now you know why controlfile multiplexing is good even within the same directory.

One Response to “How Not to Use Shell Commands”

  • SimonH says:

    A useful post – worth thinking through why the commands went wrong (might make a good opening question for a technical interview).

    My worst example of this was once:

    $ mv bigfile1 bigfile2 stage

    where bigfile1 and bigfile2 had taken all night to download over a 56k modem and the stage directory doesn’t exist. Since then I have always put a / on the end of the directory name, though fortunately I don’t think modern Unixes let you make this mistake (I’ve just tried Solaris10 and it says “mv: stage not found”).

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>