How Not to Use Shell Commands

Posted in: Technical Track

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.

Want to talk with an expert? Schedule a call with our team to get the conversation started.

About the Author

What does it take to be chief technology officer at a company of technology experts? Experience. Imagination. Passion. Alex Gorbachev has all three. He’s played a key role in taking the company global, having set up Pythian’s Asia Pacific operations. Today, the CTO office is an incubator of new services and technologies – a mini-startup inside Pythian. Most recently, Alex built a Big Data Engineering services team and established a Data Science practice. Highly sought after for his deep expertise and interest in emerging trends, Alex routinely speaks at industry events as a member of the OakTable.

1 Comment. Leave new

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

Your email address will not be published. Required fields are marked *