Linux Tips and Tricks

Firefox and Thunderbird

Opening URL in Firefox from Thunderbird

Create a script to open a new firefox tab and put it somewhere in your PATH

#!/bin/sh
/usr/local/firefox/firefox -a firefox -remote "openURL($1,new-tab)"

Let's call it firefox.sh. Now edit prefs.js in your Thunderbird profile and add these lines:

user_pref("network.protocol-handler.app.http", "firefox.sh");
user_pref("network.protocol-handler.app.https", "firefox.sh");

Opening telnet URLs in Firefox

Create a script named xtelnet.sh and put it in your PATH

#!/bin/sh
address=`echo $1 | cut -d : -f 2`
port=`echo $1 | cut -d : -f 3`
xterm -e "telnet $address $port"

Using about:config add a preference named network.protocol-handler.app.telnet with a string value xtelnet.sh. If you prefer editing prefs.js add this line

user_pref("network.protocol-handler.app.telnet", "xtelnet.sh");

SSH

Using x2x with ssh

To use host1 mouse and keyboard on host2 type:

host1:~> ssh host2 'x2x -from $DISPLAY -to :0 -east'

You can use -west instead of -east, or swap -from with -to parameters to use host2 mouse and keyboard.

X11 connection rejected because of wrong authentication

ssh says "X11 connection uses different authentication protocol". Check you have TCP enabled (i.e. no -nolisten tcp option) for your X server and try using a tunnel. E.g.

yourhost$ xhost + localhost
yourhost$ ssh -R 6007:localhost:6000 strangehost
strangehost$ env DISPLAY=localhost:7.0 xclock

Strange errors about OpenGL when using ssh and X11 forwarding

Try using -Y command option or ForwardX11Trusted option in your .ssh/config

Logging commands executed by ssh

If you're using bash you can add these lines to your .bashrc file.
if [ -n "$SSH_CONNECTION" ]; then
        LOG=$HOME/log
        date >> $LOG
        echo $SSH_CONNECTION >> $LOG
        echo $BASH_EXECUTION_STRING >> $LOG
fi

SuSE Linux

Persistent Network Interface Names

The binding between NIC mac address and interfaces names (ethXX, wlanXX, and so on ) is stored in /etc/udev/rules.d/30-net_persistent_names.rules: it is a text file and you can edit it (carefully!!) if needed. More info in /usr/share/doc/packages/sysconfig/README.Persistent_Interface_Names.

"ImportError: No module named distutils.core" while installing Python modules

Install python-devel package

Changing permissions on files created by udev

These settings are stored in /etc/udev/rules.d/50-udev.permissions or /etc/udev/rules.d/50-udev-default.rules

Zenwork stuff makes smaller systems unusable

ZMD and its related processes (parse-metadata,update-status) use up to 100% of CPU and a lot of RAM making older system really slow (or draining my laptop battery...) The more repositories you use the slower the system gets expecially when managing packages with YaST: I removed all but SuSE repositories from YaST and now it is usable again and the Novell-ZMD service from startup. I also installed yum and configured it with my preferred repositories.

XScreensaver and APCI

If you use powersave to manage power saving states on your machine everytime the machine resumes from suspend or standby mode it will run xlock. I don't like it because I still prefer XScreenSaver with WindowMaker and I'm not going to to use kpowersave: so I had to edit /usr/lib/powersave/do_screen_saver:

+++ do_screen_saver
@@ -112,7 +112,7 @@
     else
         DPMS=""
     fi
-    xlock_screen_saver
+    xscreensaver_screen_saver
     if [ $? != "0" ]; then
        DEBUG "screen_saver failed for user '$X_USER' event ${EVENT_TYPE}${EVENT_SUBTYPE:+_$EVENT_SUBTYPE}${EVENT_EXT:+_$EVENT_EXT}" DIAG
        ret=1

Misc

Getting all installed rpm packages sorted by size

rpm -qa --queryformat '%{SIZE} %{NAME}\n'| sort -r -n

Automatic reverse DNS zone creation

Take a look at mkrdns

Changing passphrase for a private RSA key with OpenSSL

openssl rsa -in old-key-file -out new-key-file -des3

You can use -des or -idea instead of -des3, If none of these options is specified the key is written in plain text.

Converting a .p7b signed cert to .pem

openssl pkcs7 -inform DER -in server-cert.p7b
	-print_certs -text -out /etc/apache2/ssl.crt/server.crt

Forcing a Stack Trace in Perl

You can force Carp to give a detailed stack trace on croak and carp. This can be enabled using something like: perl -MCarp=verbose script.pl