Table of Contents

Useful Linux Utilities

Useful tools with hard to remember names

Mrxvt

Mrxvt is a multitabbed terminal emulator based on RXVT. It doesn't require any heavy libraries like QT or GTK so it's ideal for a low powered laptop machine.

Place this into your ~/.Xdefaults file for some nicer defaults.

mrxvt.font: 9x15
mrxvt.geometry: 100x30
mrxvt.reverseVideo: True
mrxvt.loginShell: True
mrxvt.scrollbarRight: True
mrxvt.scrollbarStyle: rxvt
mrxvt.bottomTabbar: True
mrxvt.saveLines: 1500
mrxvt.visualBell: True
Mrxvt.macro.Shift+Left: GotoTab -1
Mrxvt.macro.Shift+Right: GotoTab +1

Some tips:

SSH Port forwarding

Forward the webserver (port 127.0.0.1:80) at remote.host to your local machine (port 8080) and allow open this port (8080) on all local interfaces (-g):

$> ssh user@remote.host -L 8080:127.0.0.1:80 -N -g

File Transfer through existing SSH connection

Have you ever been logged into a machine (maybe even over multiple hosts) and then needed a file from you local host on that machine? Using a second connection with scp is a pain in the a** especially with multiple hops. The solution is zssh - a wrapper around SSH and the zmodem protocol.

On you local machine just install it (apt-get install zssh is your friend) and probably add the following to your ~/.bashrc

alias ssh=zssh

When you are on the remote machine just press CTRL-Space to go into interactive mode (very much like FTP). To send a file use this:

sz -e <file>

The -e option works around non 8-Bit clean terminals. You only need the lrzsz and ssh packages installed on the remote machine.

vmstat

Gives you some info about memory stats, IO and CPU states. Give sample rate in seconds as parameter.

#> vmstat 3

dig

This is a powerful replacement for nslookup

Doing a zone transfer if allowed:

$> dig @nameserver domain.tld axfr

Unlocking a CD Writer with cdrdao

If a write failes the writer stays inaccessable sometimes - giving an error like this:

logical unit not ready, long write in progress

Resetting the SCSI or ATAPI bus doesn't help. The tool cdrdao has an option to reset the device properly:

#> cdrdao unlock

===== Copy an audio CD with cdrdao ===== Will use the recorder for reading and writing:

#> cdrdao copy --device 0,0,0 --driver generic-mmc --datafile /exchange/cd.img --eject

Burn an ISO Image with cdrecord

#> cdrecord -v dev=0,0,0 speed=16 driveropts=burnfree image.iso

VIM Setup in source file

You can embed Setup Commands for VIM in the source file. Here is an example for a Shell Script:

#Setup VIM: ex: et ts=2 nowrap syntax=sh :

pgrep and pkill

From the manpage:

pgrep looks through the currently running processes and lists the process IDs which matches the selection criteria to stdout. All the criteria have to match. For example, pgrep -u root sshd will only list the processes called sshd AND owned by root. On the other hand, pgrep -u root,daemon will list the processes owned by root OR daemon.

pkill will send the specified signal (by default SIGTERM) to each process instead of listing them on stdout.

This is a nice replacement for constructions like kill `ps ax|grep 'foo'|grep -v 'grep'|awk '{print $1}'`

nast

Sweet Network Analyzer (http://nast.berlios.de/) or just install the Debian Packages.

I like the -m (map LAN via ARP requests) and the -g (find a gateway host) switches most.

iostat I/O Device Usage Informations

This command-line tool is within the sysstat-package and provides information about the cpu load/usage and/or about basically any device in /dev/. usage: iostat [device [device2..]] [refrehrate in sec] [repeats] refrehsrate defaults to 0, means no repeats at all. repeat defaults to infinite.

iptraf Network Load Informations

This command-line tool displays package information and Usage of several network interfaces. It has a console-graphical interface and serveral configuration options. See man-page.

httrack Website Copier

To fetch a whole site use this command:

$> httrack -K0 -%q0 --keep-alive --urlhack -D http://www.example.com

mplayer / mencoder

This gives you the suggested crop parameters:

$> mplayer -vf cropdetect somemovie.avi

This concats two avi files

$> cat part1.avi part2.avi| mencoder -noidx -ovc copy -oac copy -o output.avi -

For rotating MJPEG movies as produced by the PowerShot S2 IS. This is not completely lossless but the best way I could find:

$> mencoder -vf rotate=2 -ovc lavc -lavcopts vcodec=mjpeg -oac copy -o output.avi input.avi