Showing posts with label cygwin. Show all posts
Showing posts with label cygwin. Show all posts

/usr/bin/python: bad interpreter: Permission denied error



This is my OLD blog. I've copied this post over to my NEW blog at:

http://www.saltycrane.com/blog/2008/05/usrbinpython-bad-interpreter-permission/

You should be redirected in 2 seconds.



I have a Python script, myscript.py with a #!/usr/bin/python shebang* at the top and tried to execute it on Ubuntu Linux using ./myscript.py. I got the following error message:
 
bash:  ./myscript.py: /usr/bin/python: bad interpreter: Permission  denied
 
Here are things to check:
  • The file should be executable (use chmod +x myscript.py)
  • The file shoud have Unix line endings
  • The file shouldn't be on a fat32 or ntfs filesystem. Apparently, bash can't handle scripts that are stored on fat32 or ntfs
* #!/usr/bin/env python would be the more portable shebang

[Read the full post...]

How to paste in Cygwin bash using CTRL-V



This is my OLD blog. I've copied this post over to my NEW blog at:

http://www.saltycrane.com/blog/2008/05/how-to-paste-in-cygwin-bash-using-ctrl/

You should be redirected in 2 seconds.



I come from a Windows background where Cut/Copy/Paste are almost always CTRL+X/C/V respectively. I like this consistency, so adjusting to Cygwin's (or other *nix environments') use of SHIFT+INSERT or the middle mouse button for pasting in terminals is a little annoying. After a bit of googling, I found a mailing list thread that solved my problem.

This method uses a modification to readline's ~/.inputrc configuration file, so it should work in rxvt, xterm, or even the default cmd.exe shell. Here is what to do:

Add the following line to your ~/.bashrc:
stty lnext ^q stop undef start undef
And add the following line to your ~/.inputrc:
"\C-v": paste-from-clipboard

These modifications will unmap stty's lnext (literal next-character) and readline's quoted-insert settings which are normally mapped to CTRL-V. For more details, see this cygwin mailing list thread.

Note, this appears to be a Cygwin-specific solution. Linux users could use custom key bindings in gnome-terminal or konsole, or translation tables with xterm.


Useful commands for reference:
$ bind -p
$ stty -a

[Read the full post...]

How to install Mercurial 1.0 on Cygwin



This is my OLD blog. I've copied this post over to my NEW blog at:

http://www.saltycrane.com/blog/2008/04/how-to-install-mercurial-10-on-cygwin/

You should be redirected in 2 seconds.



Mercurial 1.0 has been released and I just posted, How to install Mercurial 1.0 on Ubuntu Gutsy (or Hardy). Here are instructions for installing Mercurial 1.0 on Cygwin.

Install Mercurial 1.0
  1. Install Python Easy Install
    $ cd /tmp
    $ wget http://peak.telecommunity.com/dist/ez_setup.py
    $ python ez_setup.py
  2. Install Mercurial 1.0
    $ easy_install -U mercurial
  3. Trying hg version, gives me a ImportError: Permission denied error. Apparently, there is a Eggs/Cygwin problem. To fix it, make the dll files executable:
    $ chmod +x /usr/lib/python2.5/site-packages/mercurial-1.0-py2.5-cygwin-1.5.25-i686.egg/mercurial/*.dll
Try hg version again:
Mercurial Distributed SCM (version 1.0)

Copyright (C) 2005-2008 Matt Mackall  and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Install hgk extension
I'm not sure how to get hg view working in Cygwin. If anyone knows, please let me know.
[Read the full post...]

Install coLinux (and Ubuntu Hardy) on Win XP using Slirp to internet and TAP to host behind a corporate firewall/proxy server



This is my OLD blog. I've copied this post over to my NEW blog at:

http://www.saltycrane.com/blog/2008/04/install-colinux-and-ubuntu-gutsy-on-win/

You should be redirected in 2 seconds.



coLinux allows you to run a full Linux distribution, such as Ubuntu Hardy, on top of Windows at near native speeds. It runs as a single Windows process with its own specially allocated address space. The guest linux system can run from either a separate disk partition or from a single file on your Windows filesystem.

My initial impression of coLinux was so positive, I had planned to name this post, Goodbye Cygwin, hello coLinux. After 2 months of using coLinux, I still am using Cygwin a little bit. Despite being slow, (almost unbearably slow with my company's mandatory Whole Disk Encryption), Cygwin is good at integrating the GNU tools with Windows. Currently, I am still using Cygwin to script my Windows-only project version control system and use the Cygwin version of Mercurial for my personal version control. I'm not sure if using the Linux version of Mercurial would work on Samba shares. The more I learn about Linux and the less I depend on Windows applications, the less I will need Cygwin. (Update: Mercurial 1.0 works great on Samba shares. The important thing is to setup the owner of the share to be your user id and not root. See samba config below.)

Besides that, coLinux is great. The best part for me was being able to run the dynamic, tiling, scriptable, keyboard-driven window manager, wmii. I access Windows files (and network drives) using Samba. Shell commands, emacs, ssh are all there and are so fast. GUI applications such as Firefox, OpenOffice and Gimp are available as well. However, these are slow with the slirp networking setup. With a TAP connection between coLinux and the host OS, these apps run well, however, I couldn't get the TAP connection to work in conjuction with internet access so I settled for slirp only. If I figure this out, I will update the post. Here are my install notes.

Update 4/28/2008: I got my private TAP connection to the host working along with a slirp connection for internet. This makes my X server connections fast enough to run all my GUI apps like OpenOffice, evince kpdf for pdf files, and my web browser. See this section for details.


Contents

Install coLinux
  1. Download the coLinux installer and the Ubuntu root file system image
  2. Run the coLinux Windows installer
    • Accept defaults except for:
    • Destination Folder: change to c:\coLinux
    • You do not need to install WinPCap library.
    • You will get a warning dialog saying that "TAP-Win32 Adapter V8 (coLinux)" has not passed Windows Logo testing. Click "Continue Anyway"

Configure CoLinux
I already had Cygwin running so I did this stuff in a bash shell. You can use Windows commands as well to do the same thing.
  1. Copy Ubuntu-6.06.1.ext3.1bg.bz2 to c:\coLinux. (Keep a copy of this file as a backup to revert your Ubuntu filesystem if you mess things up.)
  2. Decompress the Ubuntu file system image. (Note, this could take a minute or more depending on your system.)
    $ cd /cygdrive/c/coLinux
    $ bunzip2 Ubuntu-6.06.1.ext3.1gb.bz2
  3. Create a swap file
    $ dd if=/dev/zero of=swap_device bs=1M count=512
    $ dd if=/dev/zero of=swap_device.2gb bs=1M count=2K
    (In Windows, you can use fsutil file createnew swap_device 536870912 )
  4. Create a configuration file
    $ cp example.conf colinux.conf
    Edit colinux.conf and set the following:
    cobd0="c:\coLinux\Ubuntu-6.06.1.ext3.1gb"
    cobd1="c:\coLinux\swap_device"
    mem=512
    eth0=slirp
    eth1=tuntap # only needed for TAP connection
    The following items should already be set by default:
    kernel=vmlinux
    root=/dev/cobd0
    ro
    initrd=initrd.gz

Run CoLinux
  1. Open a Windows cmd.exe shell
  2. cd c:\colinux
  3. colinux-daemon.exe -t nt @colinux.conf
    (the -t nt is optional but makes it easier to copy/paste)
  4. login as "root" with password "root"
  5. Try commands such as ls, pwd, etc.
  6. To exit, use the halt command.

Configure networking with slirp only
  1. If you use a http proxy server to get to the internet, do the following inside the running CoLinux session:
    root@ubuntu:~# echo "export http_proxy='http://your-proxy-server.com:yourportnumber'" >> .bash_profile
    root@ubuntu:~# source .bash_profile
  2. Otherwise, there is nothing to do. The Ubuntu image already has the correct /etc/network/interfaces and /etc/resolv.conf files setup.

    /etc/network/interfaces should look like this:
    # This file describes the network interfaces available on your system
    # and how to activate them. For more information, see interfaces(5).
    
    # The loopback network interface
    auto lo
    iface lo inet loopback
    
    # The primary network interface (slirp)
    auto eth0
    iface eth0 inet static
       address 10.0.2.15
       broadcast 10.0.2.255
       netmask 255.255.255.0
       gateway 10.0.2.2
    

  3. /etc/resolv.conf should look like this:
    nameserver 10.0.2.3
  4. To test internet access, use something like wget since ping doesn't work with slirp.
    root@ubuntu:~# wget www.google.com

Configure networking with slirp to internet and TAP to host
In this configuration, I set up TAP to form a private connection to the host and slirp to access the internet. If you want to use X applications, this will make the response much better than with slirp only. I had to play around with the IP addresses to find one that didn't conflict with the static IP addresses on our network. I ended up choosing "10.0.3.16" for the TAP colinux address and "10.0.3.17" for my Windows side.
  1. TAP should be installed when you install coLinux
  2. In Windows, go to "Start", "Control Panel", "Network Connections"
  3. Find the "TAP-Win32 Adapter V8 (coLinux)" adapter. For me, it was named "Local Area Connection 2". Right click on it and select "Properties".
  4. On the "General" tab, scroll down and select "Internet Protocol (TCP/IP)". Click on "Properties".
  5. Select "Use the following IP address:". Enter in "10.0.3.17" for the "IP address:" and "255.255.254.0" for the "Subnet mask:". Leave the rest blank. Click "OK" twice to finish.
  6. in coLinux, edit /etc/network/interfaces to look like the following:
    auto lo
    # Loopback interface
    iface lo inet loopback
    
    # Network interface for internet access (slirp)
    auto eth0
    iface eth0 inet static
       address 10.0.2.15
       broadcast 10.0.2.255
       netmask 255.255.255.0
       gateway 10.0.2.2
    
    # Network interface for private connection to Host OS (tap-win32)
    auto eth1
    iface eth1 inet static
       address 10.0.3.16
       network 10.0.3.0
       netmask 255.255.254.0
       broadcast 10.0.3.255
  7. Make sure your "colinux.conf" file has the following lines:
    eth0=slirp
    eth1=tuntap
  8. You will need to set your DISPLAY variable to "10.0.3.17:0"
    root@ubuntu:~# export DISPLAY=10.0.3.17:0

Update your Ubuntu Dapper installation
  1. root@ubuntu:~# apt-get update
    You can ignore the following warning:
    W: GPG error: http://security.ubuntu.com dapper-security Release: Could not exec
    ute /usr/bin/gpgv to verify signature (is gnupg installed?)
    W: GPG error: http://fr.archive.ubuntu.com dapper-updates Release: Could not exe
    cute /usr/bin/gpgv to verify signature (is gnupg installed?)
    W: GPG error: http://fr.archive.ubuntu.com dapper-backports Release: Could not e
    xecute /usr/bin/gpgv to verify signature (is gnupg installed?)
    W: GPG error: http://fr.archive.ubuntu.com dapper Release: Could not execute /us
    r/bin/gpgv to verify signature (is gnupg installed?)
    W: You may want to run apt-get update to correct these problems
  2. root@ubuntu:~# apt-get upgrade
    Answer yes to prompts.
  3. That was easy.

Run an Xterm and other apps

Warning, getting the X Window System working properly was one of the most frustrating parts of the setup for me. The behavior seemed to be even non-deterministic. This is what worked for me. You may need to consult other sources to get it working for you. I am starting to read X Power Tools to learn more about the X Window System and will update this section if I learn anything new. I used Cygwin's X server because I already had Cygwin installed. Another option is Xming.

Update 5/6/2008: After switching to the Slirp+TAP networking configuration, I've been getting errors when trying to start my X clients:

$ xeyes
No protocol specified
Error: Can't open display: 10.0.3.17:0
$ xterm
No protocol specified
xterm Xt error: Can't open display: 10.0.3.17:0
$ urxvt
No protocol specified
urxvt: can't open display 10.0.3.17:0, aborting.
To resolve this, I have been starting up a Cygwin bash shell, and running the xhost + command to disable access control. This worked, but it was annoying to do this all the time. I discovered that there is a -ac command line option to Xwin which will do the same thing. I've updated my batch file below to reflect this. Here is a list of all the Xwin command line options:
use: X [:] [option]
-a #                   mouse acceleration (pixels)
-ac                    disable access control restrictions
-audit int             set audit trail level
-auth file             select authorization file
bc                     enable bug compatibility
-br                    create root window with black background
+bs                    enable any backing store support
-bs                    disable any backing store support
-c                     turns off key-click
c #                    key-click volume (0-100)
-cc int                default color visual class
-co file               color database file
-core                  generate core dump on fatal error
-dpi int               screen resolution in dots per inch
-deferglyphs [none|all|16] defer loading of [no|all|16-bit] glyphs
-f #                   bell base (0-100)
-fc string             cursor font
-fn string             default font name
-fp string             default font path
-help                  prints message with these options
-I                     ignore all remaining arguments
-ld int                limit data space to N Kb
-lf int                limit number of open files to N
-ls int                limit stack space to N Kb
-logo                  enable logo in screen saver
nologo                 disable logo in screen saver
-nolisten string       don't listen on protocol
-noreset               don't reset after last client exists
-reset                 reset after last client exists
-p #                   screen-saver pattern duration (minutes)
-pn                    accept failure to listen on all ports
-nopn                  reject failure to listen on all ports
-r                     turns off auto-repeat
r                      turns on auto-repeat 
-render [default|mono|gray|color] set render color alloc policy
-s #                   screen-saver timeout (minutes)
-sp file               security policy file
-su                    disable any save under support
-t #                   mouse threshold (pixels)
-terminate             terminate at server reset
-to #                  connection time out
-tst                   disable testing extensions
ttyxx                  server started from init on /dev/ttyxx
v                      video blanking for screen-saver
-v                     screen-saver without video blanking
-wm                    WhenMapped default backing-store
-x string              loads named extension at init time 
-maxbigreqsize         set maximal bigrequest size 
+extension name        Enable extension
-extension name        Disable extension
-query host-name       contact named host for XDMCP
-broadcast             broadcast for XDMCP
-indirect host-name    contact named host for indirect XDMCP
-port port-num         UDP port number to send messages to
-from local-address    specify the local address to connect from
-once                  Terminate server after one session
-class display-class   specify display class to send in manage
-cookie xdm-auth-bits  specify the magic cookie for XDMCP
-displayID display-id  manufacturer display ID for request
The X Keyboard Extension adds the following arguments:
-kb                    disable the X Keyboard Extension
+kb                    enable the X Keyboard Extension
[+-]accessx [ timeout [ timeout_mask [ feedback [ options_mask] ] ] ]
                       enable/disable accessx key sequences
-ar1                   set XKB autorepeat delay
-ar2                   set XKB autorepeat interval
-noloadxkb             don't load XKB keymap description
-xkbdb                 file that contains default XKB keymaps
-xkbmap                XKB keyboard description to load on startup
-depth bits_per_pixel
 Specify an optional bitdepth to use in fullscreen mode
 with a DirectDraw engine.
-emulate3buttons [timeout]
 Emulate 3 button mouse with an optional timeout in
 milliseconds.
-engine engine_type_id
 Override the server's automatically selected engine type:
  1 - Shadow GDI
  2 - Shadow DirectDraw
  4 - Shadow DirectDraw4 Non-Locking
-fullscreen
 Run the server in fullscreen mode.
-refresh rate_in_Hz
 Specify an optional refresh rate to use in fullscreen mode
 with a DirectDraw engine.
-screen scr_num [width height [x y] | [[WxH[+X+Y]][@m]] ]
 Enable screen scr_num and optionally specify a width and
 height and initial position for that screen. Additionally
 a monitor number can be specified to start the server on,
 at which point, all coordinates become relative to that
 monitor (Not for Windows NT4 and 95). Examples:
  -screen 0 800x600+100+100@2 ; 2nd monitor offset 100,100 size 800x600
  -screen 0 1024x768@3        ; 3rd monitor size 1024x768
  -screen 0 @1 ; on 1st monitor using its full resolution (the default)
-lesspointer
 Hide the windows mouse pointer when it is over an inactive
 Cygwin/X window.  This prevents ghost cursors appearing where
 the Windows cursor is drawn overtop of the X cursor
-nodecoration
 Do not draw a window border, title bar, etc.  Windowed
 mode only.
-mwextwm
 Run the server in multi-window external window manager mode.
-internalwm
 Run the internal window manager.
-rootless
 Run the server in rootless mode.
-multiwindow
 Run the server in multi-window mode.
-multiplemonitors
 EXPERIMENTAL: Use the entire virtual screen if multiple
 monitors are present.
-clipboard
 Run the clipboard integration module.
 Do not use at the same time as 'xwinclip'.
-nounicodeclipboard
 Do not use Unicode clipboard even if NT-based platform.
-scrollbars
 In windowed mode, allow screens bigger than the Windows desktop.
 Moreover, if the window has decorations, one can now resize
 it.
-[no]trayicon
 Do not create a tray icon.  Default is to create one
 icon per screen.  You can globally disable tray icons with
 -notrayicon, then enable it for specific screens with
 -trayicon for those screens.
-clipupdates num_boxes
 Use a clipping region to constrain shadow update blits to
 the updated region when num_boxes, or more, are in the
 updated region.  Currently supported only by `-engine 1'.
-[no]unixkill
 Ctrl+Alt+Backspace exits the X Server.
-[no]winkill
 Alt+F4 exits the X Server.
-xkbrules XKBRules
 Equivalent to XKBRules in XF86Config files.
-xkbmodel XKBModel
 Equivalent to XKBModel in XF86Config files.
-xkblayout XKBLayout
 Equivalent to XKBLayout in XF86Config files.
 For example: -xkblayout de
-xkbvariant XKBVariant
 Equivalent to XKBVariant in XF86Config files.
 For example: -xkbvariant nodeadkeys
-xkboptions XKBOptions
 Equivalent to XKBOptions in XF86Config files.
-logfile filename
 Write logmessages to  instead of /tmp/Xwin.log.
-logverbose verbosity
 Set the verbosity of logmessages. [NOTE: Only a few messages
 respect the settings yet]
  0 - only print fatal error.
  1 - print additional configuration information.
  2 - print additional runtime information [default].
  3 - print debugging and tracing information.
-[no]keyhook
 Grab special windows key combinations like Alt-Tab or the Menu key.
 These keys are discarded by default.
-swcursor
 Disable the usage of the windows cursor and use the X11 software cursor instead
You can view this list by typing Xwin --help in a Cygwin bash shell. Also, in the process, I tried the Xming X server. However, I couldn't get it to work with wmii, so I decided to stick with Cygwin's X server.

  1. Edit your startxwin.bat file (located in "C:\cygwin\usr\X11R6\bin") so that it starts X in rootless mode, with clipboard support, disables access control, and doesn't run anything else. Run the new bat file.
    @echo off
    SET DISPLAY=127.0.0.1:0.0
    SET CYGWIN_ROOT=\cygwin
    SET RUN=%CYGWIN_ROOT%\bin\run -p /usr/X11R6/bin
    SET PATH=.;%CYGWIN_ROOT%\bin;%CYGWIN_ROOT%\usr\X11R6\bin;%PATH%
    SET XAPPLRESDIR=/usr/X11R6/lib/X11/app-defaults
    SET XCMSDB=/usr/X11R6/lib/X11/Xcms.txt
    SET XKEYSYMDB=/usr/X11R6/lib/X11/XKeysymDB
    SET XNLSPATH=/usr/X11R6/lib/X11/locale
    if not exist %CYGWIN_ROOT%\tmp\.X11-unix\X0 goto CLEANUP-FINISH
    attrib -s %CYGWIN_ROOT%\tmp\.X11-unix\X0
    del %CYGWIN_ROOT%\tmp\.X11-unix\X0
    :CLEANUP-FINISH
    if exist %CYGWIN_ROOT%\tmp\.X11-unix rmdir %CYGWIN_ROOT%\tmp\.X11-unix
    
    %RUN% XWin -clipboard -silent-dup-error -rootless -ac
  2. If you are using Slirp-only networking:
    • Obtain your Windows host IP address by opening a cmd.exe shell and running ipconfig
    • In coLinux, set your DISPLAY variable to this IP address:
      root@ubuntu:~# export DISPLAY=xxx.xxx.xxx.xxx:0.0
      where xxx.xxx.xxx.xxx is your IP address. Don't forget the :0.0 at the end.
  3. If you are using TAP plus Slirp configuration described above, set your DISPLAY variable to "10.0.3.17:0"
    root@ubuntu:~# export DISPLAY=10.0.3.17:0
  4. root@ubuntu:~# apt-get install xterm
    Answer yes to prompts.
  5. root@ubuntu:~# xterm&
    Xterm comes up!
  6. You can now install and run other high level apps like firefox or emacs

Expand the root file system image
You will need to expand the size your root filesystem image to hold the larger Ubuntu installation. I expanded it to 4GB for Xubuntu Hardy and am currently using about 87% of that. You might want to expand it to 5GB or more especially if you will be installing a lot of apps. See http://colinux.wikia.com/wiki/ExpandingRoot for more information. Note, Google's calculator function can be useful for calculating block sizes. (e.g. entering in 4GB / 16KB into the Google search box returns: (4 gigabytes) / (16 kilobytes) = 262 144)
  1. If you have coLinux running, shut it down, with halt
  2. In a Cygwin bash shell, make a copy of your current image.
    $ cp Ubuntu-6.06.1.ext3.1gb Ubuntu-6.06.1.ext3.4gb
    This may take a while.
  3. Expand the new file:
    $ dd bs=16384 if=/dev/zero of=Ubuntu-6.06.1.ext3.4gb seek=65536 count=262144

    bs=16384 sets the blocksize to 16KB
    seek=65536 skips the first 65536 blocks (1GB/16KB = 65536)
    count=262144 adds 262144 blocks to the image (4GB/16KB = 262144)

    This may take a while also. It should display the following when complete:
    262144+0 records in
    262144+0 records out
    4294967296 bytes (4.3 GB) copied, 154.362 s, 27.8 MB/s
  4. Change your colinux.conf file to use the new file system image:
    cobd0="c:\coLinux\Ubuntu-6.06.1.ext3.4gb"
  5. Switch back to the cmd.exe console, and start coLinux again
  6. root@ubuntu:~# apt-get install ext2resize
  7. root@ubuntu:~# ext2online /dev/cobd0
  8. Look at your available space:
    root@ubuntu:~# df
    Filesystem           1K-blocks      Used Available Use% Mounted on
    /dev/cobd0             4128448    411148   3507624  11% /
    varrun                  128096        36    128060   1% /var/run
    varlock                 128096         0    128096   0% /var/lock
    devshm                  128096         0    128096   0% /dev/shm
  9. Note, you may want to make a backup copy of your new expanded root file system image at this point in case things get hosed up later on. Be sure to halt coLinux first. Note, this will take even longer than the 1gb filesystem copy.

Upgrade to Ubuntu Hardy
Update 4/28/2008: When I first installed coLinux, Ubuntu Gutsy was the latest release. Because there was no direct upgrade path from Ubuntu 6.06 Dapper to Ubuntu 7.10 Gutsy, I had to incrementally upgrade from Dapper to Edgy, Edgy to Feisty, and Feisty to Gutsy. Later, when Hardy came out, I upgraded from Gutsy to Hardy. If you are upgrading to Dapper to Hardy for the first time, you can use the incremental method, or the direct method. Ubuntu supports a direct upgrade from 6.06 Dapper Drake to 8.04 Hardy Heron because both are Long Term Support (LTS) releases. See the Ubuntu upgrade documentation for more information. Note, I did not test the direct upgrade method.
  1. In coLinux:
    root@ubuntu:~# apt-get update
  2. root@ubuntu:~# apt-get install ubuntu-minimal
  3. root@ubuntu:~# apt-get install ubuntu-standard
  4. root@ubuntu:~# apt-get install xubuntu-desktop
  5. Edit your sources.list file and change "dapper" to "edgy"
    root@ubuntu:~# nano /etc/apt/sources.list
  6. root@ubuntu:~# apt-get update
  7. root@ubuntu:~# apt-get upgrade
  8. root@ubuntu:~# apt-get dist-upgrade
  9. Change "edgy" to "feisty" in /etc/apt/sources.list and repeat steps 6-8.
  10. Change "feisty" to "gutsy" in /etc/apt/sources.list and repeat steps 6-8.
  11. Change "gutsy" to "hardy" in /etc/apt/sources.list and repeat steps 6-8.
  12. Remove unneeded packages:
    root@ubuntu:~# apt-get autoremove

Disable some startup services
This is optional but may give you fewer warnings. In coLinux, go to the /etc/rc2.d directory and follow the instructions in the README file for disabling services. Here are some suggested services to disable:
  • acpid, acpi-support, apmd: used for power management
  • bluetooth: used for bluetooth
  • hotkey-setup: used to configure laptop hotkeys
  • pcmciautils: tools for PCMCIA cards (PC cards)
  • powernowd: controls CPU speed and voltage using the sysfs interface
  • vbesave: used to save the video card state

Configure Ubuntu
  1. Don't start gdm (the display manager which starts the X server)
    root@ubuntu:~# mv /etc/rc2.d/S13gdm /etc/rc2.d/K87gdm
  2. Set the timezone
    Start your Cygwin X server if it is not already running.
    root@ubuntu:~# time-admin &
    Set your timezone.
  3. Set the root password
    root@ubuntu:~# passwd
  4. Set local machine name:
    root@ubuntu:~# nano /etc/hostname
    root@ubuntu:~# nano /etc/hosts
  5. Create a user account
    root@ubuntu:~# adduser sofeng
    Note, adduser is a higher level command than useradd. adduser will set up a group and home directory.
  6. Set permissions on /dev/tty* (Note: not sure if this is needed)
    root@ubuntu:~# chgrp tty /dev/tty*
    Edit /etc/group to have the following line:
    tty:x:5:sofeng
  7. Make a pty device
    root@ubuntu:~# cd /dev
    root@ubuntu:~# MAKEDEV pty
  8. Add environment variables to .bash_profile
    Use the printenv command to list your environment variables.

Create a home filesystem image
  1. Create a 10GB blank file. In Cygwin,
    $ dd if=/dev/zero of=home-fs-image.10gb bs=1M count=10K
  2. Add the following to your c:\coLinux\colinux.conf file:
    cobd2="c:\coLinux\home-fs-image.10gb"
  3. Restart coLinux, then do the following:
    Create an ext2 file system on the new disk image
    root@ubuntu:~# mke2fs -F /dev/cobd2
    Turn this into an ext3 filesystem
    root@ubuntu:~# tune2fs -i 0 -j /dev/cobd4
  4. Mount the new filesystem to /home
    root@ubuntu:~# mv /home /home_backup
    root@ubuntu:~# mkdir /home
    root@ubuntu:~# mount /dev/cobd2 /home
    Check it worked:
    root@ubuntu:~# df
  5. To mount the filesystem automatically at startup, add the following line to your /etc/fstab:
    /dev/cobd2   /home   ext3   defaults   0 0

Setup the swap file
  1. Add the following to /etc/fstab:
    /dev/cobd1   swap   swap   defaults  0 0
  2. Initialize the swap partition
    root@ubuntu:~# sudo mkswap /dev/cobd1
  3. make use of swap now, without rebooting system:
    root@ubuntu:~# swapon -a
  4. Check that swap total is non-zero:
    root@ubuntu:~# free

Mount Windows filesystem as Samba share
  1. Setup Windows networking:
    • In Windows Explorer, right click on your C: drive and select "Properties"
    • Click on the "Sharing" tab
    • Select "Share this folder". Set the "Share name:" to "E$". Setup "Permissions" as necessary.
  2. create the location for your samba share:
    $ sudo mkdir -p /mnt/cdrive
  3. add the following to /etc/fstab:
    //yourcomputer.example.com/E$ /mnt/cdrive smbfs auto,user,rw,dir_mode=0777,file_mode=0777,uid=sofeng,gid=sofeng,credentials=/etc/smb-credentials 0 0
    /mnt/cdrive is the mount point
    smbfs means it is a samba filesystem type
    auto means it will be mounted at startup
    user means any user can mount it
    rw means it will be readable and writable
    file_mode=0777 specifies that files will be readable, writable, and executable by everyone (this replaces the deprecated fmask)
    dir_mode=0777 specifies that directories will be readable, writable, and executable by everyone (this replaces the deprecated dmask)
    uid=sofeng means the owner is sofeng
    gid=sofeng means the group is sofeng
    credentials=/etc/smb-credentials specifies the file that contains the user name and password
  4. create /etc/smb-credentials
    username=yourdomain\yourusername
    password=yourpassword
    $ sudo chmod 600 /etc/smb-credentails
  5. Mount the drive:
    $ sudo mount /mnt/cdrive

Set up wmii window manager
  1. Install wmii window manager
    apt-get install wmii
  2. I use emacs so the following steps are used to change the mod key.
  3. Download KeyTweak for Windows and remap your "Left Windows" key to "Context Menu".
  4. Use xmodmap to setup the "Menu" key to be "mod4". For my keyboard, my ~/.Xmodmap file looks like this:
    clear mod4
    keycode 115 =
    keycode 127 =
    keycode 117 = Super_L
    add mod4 = Super_L
    Then run xmodmap in one of your startup scripts (.xinitrc, .bash_profile, etc.)
    xmodmap ~/.Xmodmap

[Read the full post...]

How to get a summary of disk usage with du



This is my OLD blog. I've copied this post over to my NEW blog at:

http://www.saltycrane.com/blog/2008/02/how-to-get-summary-of-disk-usage-with/

You should be redirected in 2 seconds.



The following command gives me a listing of the sizes of all the directories in my root directory.

$ sudo du -chs /*

Here is the results of that command on my new (1 day old) Dell 530N Ubuntu desktop: (Note, the 5.0GB for the /home directory is due to the 5.0GB ubuntu-dell-reinstall.iso file. The rest of my /home directory is only 18MB.)

4.8M    /bin
18M     /boot
0       /cdrom
128K    /dev
9.1M    /etc
5.0G    /home
4.0K    /initrd
0       /initrd.img
154M    /lib
16K     /lost+found
12K     /media
4.0K    /mnt
13M     /opt
0       /proc
740K    /root
6.3M    /sbin
4.0K    /srv
0       /sys
80K     /tmp
2.1G    /usr
317M    /var
0       /vmlinuz
7.6G    total

To determine disk usage in a different directory, cd to that directory and run sudo du -chs *


[Read the full post...]

How to scroll in GNU Screen



This is my OLD blog. I've copied this post over to my NEW blog at:

http://www.saltycrane.com/blog/2008/01/how-to-scroll-in-gnu-screen/

You should be redirected in 2 seconds.



GNU Screen is great. But, after half a year of using it, I've only now figured out how to scroll into screen's buffer (courtesy of this tutorial). Normally, I just use SHIFT+PGUP to scroll up in urxvt's buffer. However, if I have two regions in screen, this doesn't work. To scroll in screen's buffer, I need to enter "copy mode". To do this, type C-a [ or C-a ESC. (The latter options works great for me because I bound the prefix key to the backtick key instead of C-a.) Once in "copy mode", I can scroll using the arrow keys or PGUP/PGDOWN keys. To exit "copy mode", I press ESC. Scrolling within screen's buffer instead of urxvt's also prevents me from losing my place in my scrollback buffer when I switch screen "windows" (terminal sessions).

Other notes:

  • C-a S splits into two regions
  • C-a tab switches input focus to the next region
  • C-a X kills the current region
  • C-a :resize numlines resizes the current region to numlines lines.


[Read the full post...]

Cygwin tips / howto's



This is my OLD blog. I've copied this post over to my NEW blog at:

http://www.saltycrane.com/blog/2008/01/cygwin-tips-howtos/

You should be redirected in 2 seconds.




cygwin tips / howto's

[Read the full post...]

How to use grep and find to search specific files



This is my OLD blog. I've copied this post over to my NEW blog at:

http://www.saltycrane.com/blog/2007/12/how-to-use-grep-and-find-to-search/

You should be redirected in 2 seconds.



I often use grep to search through the text of my files for search terms such as a variable or function name. For example, since xrange is being removed from Python 3000, I'd like to search for all the occurrences of xrange. Here is how to search all my Python files in the current directory:

$ grep --color "xrange" *.py

Which outputs something like:

dol2lol.py:    for i in xrange(len(dol[keylist[0]])):
dol2lol.py:            for i in xrange(len(dol[keylist[0]]))]
lol2lod.py:#     for i in xrange(len(locols[0])):
lol2lod.py:#         for j in xrange(len(keylist)):
lol2lod.py:    return [dict([(keylist[j], locols[j][i]) for j in xrange(len(keylist))])
lol2lod.py:            for i in xrange(len(locols[0]))]
table_modelview.py:        for row in xrange(nrows):

The above command only works for the current directory. If I want to recurse into subdirectories, I can use:

$ grep -r --color "xrange" .

However, this command often produces too many results because I cannot specify which files to search. To gain better control over which files are searched, I can use grep in combination with the find command. Here is an example which recurses into subdirectories and searches all my Python files for xrange. (I know it's hard to imagine when xrange would be inside anything other than a Python file, but hey, it's just an example.

$ find . -name '*.py' -exec grep --color 'xrange' {} +

Usually, using find with -exec is very slow and xargs is used to gain performance. However, thanks to the tip from Some notes about find, I used the + expression at the end of the commandline which avoids the fork/exec overhead, without using xargs.

As a final example, here is how I search for the text #define in all files in my current directory, excluding my backup files (*~, *.orig, *.bak). In this example, I don't want to recurse into directories, so I set -maxdepth to 1. Note, Some notes about find has some other options about limiting the depth portably, but this option worked for me. Note, this is similar to the command I use as my Emacs grep.

find . -maxdepth 1 ! -regex '.*~$' ! -regex '.*\.orig$' \
    ! -regex '.*\.bak$' -exec grep --color "#define" {} +

[Read the full post...]

Cygwin install tips using cyg-apt



This is my OLD blog. I've copied this post over to my NEW blog at:

http://www.saltycrane.com/blog/2007/11/cygwin-install-tips/

You should be redirected in 2 seconds.



I recently got a new computer at work and needed to reinstall Cygwin. Here is my install procedure using the very nice cyg-apt script. It's like Debian's apt-get for Cygwin! Note, this install process assumes that I have all my init files backed up and can copy them over to my new machine.

  1. Run the Cygwin setup program and install the default packages plus wget and python.
  2. Set the Windows user environment variable HOME to c:\home\sofeng. Note, I tried it with forward slashes, but then it doesn't work in my Windows batch file.
  3. Start the Cygwin bash shell
  4. Change the cygdrive prefix:
    mount -s --change-cygdrive-prefix /
    If you don't have admin privileges:
    mount -u --change-cygdrive-prefix /
  5. Copy over my init files and startup scripts:
    • ~/bin/startxwin.bat
      This is the Windows batch file that I use to start my Cygwin/X environment. It does the following:
      • Adds ~/bin to my PATH
      • cds to my HOME directory
      • Starts the ratpoison window manager with a urxvt terminal running screen
    • ~/.Xdefaults
      Sets the colors, font, and scrolling behavior for urxvt.
    • ~/.bashrc
      • Sets the PS1 (prompt), EDITOR, http_proxy, and other environment variables.
      • Sets a lot of aliases
      • Sets bash filename completion to be case insensitive
    • ~/.cyg-apt
    • ~/.emacs
    • ~/.emacs.d
    • ~/.inputrc
    • ~/.screenrc
    • /etc/ssmtp/ssmtp.conf
    • /var/cron/tabs/sofeng
  6. Install cyg-apt
    $ wget http://www.lilypond.org/~janneke/software/cyg-apt
    $ chmod a+xr cyg-apt
    $ mv cyg-apt ~/bin
  7. Install good stuff (note, if you don't already have ~/.cyg-apt, you will need to run cyg-apt setup first):
    $ cyg-apt install rsync Best backup utility
    $ cyg-apt install screen Terminal multiplexer
    $ cyg-apt install xorg-x11-base X Windows
    $ cyg-apt install rxvt-unicode-X Better Xterm
    $ cyg-apt install diffutils diff
    $ cyg-apt install gcc-core GCC C complier
    $ cyg-apt install make GNU make
    $ cyg-apt install xorg-x11-devel X header and library files for compiling ratpoison or other programs
    $ cyg-apt install readline used for ratpoison
    $ cyg-apt install cron so I can schedule my backups and updatedb
    $ cyg-apt install ssmtp Sendmail replacement so cron can email me
    $ cyg-apt install emacs Terminal version of emacs for quick editing jobs from the shell

Other notes:

  • I thought that I needed to add c:/cygwin/bin to my Windows path in order to use grep in Emacs Windows. However, I later found out that this step is not needed. It is generally bad practice to add c:/cygwin/bin to the Windows path. Instead, I added the required code in my .emacs file. See http://cygwin.com/faq/faq-nochunks.html#faq.using.ntemacs for more information.
  • I used to keep my http proxy server information in ~/.wgetrc, but now I store it in the http_proxy environment variable. (Note, it is lowercase and not uppercase. I don't know why this is.)

[Read the full post...]

How to get anti-aliased fonts for Cygwin with urxvt



This is my OLD blog. I've copied this post over to my NEW blog at:

http://www.saltycrane.com/blog/2007/09/how-to-get-anti-aliased-fonts-for/

You should be redirected in 2 seconds.



urxvt, or rxvt-unicode, is a better alternative to rxvt and xterm that supports xft (read anti-aliased) fonts. Here's how to make your terminal pretty:

You need: Cygwin with X, urxvt, and fontconfig (all available through Cygwin's setup utility)
  1. To see the list of available fonts run: $ fc-list
  2. Select a font and put it in your ~/.Xdefaults file. e.g.
    URxvt*font: xft:Bitstream Vera Sans Mono:size=12
    Urxvt*boldFont: xft:Bitstream Vera Sans Mono:size=12:style=Bold
  3. Run: $ urxvt
For reference, here is the list of fonts I got:
Bitstream Charter:style=Bold
Bitstream Charter:style=Bold Italic
Bitstream Charter:style=Italic
Bitstream Charter:style=Regular
Bitstream Vera Sans Mono:style=Bold
Bitstream Vera Sans Mono:style=Bold Oblique
Bitstream Vera Sans Mono:style=Oblique
Bitstream Vera Sans Mono:style=Roman
Bitstream Vera Sans:style=Bold
Bitstream Vera Sans:style=Bold Oblique
Bitstream Vera Sans:style=Oblique
Bitstream Vera Sans:style=Roman
Bitstream Vera Serif:style=Bold
Bitstream Vera Serif:style=Roman
Charter:style=Bold
Charter:style=Bold Italic
Charter:style=Italic
Charter:style=Regular
Clean:style=Regular
ClearlyU Alternate Glyphs:style=Regular
ClearlyU PUA:style=Regular
ClearlyU:style=Regular
Courier 10 Pitch:style=Bold
Courier 10 Pitch:style=Bold Italic
Courier 10 Pitch:style=Italic
Courier 10 Pitch:style=Regular
Courier:style=Bold
Courier:style=Bold Italic
Courier:style=Bold Oblique
Courier:style=Italic
Courier:style=Oblique
Courier:style=Regular
Cursor:style=Regular
Fixed:style=Bold
Fixed:style=Bold SemiCondensed
Fixed:style=ja
Fixed:style=ko
Fixed:style=Oblique
Fixed:style=Oblique SemiCondensed
Fixed:style=Regular
Fixed:style=SemiCondensed
Helvetica:style=Bold
Helvetica:style=Bold Oblique
Helvetica:style=Oblique
Helvetica:style=Regular
Lucida:style=Sans
Lucida:style=Sans Bold
Lucida:style=Sans Bold Italic
Lucida:style=Sans Italic
LucidaBright:style=Italic
LucidaBright:style=Regular
LucidaTypewriter:style=Sans
LucidaTypewriter:style=Sans Bold
Luxi Mono:style=Bold
Luxi Mono:style=Bold Oblique
Luxi Mono:style=Oblique
Luxi Mono:style=Regular
Luxi Sans:style=Bold
Luxi Sans:style=Bold Oblique
Luxi Sans:style=Oblique
Luxi Sans:style=Regular
Luxi Serif:style=Bold
Luxi Serif:style=Bold Oblique
Luxi Serif:style=Oblique
Luxi Serif:style=Regular
New Century Schoolbook:style=Bold
New Century Schoolbook:style=Bold Italic
New Century Schoolbook:style=Italic
New Century Schoolbook:style=Regular
Newspaper:style=Regular
Terminal:style=Bold
Terminal:style=Regular
Times:style=Bold
Times:style=Bold Italic
Times:style=Italic
Times:style=Regular
Utopia:style=Bold
Utopia:style=Bold Italic
Utopia:style=Italic
Utopia:style=Regular

[Read the full post...]

Cygwin, X, ratposoin, screen, rxvt setup



This is my OLD blog. I've copied this post over to my NEW blog at:

http://www.saltycrane.com/blog/2007/09/cygwin-x-ratposoin-screen-rxvt-setup/

You should be redirected in 2 seconds.



Here are my configuration files for my current Cygwin, X, ratpoison, screen, urxvt, bash setup.

General Cygwin and bash
  • I changed filename completion to be case-insensitive since we're on Windows. To do this, see the last line in ~/.bashrc and the last line in ~/.inputrc below.
  • I changed the "/cygdrive" prefix to just "/". To do this, type this command once: "mount -s --change-cygdrive-prefix /"
  • I added aliases to use "grep" and "ls" with color. And I added aliases to start various windows applications. See ~/.bashrc.
urxvt
  • urxvt (rxvt-unicode) is a better alternative to rxvt and xterm. See the ~.Xdefaults file for my urxvt customizations. I chose an anti-aliased font, removed the scrollbar, changed the background to dark blue and the foreground to light yellow, and set the number of saved lines to 8000. (Note, to scroll, hit SHIFT+PGUP or SHIFT+PGDN).
ratpoison and screen
  • GNU Screen is a terminal multiplexer which can be used to manage terminal sessions. Ratpoison is a simple keyboard driven window manager largely modeled after GNU Screen which is used as an alternative to complex window managers such as Gnome or KDE. Most of the ratpoison and screen configuration is copied from Mark Pilgrim. The layering, as I understand it, is: the Windows XP OS runs the Cygwin/X environment which runs the ratpoison window manager which runs the urxvt terminal emulator which runs the screen terminal multiplexer which runs the bash command shell.
Update 5/2/2008: I learned how to paste in urxvt (actually bash). See my post, How to paste in Cygwin bash using CTRL+V.

startxwin.bat (windows batch file)
@echo off
SET DISPLAY=127.0.0.1:0.0
SET CYGWIN_ROOT=\cygwin
SET RUN=%CYGWIN_ROOT%\bin\run -p /usr/X11R6/bin
SET PATH=.;%CYGWIN_ROOT%\bin;%CYGWIN_ROOT%\usr\X11R6\bin;%PATH%
SET XAPPLRESDIR=/usr/X11R6/lib/X11/app-defaults
SET XCMSDB=/usr/X11R6/lib/X11/Xcms.txt
SET XKEYSYMDB=/usr/X11R6/lib/X11/XKeysymDB
SET XNLSPATH=/usr/X11R6/lib/X11/locale

if not exist %CYGWIN_ROOT%\tmp\.X11-unix\X0 goto CLEANUP-FINISH
attrib -s %CYGWIN_ROOT%\tmp\.X11-unix\X0
del %CYGWIN_ROOT%\tmp\.X11-unix\X0
:CLEANUP-FINISH

if exist %CYGWIN_ROOT%\tmp\.X11-unix rmdir %CYGWIN_ROOT%\tmp\.X11-unix
if "%OS%" == "Windows_NT" goto OS_NT
echo startxwin.bat - Starting on Windows 95/98/Me
goto STARTUP

:OS_NT
echo startxwin.bat - Starting on Windows NT/2000/XP/2003

:STARTUP
%RUN% XWin -rootless -clipboard -silent-dup-error
%RUN% /usr/local/bin/ratpoison
~/.ratpoisonrc
# initial frame and window setup
hsplit
focusright
exec urxvt -e screen -RD

# use Pause as prefix key instead of Ctrl-T
escape Pause

# use global cursor positioning (not per-frame)
warp off

# set appearance of ratpoison status messages and input line
set bgcolor black
set fgcolor grey95
set font -b&h-lucidatypewriter-bold-r-normal-sans-18-180-75-75-m-110-iso8859-1
set inputwidth 1247
set bargravity ne
set barpadding 4 4
msgwait 3

# top-level shortcuts (don't require prefix key)
definekey top C-M-Up focusup
definekey top C-M-Down focusdown
definekey top C-M-Left focusleft
definekey top C-M-Right focusright
~/.Xdefaults
URxvt*background: #000033
URxvt*foreground: #ffffcc
! run "fc-list" for a list of available fonts
URxvt*font: xft:Bitstream Vera Sans Mono:size=12
Urxvt*boldFont: xft:Bitstream Vera Sans Mono:size=12:style=Bold
URxvt*scrollBar: False
URxvt*scrollTtyOutput: False
URxvt*scrollTtyKeypress: True
URxvt*secondaryScroll: True
URxvt*saveLines: 8000
~/.screenrc
shell /usr/bin/bash

# scrollback
defscrollback 8000

# Window numbering starts at 1
bind c screen 1
bind 0 select 10
screen 1

# Create initial windows
screen -t home 1
screen -t myproj 1
screen -t pydev 1
screen -t docs 1
screen -t misc 1

# Set the caption on the bottom line:
# window-list   am/pm
# from http://diveintomark.org/public/2007/03/screenrc
caption always "%{= kw}%-w%{= BW}%n %t%{-}%+w %-= %1` %m/%d/%y %C:%s%a"

# use backtick for prefix key instead of Ctrl-A
escape ``

# use regular audible bell
vbell off

# skip intro
startup_message off

# detach on disconnect
autodetach on
~/.bashrc
# prompt 
# see http://www.ibm.com/developerworks/linux/library/l-tip-prompt/
export PS1="\n\e[31;1m\w\n\e[0m\$ "

# cygwin aliases
alias where='type -a'
alias grep='grep --color'
alias ls='ls --color=auto'
alias la='ls -dlAog --time-style="+%Y %m/%d %H:%M" .*; ls -Xlog --time-style="+%Y %m/%d %H:%M"'
alias ll='ls -Xlog --hide "*~" --hide "*.bak" --hide "*.orig" --time-style="+%Y %m/%d %H:%M"'
alias dir='ll'
alias ec='emacsclient -n '

# directory aliases
alias home='cd ~'
alias progfiles='cd /c/Program\ Files'
alias incoming='cd ~/incoming'

# windows aliases
alias firefox='/c/Program\ Files/Mozilla\ Firefox/firefox.exe &'
alias eclipse='/c/Programs/eclipse3.3/eclipse.exe -vmargs -Xms192m -Xmx192m &'
alias serena='/c/Program\ Files/Serena/vm/win32/bin/pvcsvmnt.exe &'
alias kdiff='/c/Program\ Files/KDiff3/kdiff3'
alias explorer='/c/windows/explorer /e /root,'
alias outlook='/c/Program\ Files/Microsoft\ Office/OFFICE11/OUTLOOK.EXE &'
alias taskmgr='/c/windows/system32/taskmgr.exe &'
alias word='/c/Program\ Files/Microsoft\ Office/OFFICE11/WINWORD.EXE '
alias excel='/c/Program\ Files/Microsoft\ Office/OFFICE11/EXCEL.EXE '
alias powerpoint='/c/Program\ Files/Microsoft\ Office/OFFICE11/POWERPNT.EXE '
alias acrobat='/c/Program\ Files/Adobe/Acrobat/Acrobat.exe '

# Get bash filename completion to be case insensitive - there is also a line in .inputrc
shopt -s nocaseglob
~/.inputrc
# the following line is actually
# equivalent to "\C-?": delete-char
"\e[3~": delete-char

# VT
"\e[1~": beginning-of-line
"\e[4~": end-of-line

# kvt
"\e[H": beginning-of-line
"\e[F": end-of-line

# rxvt and konsole (i.e. the KDE-app...)
"\e[7~": beginning-of-line
"\e[8~": end-of-line

# VT220
"\eOH": beginning-of-line
"\eOF": end-of-line

# Get bash filename completion to be case insensitive - see also .bashrc
set completion-ignore-case on

[Read the full post...]

backing up with rsync



This is my OLD blog. I've copied this post over to my NEW blog at:

http://www.saltycrane.com/blog/2007/08/backing-up-with-rsync/

You should be redirected in 2 seconds.



Here is a python script using rsync to backup my Users directory in Vista to an external hard drive.
import os

cmd = "rsync -avz --exclude '/AppData/'" + \
      "/cygdrive/c/Users/sofeng" + \
      "/cygdrive/f/backup/Users"
os.system(cmd)
Why not to use the backup program that comes with your external hard drive:
Do not, whatever you do, feed your valuable data to a program that is going to save it in a file format that can only be read by that program, or by that kind of computer. Because when the program can’t or the computer can’t, you’re out of options. --Tim Bray, Protecting Your Data
Why to use rsync: rsync -essh -rtpvz rocks. --Mark Pilgrim, Essentials


[Read the full post...]

My software tools list



This is my OLD blog. I've copied this post over to my NEW blog at:

http://www.saltycrane.com/blog/2007/08/current-configuration/

You should be redirected in 2 seconds.



Below is a table of my current software configuration. If you notice a lot of "I switched from ..." statements, keep in mind that I am a programmer who likes shiny things.

Category Currently using Comments
Operating System Ubuntu 8.04, Windows XP, Windows Vista Work Desktop: Ubuntu Hardy via coLinux on Windows XP and Cygwin when needed.
Home Laptop: dual-boot Windows Vista with Cygwin and Ubuntu Hardy
Home Desktop: Ubuntu Hardy

I am in the process of migrating from Windows to Linux. My first Ubuntu install was in 2007 (dual-boot) and I got my first Windows-free machine in 2008. Currently I am using Cygwin and coLinux when on Windows. Cygwin integrates better with Windows applications, but coLinux is super fast and allows you to run a full Linux distro on top of Windows. Windows does have some advantages, but overall I prefer Linux.

I don't have enough experience with OSX to draw any authoritative conclusions, though I think Mark Pilgrim has biased me against Apple. Also, I think Linux's free as in beer (and somewhat related free as in speech) characteristics vs. Mac's expensive (and somewhat related proprietary) characteristics resonate with the cheap engineer in me.

Additional Linux vs. Mac commentary from some A-list geeks:
Window Manager wmii Dynamic, tiling, scriptable window manager that doesn't require a mouse. It sucks less.

I switched from ratpoison at the same time I started using coLinux because running native Linux allowed me to use any Linux window manager as well.

Recently, some have switched from wmii to xmonad, the new Haskell tiling window manager. It has some nice features over wmii, including dual head support, but after a brief excursion, I slightly prefer wmii's way of doing things.

If you're a hard core Lisper, stumpwm is the window manager for you. It has a REPL. This one seems a little too hard core for me, especially since I don't know Lisp (yet).

Other options: ion, dwm, awesomewm

Editor/IDE GNU Emacs Switched from Eclipse in 2007. It was a slow transition, but worth it. I think Emacs is definitely worth the investment if you do a lot of coding.

Terminal urxvt +
screen
urxvt supports xft (anti-aliased) fonts, real transparency (not that I actually use transparency with wmii), and fading (which I do use with wmii) and it is much lighter than gnome-terminal or konsole. screen allows me to switch terminal sessions without ugly tabs, attach to remote sessions, search through the scrollback buffer, and more.

Version Control System Mercurial Switched from Subversion in June 2007. The merging in Mercurial is very nice and can be done without thinking. I do miss Subversion/Subclipse's revision history viewer, file compare, and ability to isolate files apart from changesets.

Compiled Language C Wouldn't mind learning C++. Although, Linus doesn't like it.

Dynamic Language Python 2.5 My love for python is strong. I switched from Perl in 2005 and have no regrets. Object-oriented, easy to read (no more TIMTOWTDI), and smart people use it. I also want to learn Javascript 2 becuase it is the "Next Big Language" and Lisp because it is the "most powerful language".

On Python vs. Ruby: from what I've read, I characterize Ruby as the more expressive language more similar to Perl (than Python is) and Python as the more regimented language. Since I like regimented, I like Python.

On Python vs. Lisp: I've concluded that I lack the intelligence to harness enough of Lisp's power to counteract its non-practicality (e.g. lack of libraries).

Some other links:
Paul Graham: Python is getting closer to Lisp (2002)
Paul Prescod: no it isn't

Web Framework Django I haven't tried much else, but Django is pretty cool.

Here are some links:
Ian Bicking: There's so much more than Rails (2005), What PHP deployment gets right (2008)

Web Browser Conkeror Not to be confused with Konqueror, Conkeror is an emacs-like, keyboard driven, scriptable, Mozilla-based web browser. I've used it almost full time since January 2008. It is still considered alpha stage software so there are a number of bugs. However, it is still pretty sweet. I use Firefox as a backup (and IE Tab for Launchcast and Netflix on Windows). Unfortunately, one of the annoying things in Firefox 2 is present in Conkeror as well-- memory leaks. Based on this Mozilla article and some brief personal experience, Firefox 3 has made fixes in this area. It would be nice if Conkeror could benefit from the Firefox 3 fixes.

Email/PIM Undecided Thunderbird?, Evolution?, Mutt?, Gnus?, Alpine?, Gmail?, Claws Mail?,

I currently use Microsoft Outlook with an Exchange Server at work. Evolution supports Exchange Server through Outlook Web Access (OWA), but I couldn't get it to work for me. Thunderbird (and I assume others) support Exchange through IMAP, but this is only available at work by special request.

Links:
Adam Gomaa chooses Claws Mail over Thunderbird, Evolution, Mutt, and Gnus (2007)

PDF Viewer KPDF Preferred over Gnome's Evince
Screen Capture KSnapshot Courtesy of Mark Pilgrim's essentials list
Graphical diff/merge KDiff3 I started using KDiff a while ago on Windows and have always liked it. I'm thinking, though, since I'm an Emacs person, I ought to use Ediff.
Updated 7/2/2008
[Read the full post...]

Eclipse 3.3 cannot open a file from the command line



This is my OLD blog. I've copied this post over to my NEW blog at:

http://www.saltycrane.com/blog/2007/07/eclipse-33-cannot-open-file-from/

You should be redirected in 2 seconds.



I want to type "eclipse myfile" from the command line and have eclipse open myfile. As of version 3.3, Eclipse can't do this. See this post on the eclipse mailing list and bug report 60289.
 
I like Eclipse a lot, but am considering using emacs. It would be nice if there were a fast, keyboard driven editor/IDE with *functional* graphical decorations. Graphical icons are useful, but it shouldn't mean that the application is slow and requires a mouse.
 
sidenote: ratpoison with Cgywin/X, screen, rxvt, and bash are working great.

UPDATE 7/23/07: Padclipse is a lightweight editor based on Eclipse that allows you to open a file from the command line. You can add plug-ins to Padclipse like Eclipse, however, I could not get all of the Eclipse functionality to work.

[Read the full post...]

How to install ratpoison with Cygwin



This is my OLD blog. I've copied this post over to my NEW blog at:

http://www.saltycrane.com/blog/2007/07/ratpoison-with-cygwin-works/

You should be redirected in 2 seconds.



Running the minimalist ratpoison window manager with Cygwin/X works. You will need to install the following Cygwin packages:

gcc-core
make
readline
xorg-x11-base
xorg-x11-devel

Here is how to install:
  1. Download ratpoison
  2. $ tar xvfz ratpoison-1.4.2.tar.gz
    $ cd ratpoison-1.4.2
    $ ./configure
    $ make
    $ make install
  3. Put the following lines in your startxwin.bat file (and remove the other old %RUN% commands):
    %RUN% XWin -rootless -clipboard -silent-dup-error
    %RUN% /usr/local/bin/ratpoison
  4. Run the startxwin.bat file

UPDATE 11/08/2007:

When I installed this the first time, I had no problems. The second time I installed, after getting a new PC, I got the following error message when running configure:

configure: error: *** Can't find X11 headers and libs
I thought the reason was because I forgot to install the xorg-x11-devel package which contains the X11 headers. But even after installing it, I still got the same error. I could not figure out the reason why configure was not finding the headers and libs. So after searching the GNU autoconf manual, I found a way to specify the X11 headers and libs on the command line.
./configure --x-includes=/usr/X11R6/include/X11/ --x-libraries=/usr/X11R6/lib/
This did the trick. I'm not sure why it worked the first time and not the second time. See the GNU Autoconf manual for more information about the configure script.

See also Cygwin, X, ratposoin, screen, rxvt setup
[Read the full post...]

.screenrc and .Xdefaults (for rxvt)



This is my OLD blog. I've copied this post over to my NEW blog at:

http://www.saltycrane.com/blog/2007/07/screenrc-and-xdefaults-for-rxvt/

You should be redirected in 2 seconds.



Use SHIFT+PGUP and SHIFT+PGDOWN to scroll in rxvt. Here are my .Xdefaults and .screenrc config files. A lot of the .screenrc stuff is from Mark Pilgrim. I don't use his "nowplaying" script, but the caption seems to still work.
 
! ~/.Xdefaults
Rxvt*background: #000033
Rxvt*foreground: #ffffcc
Rxvt*font: 14
Rxvt*geometry: 80x40
Rxvt*jumpScroll: True
Rxvt*scrollBar: False
Rxvt*scrollTtyOutput: False
Rxvt*scrollTtyKeypress: True
 
# ~/.screenrc
shell $SHELL
 
# scrollback
defscrollback 5000
 
# Window numbering starts at 1
bind c screen 1
bind 0 select 10
screen 1
 
# Set the caption on the bottom line:
# window-list <nowplaying> <mm/dd/yy> <HH:MM>am/pm
# from http://diveintomark.org/public/2007/03/screenrc
caption always "%{= kw}%-w%{= BW}%n %t%{-}%+w %-= %1` %m/%d/%y %C:%s%a"
 
# use backtick for prefix key instead of Ctrl-A
escape ``
 
# use regular audible bell
vbell off
 
# skip intro
startup_message off
 
# detach on disconnect
autodetach on

[Read the full post...]

rxvt, GNU screen and bash



This is my OLD blog. I've copied this post over to my NEW blog at:

http://www.saltycrane.com/blog/2007/07/rxvt-gnu-screen-and-bash/

You should be redirected in 2 seconds.



rxvt is a better alternative to the default Cygwin cmd.exe setup. GNU screen is a full-screen window manager that, among other things, allows you to quickly switch between shell sessions. I had some trouble figuring out how to use them together along with bash, so here are my notes on how I did it.
 
In your Cygwin Windows shortcut put:
Target: C:\cygwin\bin\rxvt.exe -e bash --login -i
Start in: c:\cygwin\bin
At the end of your ~/.bash_profile, put the following line:
screen bash
Also, in your ~/.screenrc file (if you have one), make sure your shell command does not have a dash "-" in front. The dash in front will make screen treat the shell as a login shell, executing your "screen" command in your .bash_profile recursively. (see this thread on the zsh mailing list).
 
As a side note, I'm also trying out rsync. After only a small amout of use, I tend to agree with others that it rocks.

[Read the full post...]

About

This is my *OLD* blog. I've copied all of my posts and comments over to my NEW blog at:

http://www.saltycrane.com/blog/.

Please go there for my updated posts. I will leave this blog up for a short time, but eventually plan to delete it. Thanks for reading.