Archive for the ‘linux’ Category

E-Tech Wireless USB Adapter & Linux

Saturday, June 3rd, 2006

I just got my E-Tech Wireless USB Adapter working under Ubuntu. These where the steps:

  • Plug the device into the usb port
  • Type ‘dmesg’, this shows the following:

  • [4302473.979000] usb 1-2: new full speed USB device using uhci_hcd and address 4[4302474.383000] usb 1-2: Failed to load zd1201.fw firmware file!
    [4302474.383000] usb 1-2: Make sure the hotplug firmware loader is installed.
    [4302474.383000] usb 1-2: Goto http://linux-lc100020.sourceforge.net for more info

  • Go to the Linux ZyDAS zd1201 Driver website and download the latest firmware driver.
  • Unpack the driver:

  • ~/src$ tar xzvf zd1201-0.14-fw.tar.gz
    zd1201-0.14-fw/
    zd1201-0.14-fw/zd1201.fw
    zd1201-0.14-fw/README
    zd1201-0.14-fw/makefile
    zd1201-0.14-fw/zd1201-ap.fw

    Run ‘sudo make install’ in the zd1201-0.14-fw directory. This returned the following error message:

    ~/src/zd1201-0.14-fw$ sudo make install
    INSTALL zd1201.fw zd1201-ap.fw
    Failed: No firmware directory found
    make: *** [install] Error 1

  • So let’s do it ourselves! The command to copy the firmware drivers to the right location is:

  • ~/src/zd1201-0.14-fw$ sudo cp *fw /lib/firmware/`uname -r`

  • Now that the drivers are in place, just pull out the usb stick and plug it in again. In ‘dmesg’ the following section appears:

  • [4303176.729000] usb 1-2: new full speed USB device using uhci_hcd and address 5[4303177.421000] usb 1-2: wlan0: ZD1201 USB Wireless interface
    [4303188.374000] wlan0: no IPv6 routers present

  • Now you can simply configure the new network device using the ‘Networking’ configuration tool which you can find in the ‘System > Administration’ menu.

E-Tech Wireless USB Adapter

Can I ’ssh into ubuntu live cd’ ?

Friday, May 26th, 2006

Answer: Yes you can! But you first need to install the ssh daemon:

ubuntu@ubuntu:~$ sudo apt-get install openssh-server

The server is started automatically after installing. To login remotely, you’ll need to set the password for ubuntu:

ubuntu@ubuntu:~$ sudo passwd ubuntu
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
ubuntu@ubuntu:~$

…or create another user on the system:

ubuntu@ubuntu:~$ sudo adduser brammeleman
Adding user `brammeleman‘…
Adding new group `brammeleman’ (1000).
Adding new user `brammeleman‘ (1000) with group `brammeleman’.
Creating home directory `/home/brammeleman‘.
Copying files from `/etc/skel’
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for brammeleman
Enter the new value, or press ENTER for the default
Full Name []: Brammeleman
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [y/N] y
ubuntu@ubuntu:~$

From another box, you can now login to the system running the live cd. Use the ubuntu username with the password you set or use the newly created account.

Relevant nerdnotes: sshfs demo and Kickstart for Ubuntu Live CD?.

Using bash variables in awk

Friday, April 21st, 2006

While there seems nothing wrong with this:

sign="--"
awk '{if ($1 == $sign ) print $1 }'

..it doesn’t give the intended result. To be able to use bash variables in awk, you first need to assign the variables with the -v option:

sign="--"
awk -v sign="$sign" '{if ($1 == sign ) print $1 }'

From the awk man page:

The option -v followed by var=value is an assignment to be done before (the awk) prog is  executed;  any  number  of  -v  options  may be present.

vncmanager

Saturday, April 1st, 2006

When starting a vnc server, the vncserver script takes care of starting Xvnc with the right command line options. It returns the display number it has chosen for the new desktop session:

$ vncserver

New 'linuxbox:4 (me)' desktop is linuxbox:4

Starting applications specified in /home/user/.vnc/xstartup
Log file is /home/me/.vnc/linuxbox:4.log

It’s important to remember this number because you need it when using vncviewer or if you want to stop the server.
Well, not anymore when using vncmanager!!
Vncmanager integrates listing, starting and stopping vncservers. I initially wrote it to manage vncservers on a cluster of linux machines. The whole setup however, was quite site specific. The script basically queries all the linux nodes for information on running vncservers.
The version published here is adapted for use on a single machine.

The UI is done with dialog which allows you to display input boxes, menus etc. from shell scripts. For example, the following code generates the main menu of vncmanager:

        dialog  --backtitle "vncmanager"    \
                --title "Main menu"  \
                --output-fd 3             \
                --menu "What would you like to do:" 15 65 6 \
                1 "List my running VNC servers"   \
                2 "Start a VNC server"   \
                3 "Stop a VNC server"  \
                4 "Set my VNC password" \
                5 "Quit"

And what’s a new script without screenshots ;-)
screenshot of vncmanager

The multiple hosts version requires some work to make it less dependent on the cluster configuration. I’ll post it here soon.

Sshfs demo

Sunday, March 19th, 2006

Want to play around with sshfs? Sshfs allows you to mount a filesystem of any computer you have ssh access to.
This is all you need to do after booting your PC or Mac with the Ubuntu 5.10 (breezy badger) live cd:

$ wget -O - http://nerdnotes.org/scripts/sshfs.sh.php | sudo sh

Scared to just execute a shell script from the web?
(more…)

Kickstart for Ubuntu Live CD?

Sunday, February 26th, 2006

Wouldn’t it be great to have a kickstart option for the Ubuntu Live CD?
First, kickstart is very convenient. I’ve been using kickstart to install Red Hat and Fedora machines. A kickstart script is a kind of ‘answer file’ containing the answers to the questions otherwise asked during a manual installation. The kickstart procedure is easily extended in the %post section. Everything after this magical keyword is considered a script and executed in the last stage of the installation process. In this script, you can take care of installing cronjobs, printers, update all sorts of config files. You can tell the installer to grab a kickstart file from a web server by adding ks=http://url/to/ks.cfg to the kernel boot parameters.

I was happy to see the kickstart feature introduced in Hoary (Ubuntu 5.04). Some of Red Hats’ kickstart features are still missing, but they might show up in Dapper, which is scheduled for April.
motor kickstart
Secondly, two very cool features of the Live CD are the ability to make changes to the file system and the fact that it comes with a fully functional package management system: APT. After booting, you can simply open a terminal and apt-get install something. Even tried an apt-get update; apt-get upgrade, but be sure to do this just before a coffee break, even better… before lunch!

Ok, so why kickstarting a live cd? All installed packages and modified settings will be lost after rebooting anyway.
Quite some open source projects, like Typo3, Lamppix and schoolTool, are offering demo cd’s. These cd’s boot your pc into a fully configured web-server. If the Ubuntu Live CD would have a kickstart option, these projects could just as well offer a kickstart script for it. Instead of downloading a modified live cd distribution, just download the script that adds some functionality to the live cd you already have lying around.

I’ve once used a similar solution to turn a room of windows computers into a linux course lab. By then, the first ubuntu live cd was based on Morphix. Just two extra lines of code added some kind of kickstart option to the Morphix cd:

#!/bin/sh

# determine the mac address of the first network adapter
mac=`/sbin/ifconfig  | awk  '/HWaddr/ { print $5 }' | head -1`

# download and execute livecd init script
wget -q -O - http://intranet/livecd/init.sh.php?mac=$mac | /bin/sh

The init.sh.php script on the intranet server returned the code to execute at startup. By including the hosts’ mac address, the script is able to return host specific shell scripts. The lab pc’s where booting a script that took care of installing missing packages, mounting nfs home directories, mounting the nfs application directory, setting the root password, start ssh, etc. Think of it as a fat client alternative for LTSP.

If you have any ideas on how to get this into Ubuntu, go ahead!

Plain text formatting

Thursday, February 23rd, 2006

I recently did some fun shell scripting to format plain text. I found out that Links, a text based browser, is your friend when you want to display a nice table on a terminal screen. Links has some command line options for using it as a filter. More precise, an HTML to plain text filter.
Since it is straight forward convert a CSV file into an HTML table, we’re just one step away from plain text.
(more…)

Shell fun!

Sunday, January 8th, 2006

Tijd voor een fijne shell one-liner! Ik heb ergens een scripje lopen dat dagelijks een database backupje maakt. Als er die dag niks aan de database veranderd is, zal de inhoud van de backup hetzelfde zijn als de dag ervoor. Met de volgende regel code ruim je in 1 klap alle duplicaten op:

find . -type f -exec md5sum '{}' \; | sort | awk '{ print $2 " " $1 }' | uniq -d -f 1 | awk '{ print "rm " $1 }' | sh

(more…)

X11 genetwerkt, netgewerkt…

Tuesday, January 3rd, 2006

Heb net geprobeerd X11 op m’n mac open te zetten voor linux machines op het netwerk. Kreeg het niet direct voor elkaar omdat X11 standaard geen netwerk connecties toe laat. Helaas wordt dit nergens in de officiele X11 documentatie van Apple vermeld.

Na wat zoeken blijkt dat je dit alsnog aan kan zetten. Dit doe je met het volgende shell commando:
$ defaults write com.apple.x11 nolisten_tcp -boolean false
Ter controle: In de output van 'nmap localhost' zou een regel '6000/tcp open X11' moeten voorkomen.

Voorbeeld van een grafische sessie vanuit Terminal.app:

  • Start X11
  • Geef met xhost +linuxmachine aan dat je de linux machine toegang geeft tot de X-server
  • Log in op de linux machine
  • Geef daar met export DISPLAY=jemac:0.0 aan dat het sherm van je mac gebruikt moet worden.
  • Test het door bv xclock op te starten op de linux machine

Je kunt het opstarten X11 eenvoudig configureren in de file:
/usr/X11R6/lib/X11/xinit/xinitrc
Ik heb daar bijvoorbeeld het automatisch starten van een xterm uitgezet en de regel 'xhost + linuxmachine' toegevoegd. Zo kan ik X starten zonder dat er vensters tevoorschijn komen en kan ik fijn vanuit Terminal.app blijven werken.

Exposé voor Windows

Monday, December 12th, 2005

Alleen voor Firefox gebruikers dan… en ook voor Linux en Mac OS X. Heb je al Firefox 1.5? Werk je regelmatig met tabs? dan moet je deze extensie beslist installeren. Na de installatie krijg je een knopje links onderin de status balk. Hiermee kun je alle tabs als miniaturen naast elkaar te zien krijgen…. dus net als bij Exposé.
Nou ja, het haalt het er nog niet bij. Het is niet geanimeerd en het is jammer dat je niet terug keert naar je huidige tab als je nog een keer op de knop drukt.

Short-cut: Ctrl + Shift + x, op de Mac is het Appeltje + Shift + x.

Trouwens, er is iets als Exposé voor Windows: IEx, WinPLOSION, Entbloess en Windows Exposer… ik ga ze niet eens proberen ;-)