Warning: Trying to access array offset on value of type bool in /data/www/freeminded.org/www/wp-content/plugins/wp-latex/wp-latex.php on line 39 Not-so-everyday Linux tools @ Freeminded.org Warning: Trying to access array offset on value of type bool in /data/www/freeminded.org/www/wp-content/plugins/wp-latex/wp-latex.php on line 46

Not-so-everyday Linux tools

This entry was posted by on Saturday, 17 April, 2010 at

This is a list of some helpful linux tools

1 Audio
2 Bluetooth:
3 Code Project Management:
4 Disk/filesystem:
5 File Conversions:
6 File Parsing (also general scripting):
7 Gnuplot:
8 Keyboard:
9 Random Numbers
10 Security

Audio files:
Encode a wave to mp3 with insane stereo quality:

lame -v q -m s infile.wav outfile.mp3

Decode an mp3 to wave:

lame --mp3input --decode input.mp3 output.wav

Decode a .mpc file to wave
mppdec-static in.mpc out.wav
pipe to lame to re-encode into mp3:
mppdec-static in.mpc | lame -v q -m s outfile.mp3

Mp3 support in K3B can be obtained by installing package libk3b2-mp3.

hcidump – hci level packet sniffer
hcitool – perform basic Bluetooth operations on device

Code Project Management:
cvs (howto at http://www.linux.ie/articles/tutorials/cvs.php)
svn (home at http://subversion.tigris.org/ , svn book at http://svnbook.red-bean.com/)
kdesvn (home at http://kdesvn.alwins-world.de/)

du – estimate file space usage, du -h gives human-readable output.
df – report filesystem disk space usage, df -h gives human-readable output, df -T shows the fs types.

File Conversions:
epstopdf [my_image.eps] – outputs a my_image.pdf file with correct BoundingBox, cropped to the image size and correctly dimensioned.

File Parsing (also general scripting):
Awk – The AWK manual at http://people.cs.uu.nl/piet/docs/nawk/
cat – output a file
head / tail – select only head or tail portion of file, tail -f to follow the tail of the file.
paste – merge file1 and file2 to become [col1 col2] (add as column)
cut – inverse of paste, split [col1 col2] into file1 or file2
sort – alphabetically (default), numerically (-n), reverse (-r), based on key in column 5 (-k5), etc
tac – output a file in reverse (inverse cat)
uniq – reports on unique lines, uniq -c provides counts of occurence
wc – counts words, wc -l counts lines

Some other commandline one-liners:

Not so Frequently Asked Questions:
Gnuplot site: http://gnuplot.sourceforge.net/ (contains demos)

Generic gnuplot usage with gp file to plot points in x,y dimensions:
gnuplot makeplot.gp > plot.eps

1 set terminal postscript eps enhanced
2 set key box
3 plot "out.txt" using 1:2 title 'data' with points

To make PDF plots:
gnuplot makeplot.gp | epstopdf --filter > plot.pdf

xev – print contents of X events such as key input
showkey – examine the scan codes and keycodes sent by the keyboard

Random Numbers
Example: need random number between 100 and 1000:
http://ramalokehrota.blogspot.com/2007/04/random-numbers-in-python.html uses python:

bash_variable=$(python -c "import random;
randval=random.uniform(100,1000); print randval")

http://linux.byexamples.com/archives/128/generating-random-numbers/ uses /dev/random and awk:
echo $(( 100+(`od -An -N2 -i /dev/random` )%(1000-100+1) ))

In stead of reading from /dev/random or /dev/urandom, one can also use the shell variable $RANDOM and use awk to calculate so as not to get trouble with bash’ integer-math.

pwgen – generate pronounceable passwords which are still as secure as possible

Leave a Reply