01.06.08
Posted in E-Mail at 10:03 pm by ben
I've written a little script to delete spam untouched 14 days in the spam folder, to be used on qmailrocks installations (or any server running vpopmail).
It's a bit long and untidy to paste into a blog post so I've uploaded it here.
I've also added this to the end of the SpamAssassin on QMR HowTo.
Technorati Tags: Scripting, Bash, QMR
Permalink
11.30.07
Posted in Linux General at 9:56 pm by ben
A few weeks ago I wrote about xMing for sending the graphical output of Linux apps to a Windows PC. This raised my curiosity so I've been finding out more about X Forwarding and what else you can do with SSH.
From one Linux PC to another it's really easy to forward X apps. Just start the SSH session using:
ssh -X user@server
Then any applications you launch, for example '/usr/local/firefox &' will open on the local display. If this doesn't work, check if the line "X11Forwarding yes" exits in the remote machine's /etc/ssh/sshd_config.
To forward an entire desktop, press CTRL+ALT+F1to start a new console, and then use this (presuming the desktop is Gnome):
xinit -e ssh -XCT user@remote gnome-session -- :1
To get this to work I had to use :2 instead of :1, as screen 1 was in use by X server running on the remote machine. One other observation I noted was pressing CTRL+ALT+F7 to return to my local display worked, but CTRL+ALT+F1 back to tty1 gave me a text console in a hung state and I had to push CTRL+C to exit from it.
Authentication without a password
One last goodie I discovered which unfortunately only seems to work on my Ubuntu machines at home, is a nice way to send your local SSH dsa key to the authorized_keys file on a remote computer. Here is the manual way (which I have previously been using), I am sending my local SSH key to user ben on ubuntu:
ssh-keygen -t dsa
Here it asks you if you want to set up a passphrase. Say no.
scp ~/.ssh/id_dsa.pub ben@ubuntu:~/`hostname`.pub
Enter the password and the file will be copied over to the remote machine to ben's home folder.
ssh ben@ubuntu
cat your_hostname.pub >> ~/.ssh/authorized_keys
exit
Now user ben will be able to connect to ubuntu without a password.
The quick way
The more streamlined way which works on Ubuntu (and not on CentOS), is:
ssh-keygen -t dsa
ssh-copy-id -i ~/.ssh/id_dsa.pub ben@ubuntu
I've had a quick scout around and this seems to be a little script not included in the openSSH package by default, which explains why it's missing from a few distributions.
Technorati Tags: SSH
Permalink
11.29.07
Posted in Linux General at 9:47 pm by ben
Here's another thing I only learned recently - using man -k to search for a man page that contains a string of text. E.g.
man -k wireless
iwconfig (8) - configure a wireless network interface
iwevent (8) - Display Wireless Events generated by drivers and setting changes
iwgetid (8) - Report ESSID, NWID or AP/Cell Address of wireless network
iwlist (8) - Get more detailed wireless information from a wireless interface
iwpriv (8) - configure optionals (private) parameters of a wireless network interface
iwspy (8) - Get wireless statistics from specific nodes
wireless (7) - Wireless Tools and Wireless Extentions
I wish someone had told me about this a few years ago!
Technorati Tags: bash, man pages, linux admin, linux newbie
Permalink
Posted in Scripting at 9:41 pm by ben
Here's how to make a script terminate unless it's run by a specific user, in this case the user is called ben:
#!/bin/bash
#
#Set environment variables
LOGGED_ON_USER=`whoami`
REQUIRED_USER=ben
if [ $LOGGED_ON_USER != $REQUIRED_USER ]; then
echo "Sorry. You need to run this script as $REQUIRED_USER."
exit 1
fi
#
#Script content goes here
#
You can also turn this around. For example, make the script exit if it is being run as root:
LOGGED_ON_USER=`whoami`
BANNED_USER=root
if [ $LOGGED_ON_USER == $BANNED_USER ]; then
echo "Sorry. You cannot run this script as $BANNED_USER."
exit 1
fi
For more details on using tests in square brackets in bash, see the man page for test (man test) and for information on if statements, see man bash.
Technorati Tags: bash, scripting, Linux
Permalink
11.20.07
Posted in Linux General at 2:07 pm by ben
We have a very old server at work which frequently runs out of disk space. It doesn't have X installed so each time this happens I use the command line to find out what has eaten up the disk space. A bit of research the first time this happened added a new command to my repertoire - du. Think of du as df's little brother. Where df -h (-h gives you human readable format) will tell you how much disk space is available on file system, du will scan within a directory tree and tell you which directories are the largest. This is how it works:
du / - -max-depth=1 -h
That IS a double-dash before max-depth, but wordpress auto-formats it into a single dash. :-(
Of course instead of scanning the file system from / (root), you can specify any directory in your file system, and recurse into as many levels as you need by changing the max-depth value.
In the example of my very old server, it was an application called logwatch that kept rolling up syslogs and dumping them on / which only had 300Mb of free space. The drive itself was only 500Mb (yes I know, it's a really old server!). Removing the 0logwatch symlink from /etc/cron.daily (which pointed to ../log.d/scripts/logwatch.pl) stopped this from happening.
Technorati Tags: Disk Space, Linux, Administration
Permalink
10.21.07
Posted in Linux General at 9:55 pm by ben
Since I seem to use Linux a lot at work these days, I thought it would be useful to have a dual boot laptop for those occasions when a Linux to Linux connection makes things a bit easier.The nc6400 is a newish HP laptop with an integrated ATI mobility X1300 video card, 1Gb of RAM, and a widescreen display (1280x800).
Why Debian?
I've always thought Debian is a superb distro, probably because of Apt - which in my opinion is the best package manager around. I do use Ubuntu on my server but I have found the more recent releases of Ubuntu to be fairly hopeless when it comes to hardware detection, the nc6400 was a prime example of that where it completely failed to load wlan or display drivers, I couldn't even get X working with a vesa driver (and when this happens, you know you're in for a struggle).
The challenges
- Getting wireless to work - presumably through Ndiswrapper
- ATI mobility video drivers
- Fully utilising the Core Duo processor - this could mean some tinkering with the kernel
- Laptop stuff - like going into standby when the lid is closed, low battery warnings, and graceful shutdown when the battery is drained
Getting started
Since this laptop already has Windows installed, I downloaded the GParted live CD to repartition my hard drive. Gparted actually has a few options in the Grub menu for HP laptops but none of them worked correctly for me - for some reason it would not resize my NTFS partition. Luckily there was a 5Gb FAT32 HP recovery partition sitting there wasting space, so that was cleared to make room for Linux. I downloaded the latest Debian Etch netinstall CD, connected the RJ45 ethernet to my router and ran through the install.
A few minutes later I had a basic Debian system installed. The first thing I wanted to do was install Gnome, but for some reason my Apt sources did not contain any of the Gnome packages. I modified my sources.list to this:
deb http://ftp.debian.org/debian/ etch main contrib non-free
deb http://security.debian.org/ etch/updates main contrib
deb http://www.debian-multimedia.org etch main
I was then able to apt-get install gnome-desktop-environment. Strangely, an X server is not installed as a dependency when you do this so you also have to install the x-window-system package, and select the vesa driver and a resolution of 1024x768. After this is done you can start doing things in Gnome.
Sound and video
Setting up sound is a no brainer. Open up synaptic and install alsa-base, alsa-utils and gnome-audio. Then drop to a terminal and run alsaconf, and when prompted pick the integrated Intel card from the list.
Configuring the ATI video driver was a lot easier than I expected. You simply download the Linux ATI Mobility driver, make it executable with a chmod 755 and then run it from within your X windows session. Its the exact opposite to installing an Nvidia driver, where you have to quit X Windows and kill GDM before you can launch it. Once it's installed, run aticonfig --initial, then reboot. I also installed the 915resolution package for 1280x800 resolutions, but I'm not sure if I really need it.
Wireless LAN
You need the Windows drivers and Ndiswrapper to get the Broadcomm card up and running. Grab the Windows drivers from the HP website. It's an exe file, you can open it using 7-Zip in Windows and extract the .inf and .sys files. Then I would recommend following this article. One last thing is getting the wlan0 adapter to start automatically when you reboot. I've added this to /etc/network/interfaces:
iface wlan0 inet dhcp
wireless-essid cupotea
wireless-key my_key
wireless-enc on
wireless-keymode open
wireless-mode managed
There's something not right with this at the moment as I still have to manually initialize my card using iwconfig and dhclient after I log in. I've run out of time today and will revist this and the remaining issues in part 2.
Technorati Tags: nc6300, Linux, Debian, ATI on Linux, Linux on Laptops
Permalink
10.10.07
Posted in Linux General at 10:09 pm by ben
XMing is free software that allows you to launch X-Window apps on a remote Linux server, and have the output appear on your local Windows PC. What makes this different from XWinLogon or NoMachine (FreeNX), is you only get the application on your local machine, rather than a full desktop environment. Think of it as a free version of Citrix server for Linux.
There are 2 ways you can use it - the first is to start XLaunch, select "Disable Server Access Control" and send it to the system tray. Then start Putty and connect to your Linux computer. Use ipconfig to find your IP address, and then use the following command to pipe your X-Window sessions to your local display:
export DISPLAY=192.168.0.101:0
Then launch your apps (such as xterm, xcalc, /usr/bin/firefox, etc) in the Putty window and watch them appear on your Windows desktop. Very cool.
The other way to do it is to configure your remote application and save it as a shortcut, then just double click on the shortcut to load the app. If you have configured SSH key pairs to connect to your Linux computer, you can start your Linux apps in Windows without it prompting for a password. This is a 5 step process:

1. Configure display settings - single or multiple windows

2. Choose 'start a program'.

3. Configure your program and connection

4. Configure clipboard settings

5. Save settings.
Then just double click the shortcut to launch the application ...

Technorati Tags: xming, remote x server, Linux
Permalink
09.02.07
Posted in Cobalt Qube3 at 9:49 am by ben
I haven't used my Qube for a while but occasionally I notice fresh links back to old Qube3 posts on this site. This one caught my eye and is worth linking back to:
Installing Ubuntu 6.04 on the Cobalt Qube3
It's a very extensive guide covering all areas in detail from backing up and upgrading the PROM to booting the Qube from NFS and configuring Ubuntu. I need a new case fan and hard drive for my Qube as it's a bit noisy but if I ever find myself with the replacement hardware and a few hours on my hands (perhaps this is not all that likely) I would like to give this a try. If I do I'll be sure to post the results up here.
Technorati Tags: Qube3, Cobalt Qube
Permalink
08.29.07
Posted in Free stuff, Software at 7:36 pm by ben
I've used FileZilla for a while and would definitely rate it as the best free FTP client out there. The other day when downloading it I noticed they also offer another free download on their site - FileZilla Server. As you might guess it's an FTP server for Windows.
It installs using a standard wizard and runs as a service, and seems to be a decent replacement for Microsoft's FTP service (which can be installed as an IIS component in Add/Remove programs). I actually prefer the layout of FileZilla Server admin interface to the IIS FTP server, it's laid out in a more logical manner with all of the options accessable from 2 dialog boxes.

FileZilla Server
As well as all the usual stuff like creating FTP users and groups, and configuring the FTP shared folders, the admin interface also uses it's own TCP port and optional password for additional security, and within the settings there are far more configurable options than in the XP IIS FTP server, such as IP filters, transfer buffer size, speed limits (throttling), and quite a lot more.
If running this on Windows XP just remember to open port 21 on your Windows firewall as this is not open by default, as well as on your router to allow the connections through.
Technorati Tags: FileZilla, FileZilla Server, FTP Server
Permalink
08.27.07
Posted in Blogging at 9:22 am by ben
I've fixed an error on this blog with [Got a packet bigger than 'max_allowed_packet' bytes] appearing after posting a comment. The culprit was the Google Sitemaps plugin - disabling it made the problem go away. I looked into it a bit further and noticed I was actually using a beta version of this plugin (3.0b), and rolled back to 2.7 which fixed it properly. The problem must have started after one of the recent version upgrades to Wordpress 2.x.
I also had to remove the Text Control plugin as it had completely screwed up the formatting on my SpamAssassin on QmailRocks page. One unfortunate side effect of that is that elements of that page are now 'texturised', in particular this affects quotation marks, meaning any code containing the ' or " characters can't be copied and pasted into a terminal window anymore as the syntax will be completely wrong. If anyone knows another way (using a plugin or not) to turn off the texturise feature on Wordpress 2.x I would very much like to know...
Note to self ... must test all Wordpress plugins after every version upgrade ...
Technorati Tags: Wordpress, Google Sitemaps
Permalink
« Previous entries