Ubuntu 7.04 (Feisty Fawn) Initial Setup

This page contains instructions and links for setting up a clean install of Ubuntu 7.04 and Firefox. It was blatantly copied from this page and altered to use my own personal customizations. It serves more or less as a list of programs and Firefox addons/scripts that I've installed for quick reference.

Setup

How-To

Customization

Install nVidia graphics driver

  1. Backup xorg.conf:
    sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.original
  2. Install and enable the nVidia driver: Envy, or:
    sudo apt-get install nvidia-glx-new
    sudo nvidia-glx-config enable
  3. Screen resolution, etc.:
    sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.backup.sync_and_refresh
    sudo gedit /etc/X11/xorg.conf
    
    Find the following section and fix the HorizSync and VertRefresh values:
    Section "Monitor"
                ...
                HorizSync          30-96
                VertRefresh        50-160
    EndSection
    
  4. Disable the nVidia splash screen:
    sudo gedit /etc/X11/xorg.conf
    
    Change:
    Section "Device"
        ...
        Driver "nvidia"
        ...
    EndSection
    
    to:
    Section "Device"
        ...
        Driver "nvidia"
        ...
        Option "NoLogo" "true"
    EndSection
    

Add extra repositories

  1. sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
    sudo gedit /etc/apt/sources.list
    
    Add:
    deb http://us.archive.ubuntu.com/ubuntu/ feisty main restricted universe multiverse
    deb-src http://us.archive.ubuntu.com/ubuntu/ feisty main restricted universe multiverse
    
    deb http://us.archive.ubuntu.com/ubuntu/ feisty-updates main restricted universe multiverse
    deb-src http://us.archive.ubuntu.com/ubuntu/ feisty-updates main restricted universe multiverse
    
    deb http://us.archive.ubuntu.com/ubuntu/ feisty-backports main restricted universe multiverse
    deb-src http://us.archive.ubuntu.com/ubuntu/ feisty-backports main restricted universe multiverse
    
    deb http://security.ubuntu.com/ubuntu feisty-security main restricted universe multiverse
    deb-src http://security.ubuntu.com/ubuntu feisty-security main restricted universe multiverse
    
    ## NTFS-3G
    ## deb http://ntfs-3g.sitesweetsite.info/ubuntu/ edgy main main-all
    ## deb http://flomertens.keo.in/ubuntu/ edgy main main-all
    
    ## Some multimedia stuff
    deb http://mirror.ubuntulinux.nl edgy-seveas all
    
    ## Fonts
    deb http://www.telemail.fi/mlind/ubuntu feisty fonts
    deb-src http://www.telemail.fi/mlind/ubuntu feisty fonts
    
    ## Google Picasa for Linux repository
    deb http://dl.google.com/linux/deb/ stable non-free
     
    
    wget http://flomertens.keo.in/ubuntu/givre_key.asc -O- | sudo apt-key add -
    wget http://mirror.ubuntulinux.nl/1135D466.gpg -O- | sudo apt-key add -
    sudo wget -q http://medibuntu.sos-sts.com/repo/medibuntu-key.gpg -O- | sudo apt-key add -
    gpg --keyserver subkeys.pgp.net --recv-keys 937215FF
    gpg --export --armor 937215FF | sudo apt-key add -
     
    Google repositories setup

General Programs

Setup & Config Packages

  1. NTFS
    sudo cp /etc/fstab /etc/fstab.before.ntfs3g
    sudo gedit /etc/fstab
    
    Add the following to the end:
    /dev/hda1  /media/winxp  ntfs-3g defaults,locale=en_US.utf8 0 0
  2. Font smoothing:
    sudo dpkg-reconfigure fontconfig-config
    sudo dpkg-reconfigure fontconfig
     
  3. Improve graphics performance with Desktop Effects turned on:
    sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.beforeDesktopEffectsPerformance
    sudo gedit /etc/X11/xorg.conf
     
    Append the following in the "Device" section:
    Option "AddARGBGLXVisuals" "True"
    Option "RenderAccel" "True"
    Option "AllowGLXWithComposite" "True"
    Option "backingstore" "True"
    Option "TripleBuffer" "True"
  4. Turn on Num Lock at startup
    sudo cp /etc/X11/gdm/Init/Default /etc/X11/gdm/Init/Default_backup
    sudo gedit /etc/X11/gdm/Init/Default
     
    Find this line:
    ...
    exit 0
    Add the following lines above it
    if [ -x /usr/bin/numlockx ]; then
     /usr/bin/numlockx on
    fi
    
  5. ISO Mounter and Creator

    AcetoneISO

  6. MPlayer:
    sudo sed -i.backup -e's@vo=x11,@vo=xv,@g' /etc/mplayer/mplayer.conf
  7. Make Acroread the default pdf viewer by changing the application/pdf entry of /usr/share/applications/defaults.list:
    sudo sed -i.backup.acroread -e's@application/pdf=evince.desktop@application/pdf=AdobeReader.desktop@g' /usr/share/applications/defaults.list
    
  8. Enable DMA
    Check status:
    sudo hdparm /dev/hda
    Turn it on:
    sudo hdparm -d1 /dev/hda
    Enable it permanently
    sudo gedit /etc/hdparm.conf
    Add the following lines:
    /dev/hdc {
    dma = on
    }
     
  9. Display only one kernel on GRUB menu
    sudo cp /boot/grub/menu.lst /boot/grub/menu.lst_backup-`date +%F`
    sudo gedit /boot/grub/menu.lst
     
    Find this line
    ...
    # howmany=all
    ...
    Replace with the following line
    # howmany=1
    Do not delete the # symbol.
    sudo update-grub
  10. Clean up localisation and orphans
    sudo apt-get install -y localepurge
    sudo deborphan | xargs sudo apt-get -y remove --purge
  11. DVD playback capability and Windows Media and RealPlayer codecs (see also the Restricted Formats page):
    wget -c -P /tmp/ http://www.debian-multimedia.org/pool/main/w/w32codecs/w32codecs_20061022-0.0_i386.deb
    wget -c -P /tmp/ http://www.debian-multimedia.org/pool/main/libd/libdvdcss/libdvdcss2_1.2.9-0.0_i386.deb
    sudo dpkg -i /tmp/w32codecs_20061022-0.0_i386.deb /tmp/libdvdcss2_1.2.9-0.0_i386.deb
     
  12. Setup Java
    sudo update-alternatives --config java
    Select the appropriate Sun Java option.
  13. To add customized entries to the Nautilus right-click context menu, run:
    nautilus-actions-config
    
    and twiddle away.
  14. Apache & PHP setup
    1. Apache config:
      sudo gedit /etc/apache2/apache2.conf
    2. PHP
      sudo gedit /etc/php5/apache2/php.ini
      Look for the 'extension_dir' property. It should be by default '/usr/lib/php5/ext'. If it's not, change it.
  15. MySQL Setup
    1. Before accessing the database by console you need to type:
      mysql -u root
      At the mysql console type:
      mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourpassword');
      A successful mysql command will show:
      Query OK, 0 rows affected (0.00 sec)
      Mysql commands can span several lines. Do not forget to end your mysql command with a semicolon.
      mysql -u root -p
    2. Create a database
      mysql> CREATE DATABASE database1;
    3. Create a user
      mysql> GRANT ALL PRIVILEGES ON *.* TO 'yourusername'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
    4. MySQLAdmin (alternative)
      mysqladmin -u root -p password yourpassword
      mysqladmin -u root -p create database1
  16. Add right-click options in Nautilus for enqueuing and replacing multiple files in Totem.
    1. Run Nautilus Actions:
      nautilus-actions-config
    2. Add an action (for enqueuing media files in Totem) with the following properties:
      • Under the Menu Item & Action tab:
        • Label: Enqueue in Totem
        • Icon: /usr/share/icons/hicolor/scalable/apps/totem.svg
        • Path: totem
        • Parameters: --enqueue %M
      • Under the Conditions tab:
        • Filenames: *
        • Match case: checked
        • Mimetypes:
          application/x-cd-image ; application/ogg ; application/vnd.rn-realmedia ; application/x-extension-m4a ; application/x-extension-mp4 ; application/x-flac ; application/x-matroska ; application/x-ogg ; application/x-shockwave-flash ; audio/mpeg ; audio/mpegurl ; audio/vnd.rn-realaudio ; audio/x-flac ; audio/x-m4a ; audio/x-mod ; audio/x-mp3 ; audio/x-mpeg ; audio/x-mpegurl ; audio/x-ms-asf ; audio/x-ms-asx ; audio/x-ms-wax ; audio/x-ms-wma ; audio/x-pn-aiff ; audio/x-pn-au ; audio/x-pn-realaudio-plugin ; audio/x-pn-realaudio ; audio/x-pn-wav ; audio/x-pn-windows-acm ; audio/x-real-audio ; audio/x-s3m ; audio/x-vorbis+ogg ; audio/x-wav ; audio/x-xm ; image/vnd.rn-realpix ; misc/ultravox ; video/dv ; video/mp4 ; video/mpeg ; video/msvideo ; video/quicktime ; video/vnd.rn-realvideo ; video/x-anim ; video/x-avi ; video/x-flc ; video/x-fli ; video/x-mpeg ; video/x-ms-asf ; video/x-msvideo ; video/x-ms-wmv ; video/x-nsv ; video/x-theora+ogg 
          								
        • Appears if selection contains: Only files
        • Appears if selection has multiples files or folders: checked
    3. Add an action (for replacing media files in Totem) with the same properties as in the previous step, except for the following:
      • Under the Menu Item & Action tab:
        • Label: Replace in Totem
        • Parameters: --replace %M

Enable CD/DVD eject

  1. Enable CD/DVD eject for the current session:
    sudo sysctl dev.cdrom.lock=0
    
  2. Enable CD/DVD eject on startup for future sessions:
    sudo cp /etc/sysctl.conf /etc/sysctl.conf.backup.eject
    sudo gedit /etc/sysctl.conf
    
    Add the following line to the file:
    dev.cdrom.lock=0
    

Smooth Fonts

Mount

  1. ReiserFS partition:
    sudo mount /dev/hdb1 mountPoint -t reiserfs -o notail
    
  2. EXT3 partition:
    sudo mount /dev/hdb1 mountPoint -t ext3 
    
  3. NTFS partition:
    sudo mount /dev/hda1 mountPoint -t ntfs -o nls=utf8,umask=0222
    
  4. FAT32 partition:
    sudo mount /dev/hda1 mountPoint -t vfat -o iocharset=utf8,umask=000
    
  5. CD/DVD:
    sudo mount /media/cdrom0/ -o unhide
    
  6. ISO:
    sudo modprobe loop
    sudo mount file.iso /media/iso/ -t iso9660 -o loop -r
    

Unmount

  1. sudo umount mountPoint
    
  2. Force unmount (if previous step doesn't work):
    sudo umount -l mountPoint
    

Create ISO

  1. Create an ISO from CD/DVD (replace device with dvd, cdrom, or cdrom1):
    dd if=/dev/device  of=file.iso bs=1024
    
    If this step fails with an "input/output error", try various combinations of unmounting/remounting/ejecting the device:
    sudo umount -l /dev/device
    eject /dev/device
    sudo mount /dev/device
    
  2. Create an ISO from a directory:
    mkisofs -o file.iso dir
    

MD5 checksum

  1. Create:
    md5sum file.iso > file.iso.md5
    
  2. Verify:
    md5sum -c file.iso.md5
    

Fix sound

See the Unofficial Ubuntu Starter Guide for more information.

Fix screen resolution

See https://wiki.ubuntu.com/FixVideoResolutionHowto for more information. The following worked for me:

Fix Xine's WMV playback

  1. To fix Xine's WMV playback (only if it is broken):
    cp ~/.xine/catalog.cache ~/.xine/catalog.cache.backup
    gedit ~/.xine/catalog.cache
    
    Find the following section:
    [/usr/lib/xine/plugins/1.0.0/xineplug_decode_w32dll.so]
    size=173768
    mtime=1112804124
    type=131
    api=15
    id=win32a
    version=10000
    supported_types=50593792 52428800 52822016 ... (long line truncated)
    decoder_priority=1
    
    Replace (in this section only):
    decoder_priority=1
    With:
    decoder_priority=7

Fix jumpy/skipping/choppy/stuttering CD/DVD playback

Only follow these steps if you experience choppy CD/DVD playback. See the Unofficial Ubuntu Starter Guide for more information.

  1. Check if DMA is enabled for the appropriate CD/DVD device:
    sudo hdparm -d /dev/device
    
    where device is cdrom, cdrom1, dvd, etc.
  2. If DMA was off for the device, enable it:
    sudo hdparm -d1 /dev/device
    sudo cp /etc/hdparm.conf /etc/hdparm.conf.backup.dma
    sudo gedit /etc/hdparm.conf
    
    Append the following to the /etc/hdparm.conf
    /dev/device {
           dma = on
    }
    
    where device is cdrom, cdrom1, dvd, etc.

Fix "There are differences between boot sector and its backup" error

  1. This is not a fix, but a way to avoid the warning:
    sudo gedit /etc/fstab
    
    Replace:
    /dev/hda1 /media/hda1 vfat defaults,utf8,umask=007,gid=46 0 1
    
    With:
    /dev/hda1 /media/hda1 vfat iocharset=utf8,umask=000 0 0
    
    Note that occurences of hda1 could be different (e.g., hdb2) for you, depending on the disk and partition number of your FAT32 partition.

Set up SSH tunneling

See CFS's "Connecting to Herakles using SSH" page and this example ~/.ssh/config file for information specific to CUCS tunneling.

  1. Set up tunneling to targetHostName.targetDomain via bastionHostName.bastionDomain using port local forwarding on port 2001:
    nano ~/.ssh/config
    
    Add:
    host bastionHostName
    user bastionUserName
    hostname bastionHostName.bastionDomain
    ForwardAgent yes
    LocalForward 2001 targetHostName.targetDomain:22
    
    host targetHostName
    user targetUserName
    hostname localhost
    port 2001
    
  2. Start tunneling:
    ssh -fN bastionHostName
    
  3. SSH to target:
    ssh targetHostName
    
  4. (optional) Set up public key authentication.

Set up SSH public key authentication

Quick explanation:Public key authentication works as follows. First you create a public key and a private key. Think of the public key as being a lock which only opens with the private key. The private key should reside only on your local machine and is stored in encrypted form using a passphrase that you choose when you first create the key. Never send your private key to anyone. The public key is copied to the various systems that you want to access. Once the public key is installed on another system, you can access that system using your private key as authentication. This authentication is done automatically and there is no need for a password entry. You do however need to enter your passphrase in order to decrypt the private key on your local machine in the first place, but you can do this just once per session on your local machine (e.g., when you first log in to your local machine). This will store the decrypted private key in memory until you log out or until you manually tell the local machine to forget the decrypted private key.

  1. Create a private/public key pair on your client:
    ssh-keygen -f ~/.ssh/keyFile -t dsa
    
    I highly recommend using a non-empty passphrase; you can later set up key management so that you only enter your passphrase once per session. You will now have two files in your ~/.ssh folder:
    1. keyFile which contains the private key. Never show or send this file to anyone. Think of this as your secret key.
    2. keyFile.pub which contains the public key. Think of this as a lock that only opens with your secret key. You can send this lock to others so that they can install it in their systems so that you can enter their system with your secret key.
  2. Append the contents of your keyFile.pub to the server's ~/.ssh/authorized_keys2 file. If you don't have access, email the server's admin.
  3. SSH to server:
    ssh -i keyFile serverHostName.serverDomain
    
    Alternatively, you can add the following line to the appropriate host entry in your ~/.ssh/config file:
    IdentityFile ~/.ssh/keyFile
    
    and then ssh to that host as usual without having to use the -i keyFile command line option.
  4. (optional) If you use SSH tunneling and public key authentication with multiple SSH servers, then you will probably run into a "HOST IDENTIFICATION HAS CHANGED" warning. This is because multiple servers are associated with a single hostname (namely, localhost) through the use of port forwarding. You can resolve this issue as follows (assuming port forwarding for the different target servers are on ports 2001, 2002, ...):
    cp ~/.ssh/known_hosts ~/.ssh/known_hosts.backup
    ssh -fN bastionHostName
    ssh-keyscan -H -t rsa,dsa -p 2001 localhost >> ~/.ssh/known_hosts
    ssh-keyscan -H -t rsa,dsa -p 2002 localhost >> ~/.ssh/known_hosts
    ssh-keyscan -H -t rsa,dsa -p ...  localhost >> ~/.ssh/known_hosts
    
  5. (optional) Set up SSH key management so that you only have to enter your passphrase once per session.

SSH key management

The following allows you to set things up so that you only have to enter your SSH key passphrase once per login session.

  1. sudo apt-get install gnome-keyring-manager
    
  2. Activate your keys for the remainder of the session (you'll be prompted for your passphrase):
    ssh-add
    
  3. Deactivate your keys:
    ssh-add -D
    

Reboot (remotely) from Ubuntu into Windows

NOTE: This assumes that you use GRUB to dual boot and that you do NOT use dmraid.

WARNING: In Edgy, after performing the steps below, I ran into GRUB "Error 18: Selected cylinder exceeds maximum supported by BIOS" and could not boot into Ubuntu. To solve this, I had to boot into Ubuntu recovery mode, and then edit /boot/grub/menu.lst and comment out the savedefault line in the Ubuntu stanza. You probably can't do this remotely once you run into this error (since the computer requires a physical CTRL+ALT+DEL to reboot after encountering the error), so make sure to comment out the savedefault before you perform a remote grub-reboot.

  1. If you are rebooting a remote computer, first SSH into the remote computer, and then follow the next steps in the remote terminal.
  2. This step needs to be done only once (and apparently you should NOT do it if you are using dmraid) - you don't have to do this step for subsequent reboots.
    sudo nano /boot/grub/menu.lst
    
    Change:
    default		0
    
    to:
    default		saved
    
    Save and close the file by hitting CTRL+O and then CTRL+X.
  3. Reboot the machine using the appropriate GRUB entry:
    sudo grub-reboot number
    
    where number is the number of lines that show up in your GRUB menu before the "Windows" line (typically 4, 6, or 8). (Don't include the "Windows" line into your count, but do include the "Other operating systems:" line.) For example, number is 4 in this screenshot because there are four lines above the "Windows" option.

Reboot (remotely) from Windows into Ubuntu

NOTE: this assumes that you use GRUB to dual boot, and that Ubuntu is the first boot option in /root/grub/menu.lst.

  1. If you are rebooting a remote computer, first Remote-desktop into the remote computer, and then follow the next step in the remote desktop.
  2. Click "Start / Run..." and enter:
    shutdown /r /t 00
    

Remote desktop to your CUCS computer that is currently running Windows

NOTE: The remote computer must be currently booted in WinXP, so you might have to reboot remotely from Ubuntu to Windows first.

  1. Configure SSH tunneling for CUCS using the example ~/.ssh/config file. The following assumes that in SSH forwards localhost:2011 to CUCS_hostname.u.cs.cornell.edu:3389 on lion (as per your ~/.ssh/config file).
  2. ssh -N -f herakles
    ssh -N -f lion
    
  3. rdesktop -r disk:sync=/home/localDirectory localhost:2011
    
    Note that disk:sync should be set to an absolute (as opposed to relative) path.

Access your CUCS home directories via Samba

NOTE: I find that using SFTP is faster and more reliable.

See CFS's "Samba mounting" page for additional info.

  1. Configure SSH tunneling for CUCS using the example ~/.ssh/config file. The following assumes that in SSH forwards localhost:2017 to smb.cs.cornell.edu:139 on lion (as per your ~/.ssh/config file).
  2. ssh -fN herakles
    ssh -fN lion
    
  3. You can now use either smbclient, which provides an ftp like console:
    smbclient //smb.cs.cornell.edu/win -U userName -W CUCS -I localhost -p 2017
    
    Or smbmount to mount the share:
    smbmount //smb.cs.cornell.edu/win localDir -o ip=localhost,port=2017,username=userName,workgroup=CUCS
    
    And smbumount to unmount it:
    smbumount localDirectory
    

Access your CUCS home directories via SFTP

I find this method faster and more reliable than using Samba.

  1. Configure SSH tunneling for CUCS using the example ~/.ssh/config file.
  2. ssh -fN herakles
    sftp lion
    
  3. For SFTP access via Nautilus, open Nautilus and press CTRL+L and enter one of the following addresses:

    Linux home directory:
    sftp://lion/home/user
    
    Windows home directory:
    sftp://lion/home/WIN/user
    
    Linux Bigbox directory:
    sftp://lion/home/BIGBOX/user
    
    Windows Bigbox directory:
    sftp://lion/home/BIGBOX.win/user
    
  4. For the sake of completeness, the locations of these directories under Windows are:

    Linux home directory:
    \\cucs\home\UNIX\user
    
    Windows home directory:
    \\cucs\home\Windows\user
    
    Windows Bigbox directory:
    \\cs.cornell.edu\home\bigbox\user
    

Rename your computer

  1. Run the following, and then choose the "General" tab, and change the hostname as desired:
    gksudo network-admin
    
  2. (optional) If you access your computer remotely, you might need to tell your DHCP server your host-name.

Relocating the /home directory

IMPORTANT: This only applies if you want to move your home directory to another drive, or if you want to activate an existing home directory on another drive.

  1. (NOTE: Skip this first step if you already have your home directory on the partition you want, e.g., if you've already done this step during a previous installation.) This step copies your current home directory onto the new partition. Let's start by making a new directory to mount the new partition:
    sudo mkdir /mnt/new
    
    Now mount the new partition (e.g., /dev/hdb2) to /mnt/new. If it is an Ext3 partition, use the following:
    sudo mount -t ext3 /dev/hdb1 /mnt/new/
    
    If it is a ReiserFS partition, use the following:
    sudo mount -t reiserfs -o notail /dev/hdb1 /mnt/new/
    
    Now copy your existing home directory to the new partition.
    sudo cp -R -p /home/user /mnt/new/
    sudo chown user:user /mnt/new/user
    sudo umount /mnt/new/
    
  2. Mount the new drive as /home:
    sudo nano /etc/fstab
    
    Assuming your intended home partition is /dev/hdb1, add a line to your /etc/fstab file to automount the partition onto the /home directory. If your intended home partition is Ext3, add the following line just after the main and swap partitions:
    /dev/hdb1 /home ext3 defaults,errors=remount-ro 0 2
    
    If the intended home partition is ReiserFS, use the following:
    /dev/hdb1 /home reiserfs defaults,notail 0 2
    
    Save the file (i.e., press CTRL+O) and exit Nano (i.e., press CTRL+X).
  3. Restart Gnome Desktop Manager.

Disable USplash

  1. (optional) To disable USplash, if, like me, you find it ugly:
    sudo cp /boot/grub/menu.lst /boot/grub/menu.lst.backup
    sudo gedit /boot/grub/menu.lst
    
    Remove the splash option from the appropriate lines. I.e., Change:
    kernel          /boot/... root=... ro quiet splash
    
    to:
    kernel          /boot/... root=... ro quiet
    

Restore Mozilla Firefox and Thunderbird icons

  1. Firefox:
    wget -c -O /tmp/mozilla-firefox.png http://www.cs.cornell.edu/~djm/ubuntu/mozilla-icons/mozilla-firefox.png
    wget -c -O /tmp/document.png http://www.cs.cornell.edu/~djm/ubuntu/mozilla-icons/document.png
    chmod 644 /tmp/mozilla-firefox.png /tmp/document.png
    sudo dpkg-divert --rename /usr/share/pixmaps/mozilla-firefox.png
    sudo dpkg-divert --rename /usr/share/pixmaps/mozilla-firefox.xpm
    sudo dpkg-divert --rename /usr/lib/mozilla-firefox/icons/default.xpm
    sudo dpkg-divert --rename /usr/lib/mozilla-firefox/icons/document.png
    sudo dpkg-divert --rename /usr/lib/mozilla-firefox/chrome/icons/default/default.xpm
    sudo cp /tmp/mozilla-firefox.png /usr/share/pixmaps/mozilla-firefox.png
    sudo cp /tmp/mozilla-firefox.png /usr/share/pixmaps/mozilla-firefox.xpm
    sudo cp /tmp/mozilla-firefox.png /usr/lib/mozilla-firefox/icons/default.xpm
    sudo cp /tmp/document.png /usr/lib/mozilla-firefox/icons/document.png
    sudo cp /tmp/mozilla-firefox.png /usr/lib/mozilla-firefox/chrome/icons/default/default.xpm
     
    
  2. Thunderbird:
    wget -c -O /tmp/mozilla-thunderbird.xpm http://www.cs.cornell.edu/~djm/ubuntu/mozilla-icons/mozilla-thunderbird.xpm
    chmod 644 /tmp/mozilla-thunderbird.xpm
    sudo dpkg-divert --rename /usr/share/pixmaps/mozilla-thunderbird.xpm
    sudo dpkg-divert --rename /usr/share/pixmaps/mozilla-thunderbird-menu.xpm
    sudo dpkg-divert --rename /usr/share/pixmaps/mozilla-thunderbird-pm-menu.xpm
    sudo dpkg-divert --rename /usr/lib/mozilla-thunderbird/chrome/icons/default/mozilla-thunderbird.xpm
    sudo dpkg-divert --rename /usr/lib/mozilla-thunderbird/chrome/icons/default/messengerWindow16.xpm
    sudo dpkg-divert --rename /usr/lib/mozilla-thunderbird/chrome/icons/default/messengerWindow.xpm
    sudo dpkg-divert --rename /usr/lib/mozilla-thunderbird/chrome/icons/default/default.xpm
    sudo cp /tmp/mozilla-thunderbird.xpm /usr/share/pixmaps/mozilla-thunderbird.xpm
    sudo cp /tmp/mozilla-thunderbird.xpm /usr/share/pixmaps/mozilla-thunderbird-menu.xpm
    sudo cp /tmp/mozilla-thunderbird.xpm /usr/share/pixmaps/mozilla-thunderbird-pm-menu.xpm
    sudo cp /tmp/mozilla-thunderbird.xpm /usr/lib/mozilla-thunderbird/chrome/icons/default/mozilla-thunderbird.xpm
    sudo cp /tmp/mozilla-thunderbird.xpm /usr/lib/mozilla-thunderbird/chrome/icons/default/messengerWindow16.xpm
    sudo cp /tmp/mozilla-thunderbird.xpm /usr/lib/mozilla-thunderbird/chrome/icons/default/messengerWindow.xpm
    sudo cp /tmp/mozilla-thunderbird.xpm /usr/lib/mozilla-thunderbird/chrome/icons/default/default.xpm
     
    

Send host-name to DHCP server

If you have trouble accessing your Ubuntu machine remotely, it might be because the DHCP server needs to be informed of the machine's name.

  1. sudo cp /etc/dhcp3/dhclient.conf /etc/dhcp3/dhclient.conf.backup
    sudo gedit /etc/dhcp3/dhclient.conf
    
    Add the following line to the file:
    send "hostname.domain";
    
    where hostname is your computer name and domain is the your computer's network domain (e.g., u.cs.cornell.edu).
  2. Reboot the computer.

Recursively remove files by name

  1. To remove files with names matching regular expression regexp from directory dir recursively:
    find dir -name "regexp" -ok rm '{}' \;
    

Rename multiple files

  1. The following script will change all occurences of regexp1 in file names to regexp2 (see Wikipedia's regular expression syntax guide):
    #!/bin/bash
    find directory -mindepth 1 -maxdepth 1 -name "*regexp1*" | while read file
    do
        target=$(echo $file | sed -e "s@regexp1@regexp2@g")
        mv "$file" "$target"
    done 
    
  2. The following script will change all upper-case letters in file names to lower-case:
    #!/bin/bash
    find directory -mindepth 1 -maxdepth 1 -name "*[A-Z]*" | while read file
    do
        target=$(echo $file | tr '[A-Z]' '[a-z]')
        mv "$file" "$target"
    done 
    
  3. Remember to make your script file executable:
    chmod +x script_file
    

Add or change a default application

Quick explanation: In order to associate an application (e.g., gThumb Image Viewer) with a file-type (e.g., PNG image files), the application needs to have a "desktop entry" (e.g., gthumb.desktop) located in the /usr/share/applications/ directory. Furthermore, the file-type needs to have a mime-type located in the /usr/share/mime/ directory (e.g., /usr/share/mime/images/png.xml). Finally, there should be a line in the /usr/share/applications/defaults.list file that associates the desktop entry with the mime-type (e.g., images/png=gthumb.desktop).

  1. sudo cp /usr/share/applications/defaults.list /usr/share/applications/defaults.list.backup
    
  2. sudo gedit /usr/share/applications/defaults.list
    
    Add/change appropriate line to:
    mimeType=newApp.desktop
    
    To figure out what newApp should be (if necessary):
    ls /usr/share/applications/*.desktop | sed -e "s@/usr/share/applications/@@g" | less
    
    To figure out what mimeType should be (if necessary):
    find /usr/share/mime/ -mindepth 2 -maxdepth 2 -name "*" | sed -e "s@/usr/share/mime/@@g" -e "s@[.]xml@@g" | less
    
  3. Restart Nautilus and the Gnome Panel:
    killall gnome-panel
    killall nautilus
    

Reinstall GRUB

  1. Boot from the Live CD if you can't boot from the hard disk into Ubuntu.
  2. In the terminal, run:
    sudo grub
    
    At the grub command prompt, run the following commands:
    1. find /boot/grub/stage1
      
      You should see something like (hdX,Y) where X and Y will be numbers, e.g., (hd0, 1).
    2. root (hdX,Y)
      
      where X and Y above should be replaced by the appropriate numbers returned in step 1.
    3. setup (hdX)
      
      where X above should be replaced by the appropriate number returned in step 1.
    4. quit
      
  3. GRUB should now be installed on the Master Boot Record (MBR). Reboot.

Customize Firefox

  1. user.js
    userChrome.css
    userContent.css
  2. Extensions:
    Adblock Plus
    Greasemonkey
    Stylish
    Dictionary Search
    Forecastfox Enhanced
    Searchbar Autosizer
    Context Search
    DownThemAll
    Download Statusbar
    Tiny Menu
    Classic Compact
    FireFTP
    Slashdotter
    Firebug
    Nuke Anything Enhanced
    Better Gmail
    Save Session
    Linkification
    CustomizeGoogle
    Image Zoom
    Bug Me Not
    Web Developer
    Platypus
    Aardvark
  3. Greasemonkey & Stylish Scripts:
    Wikipedia links in Google
    Google Image Face Search
    Amazon Permalink
    Tard's KoL scripts - Framework, Recipes, Adventure Advisor, Familiar Trainer, Adventure Choices, Naughty Sorceress helper, Compact Mode Flat Navigation, Strange Leaflet helper, Item management tools
    Other KoL scripts
    KoL mall price highlighter
    KoL wiki links
    W3schools cleaner
    Slashdot Ad Remover
    Digg Washer
    Super Digg
    Digg Comments Cleanup 1
    Digg Comments Cleanup 2
    Multi-column news articles (Windows only)
    Gmail Nested Labels
  4. Adblock filters:
  5. MMS & RTSP protocols about:config
    Create a new string:
    network.protocol-handler.app.mms
    value = /usr/bin/X11/vlc
    Create a new boolean:
    network.protocol-handler.external.mms
    value = true
    Create a new string:
    network.protocol-handler.app.rtsp
    value = /usr/bin/X11/realplay
    Create a new boolean:
    network.protocol-handler.external.rtsp
    value = true
  6. Dictionary Search setup:
    Search Dictionary for "$"
    http://dictionary.reference.com/search?q=$
    
    Search Wikipedia for "$"
    http://en.wikipedia.org/wiki/Special:Search?search=$&sourceid=mozilla-search
    
    Search Google for "$"
    http://www.google.com/search?q=$&ie=utf-8&oe=utf-8&rls=org.mozilla:en-US:official&client=firefox-a
     
  7. (optional) Enter about:config in the URL bar and then make the following changes:
    general.autoScroll=true
    network.http.pipelining=true
    network.prefetch-next=false
    browser.backspace_action=0
    browser.link.open_newwindow=3 (3: new tab; 2: new window; 1: current tab)
    browser.link.open_newwindow.restriction=2 (0: use open_newwindow setting; 1: new window; 2: use open_newwindow setting unless javascript specifies window size)
    browser.search.openintab=true
    browser.tabs.autoHide=false
    browser.tabs.closeButtons=2
    browser.tabs.loadFolderAndReplace=false
    browser.tabs.loadGroup=0
    browser.tabs.warnOnClose=false
    font.size.fixed.x-western=16
    font.size.variable.x-western=16
    font.default.x-western=sans-serif
    font.name.monospace.x-western=DejaVu Sans Mono
    font.name.sans-serif.x-western=DejaVu Sans
    font.name.serif.x-western=Nimbus Roman No9 L
    linkification.settings.Linkify_OpenInTab=true
    linkification.settings.Linkify_OpenTabinBG=true
    linkification.settings.Linkify_Toggle=false
    extensions.customizegoogle.web.suggest=false
    

Customize Thunderbird

  1. Extensions: Addressbooks Synchronizer, New Mail Icon.
  2. Fonts: Variable=Sans Serif 18px, Serif=Nimbus Roman No9 L, Sans-serif=DejaVu Sans, Monospace=DejaVu Sans Mono 16px.

Remove occurences of ^M in Vim

  1. In vim, replace all extraneous ^M by:
    :%s/^M$//g
    
    IMPORTANT: Make the ^M by typing CTRL+V CTRL+M, not ^ M! This expression will replace all the ^M's that have carriage returns after them with nothing. (The dollar ties the search to the end of a line.)
  2. In vim, replace all ^M's that need to have carriage returns:
    :%s/^M/ /g
    
    IMPORTANT: Make the ^M by typing CTRL+V CTRL+M, not ^ M! This expression will replace all the ^M's that didn't have carriage returns after them with a carriage return.

Compress and extract a file/directory

  1. Compress:
    tar -cvzf archiveName.tar.gz fileOrFolder
    
  2. Extract:
    tar -xvzf archiveName.tar.gz
    

Encrypt and decrypt a file

  1. Encrypt:
    gpg -c file
    
    You will be asked to enter (and re-enter) a password which will used to create the encrypted file called file.gpg
  2. Decrypt:
    gpg file.gpg