Bash Shell

A quick shell include for setting paths for programs installed in non-traditional locations

Tags: •  •  • 

A page in the Beyond Linux from Scratch manual describes environment variables that should be set when installing software in a non-traditional location (e.g. your home directory).

I've written a sh/bash include that can be included from .bashrc to set these variables, as well as PYTHON_PATH for separately installed Python libraries:

#!/bin/bash
PREFIX=$HOME/usr
export PATH="$PREFIX/bin:$PATH"
export PYTHONPATH="$PREFIX/lib/python2.4/site-packages:$PYTHON_PATH"
export MANPATH="$PREFIX/man:$MANPATH"
export INFOPATH="$PREFIX/info:$INFOPATH"
export LD_LIBRARY_PATH="$PREFIX/lib:$LD_LIBRARY_PATH"
export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH"
export CPPFLAGS="-I$PREFIX/includes $CPPFLAGS"
export LDFLAGS="-L$PREFIX/lib $LDFLAGS"

Best SSH options for X11 forwarding

Tags: •  • 

Many versions of SSH, including the extremely common OpenSSH, provide support a feature known as “X11 forwarding.”

Say on you are on one computer running an X server. You want to be able to run a GUI program on another computer (to, say, access files on it), but display the program on the computer you’re sitting at. SSH’s X11 forwarding lets you do this easily in one command, without having to worry about firewalls and permissions.

But it’s a bit slow. There are several options to SSH that you can use to make things faster.

The “-c” option allows selection of cipher for a connection. The default AES cipher is extremely slow: you can get much better performance out of the arcfour and blowfish ciphers. I’ve noticed arcfour to perform the best, but there have been legitimate complaints in the cryptography community about whether or not it is “secure.” If your paramount concern is security, go with blowfish, as it can be just as fast.

The “-C” option enables compression for an SSH connection. On anything but LAN links, compression can make a big difference. SSH performs packet-based compression. That is, it can only compress the data immediately available to it, whatever may be contained in the packet it is currently processing. This immediately limits how much compression can be done, and results in bad compression ratios. But it is usually better than nothing.

All this can be incorporated into a simple bash alias:

alias ssh-x='ssh -c arcfour,blowfish-cbc -XC'

To run a program “xterm” on machine “baz.example.com” but display its GUI on the local machine, simply run:

ssh-x baz.example.com xterm

Bash function mac2unix

Tags: •  •  • 

A new addition to my .bashrc, a bash function that will swap Macintosh newlines for UNIX ones: function mac2unix() { sed 's/\r/\n/gi' } To use it, pipe it as so:

cat file.txt.bad-newlines | mac2unix > file.txt

This will convert Macintosh newlines from files that Mac friends forgot to upload in ASCII mode. If this is not done, programs will ignore the Macintosh newlines and files will have no newlines, which goes without saying is very annoying.


Syndicate content