How Not to Use Shell Commands

By Alex Gorbachev June 20th, 2007 at 3:09 pm
Posted in Group Blog PostsOracle

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.

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Google
  • del.icio.us
  • Facebook
  • bodytext
  • Technorati
  • TwitThis
  • Reddit

One Response to “How Not to Use Shell Commands”

  1. 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

Filling out the following captcha not only allows us to cut down on automated blogspam but also helps digitize books. Please feel free to send comments on this approach directly to Paul at vallee@pythian.com.

NOTE: After submitting your comment, verify that it is added to the blog. New comments will be marked as "waiting for moderation" (we only moderate for spam). If the level of spam is as low as we hope, we will bypass this step.