Useful Linux Commands

This page lists some of the less common, but highly useful linux commands, or some new, exciting ways to use a command.

cu – Call up another system

cu can be used to establish a link across a serial port. Personally I have used it to connect to the console port on a cisco router.

cu -l /dev/ttyS0

ldd – print shared library dependencies

Ever download a binary build of an app and can’t get it to work. I run across this all the time. Due to convenience or availability of source code I attempt to install an rpm or debian package onto my Slackware machine and it doesn’t work. ldd can help you find out what libraries the binary in question is dependant on.

Using find to list files that DON’T match a pattern
n the jargon of the find command, statements are comprised of primaries and operands. Want to match a specific filename pattern? Use -name “pattern”. Here’s the magic, though: want to negate the primary? Just preface it with -not.

Put these together and here’s the easy way to find all files that don’t have an underscore:

find -not -name “*_*” -print

This is a bit too broad, actually, because I presume that you don’t want to match directories if you can help it. This is done by adding the primary -type f. If you’d like to further constrain your search results to just those files in the current directory (remember, find likes to traverse entire file trees, not just the current directory) you can add -maxdepth 1. Change the “1” to a “2” and you’ll get only the current directory and matches one level deeper.

Put it all together and even toss in a second filename conditional to screen out files with dashes in their names and here’s what you end up with:

find . -not -name “*_*” -and -not -name “*-*” -maxdepth 1 -type f -print

Experiment with this command and some of the further constraints you can put on it by using various find primaries, and I think you’ll be suitably impressed!
Created 2003-01-28 12:00:00 by converted
Updated 2005-01-25 23:56:50 by robertjw
How to get bc to give decimal places
The command line calculator bc is a great little tool. Just type it in, type your expression, press enter and get an answer.

The problem is that by default bc doesn’t give any digits after the decimal point. The easiest way to get around this problem is envoke bc with a -l option

bc -l

Personally I put this command in my .bashrc as an alias

alias bc=’bc -l’

So every time I run bc I get digits after the decimal point. The -l option also has the added benefit of enabling other more advanced math routines like sine, cosine, arctangent, exponential, natural logarithm and Bessel functions.

Leave a Reply

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