Ubuntu 7.04 (Feisty Fawn) How-To

Ubuntu

This page is not maintained anymore; the links may be broken, and the information may be out of date.

The information presented here is for you to use freely but at your own risk.

Installing Ubuntu

See here for some other good installation guides: APC's Linux/Vista/XP dual-booting guide and Psychocats' installation guide.

  1. Download the Ubuntu 7.04 installation CD/DVD image, and then burn the image to CD/DVD.
  2. Boot off the CD/DVD. This usually involves simply rebooting the computer with the CD/DVD in the appropriate drive. For some computers you may need to hit F12 (or F2, or DEL, or something like that) at the appropriate time during boot and select from a menu to boot off the CD.
  3. Choose the "Start Ubuntu in safe graphics mode" option.
  4. After the computer boots into the Live CD version of Ubuntu, double-click the Install icon on the Desktop.
  5. At this point, your screen resolution might be too low to be able see or click the "Forward" button at the bottom of the Install window. If this is the case, you can fix the problem as follows:
    1. Close the over-sized Install window.
    2. Open a terminal by clicking on the Applications menu and then on the Accessories submenu and then on the Terminal menu item.
    3. In the terminal, type:
      sudo dpkg-reconfigure xserver-xorg
      
      and then press ENTER on your keyboard.
    4. You will be presented with a series of questions. Choose the default answers to all questions, except for the following:
      1. Choose "Medium" for the method for selecting monitor characteristics.
      2. Choose "1028x768 @ 60Hz" for the monitor's best video mode.
    5. After you answer all the questions and are back in the regular terminal, restart the Gnome Desktop Manager by pressing CTRL+ALT+BACKSPACE on your keyboard.
    6. Wait for a few seconds without pressing any keys until Ubuntu automatically logs back in and you can see the desktop again.
    7. You should now have a better resolution.
    8. Double-click the Install icon on the Desktop and you should be able to see the full install window.
  6. Select your language, location and time-zone, and keyboard layout.
  7. When you reach the "Prepare disk space" section, choose to "Manually edit partition table". Note that you can decide to keep any existing Windows partition(s) (in which case Ubuntu will install itself with dual boot options). However, if the Windows partitions take up the whole hard drive, then you must first shrink these partition(s) in order to free up space for your Ubuntu partitions. I recommend setting up three new partitions (in addition to the shrunk Windows partition) for Ubuntu as follows:
    Purpose Size Filesystem
    swap space 1 - 2GB linux-swap
    root directory (/) 6 - 10GB ReiserFS (or ext3)
    home directory (/home) remaining free space ReiserFS (or ext3)
    The /home directory will hold your documents, music, pictures, etc., so you should plan to invest adequate space for that. Putting /home on a separate partition allows you to upgrade/reinstall the OS without touching your documents.
  8. Migrate Documents and Settings if applicable and/or desired.
  9. Select your user name, password and computer name.
  10. Review your choices, and then click "Install".
  11. Browse the web or read a magazine while Ubuntu installs.
  12. Eventually, you will be informed that the installation is complete, at which point click the "Restart now" button.
  13. Just before Ubuntu finishes restarting, you will be prompted to remove the install CD/DVD. Make sure to do so in order to avoid booting back into the install CD.
  14. If Ubuntu detected Windows on another partition, it will present you with dual boot options using GRUB. The top option is Ubuntu. Choose it, or else just let the timer count down to zero.
  15. After the computer boots into the newly installed Ubuntu, log in using the user name and password that you selected earlier during installation.
  16. Congratulations! You are now running Ubuntu! Wasn't that easy? :)

Initial setup

  1. Update and upgrade package sources
  2. Install nVidia graphics driver
  3. Enable 5-button mouse
  4. Enable CD/DVD eject
  5. Add extra repositories

Useful packages

Troubleshooting

Customization

Hardware

Remote access

Most of the information on this page comes from the following sources:

You can visit my home page to find out how to contact me with feedback and suggestions for this site.

Update and upgrade packages

  1. sudo apt-get update
    sudo apt-get upgrade
    

Install nVidia graphics driver

Note that installing the nVidia driver will automatically fix some screen resolution problems.

  1. First, reset the X server configuration to very basic settings:
    sudo dpkg-reconfigure xserver-xorg
    
    You will be presented with a series of questions. Choose the default answers for all the questions except for the following:
    1. Choose "vesa" for the X server driver.
    2. Choose "No" for monitor autodection.
    3. Choose "medium" for the method for selecting the monitor characteristics.
    4. Choose "1024x768 @ 60Hz" for the monitor's best video mode. (Don't worry, we'll get better screen resolutions once we install and enable the nVidia driver.)
    5. Choose "Yes" for writing the monitor sync ranges to the config file.
    You can now optionally restart the Gnome Desktop Manager (GDM) for these settings to take effect before continuing. Alternatively, you can just continue the driver installation without restarting the GDM.
  2. Install and enable the nVidia driver:
    sudo apt-get install nvidia-glx-new
    sudo nvidia-glx-config enable
    
    Note: If you have a GeForce4 video card, you may need to use nvidia-glx instead of nvidia-glx-new. And if you have a very old card, like a TNT, you may need to use nvidia-glx-legacy instead.
  3. Restart the Gnome Desktop Manager for these settings to take effect.
  4. Set up screen resolution, dual monitors, Xinerama, etc.:
    sudo nvidia-settings
    
    You can change the settings in the "X Server Display Configuration" section and then click the "Save to X Configuration" button and save the file as /etc/X11/xorg.conf.
    Note: If you decide to enable dual monitors with Xinerama, you will need to disable compositing due to this nVidia bug. You can do this by editing your /etc/X11/xorg.conf file:
    sudo gedit /etc/X11/xorg.conf
    
    and then appending the following lines to the file:
    Section "Extensions"
        Option "Composite" "false"
    EndSection
    
  5. (optional) 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
    
  6. (optional) Restart Gnome Desktop Manager for these settings to take effect.

Enable 5-button mouse

  1. If you have a 5-button mouse, you can enable the forward and back buttons as follows:
    sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.backup.mouse
    sudo gedit /etc/X11/xorg.conf
    
    Change:
    Section "InputDevice"
        ...
        Driver "mouse"
        ...
        Option "Emulate3Buttons" ...
        Option "ZAxisMapping"    ...
        ...
    EndSection
    
    to:
    Section "InputDevice"
        ...
        Driver "mouse"
        ...
        Option "Emulate3Buttons" "false"
        Option "Buttons"         "7"
        Option "ButtonMapping"   "1 2 3 6 7"
        Option "ZAxisMapping"    "4 5"
        ...
    EndSection
    
  2. (optional) Restart Gnome Desktop Manager for these settings to take effect.

Enable CD/DVD eject

NOTE: CD/DVD eject seems to work fine for me in Feisty, so only follow these steps if you are having problems ejecting.

  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
    

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
    
  2. sudo apt-get update
    

Install Microsoft fonts

  1. sudo apt-get install msttcorefonts
    

Install multimedia codecs and players

  1. Add the extra repositories. (In particular, make sure that feisty/universe and feisty/multiverse are enabled.)
  2. (optional) Install 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
    
  3. (recommended) Install totem-xine (this is my favorite media player - it plays most media files and has a very clean interface):
    sudo apt-get install totem-xine libxine-extracodecs
    
  4. (recommended) Add right-click options in Nautilus for enqueuing and replacing multiple files in Totem.
  5. (optional) Install MPlayer (a media player that plays pretty much everything but has a lousy interface; it's good to have it around for the rare cases when totem-xine can't play something):
    sudo apt-get install mplayer
    sudo sed -i.backup -e's@gmplayer@mplayer@g' /usr/share/applications/mplayer.desktop
    sudo sed -i.backup -e's@vo=x11,@vo=xv,@g' /etc/mplayer/mplayer.conf 
    
  6. (optional; recommended) Install the MPlayer plugin for Firefox:
    sudo apt-get install mozilla-mplayer
    

Install TiMidity (MIDI player/software synthesizer)

See also the Midi Software Synthesis How-To.

  1. Install Timidity:
    sudo apt-get install timidity timidity-interfaces-extra
    
  2. (optional) Start software synthesis by loading the appropriate modules and starting Timidity as the MIDI server:
    sudo modprobe snd-seq-device
    sudo modprobe snd-seq-midi
    sudo modprobe snd-seq-oss
    sudo modprobe snd-seq-midi-event
    sudo modprobe snd-seq
    timidity -iA -B2,8 -Os1l -s 44100
    
    To make software synthesis start automatically in future, first make the appropriate modules load automatically:
    sudo gedit /etc/modules
    
    Append the following:
    snd-seq-device
    snd-seq-midi
    snd-seq-oss
    snd-seq-midi-event
    snd-seq
    
    Then inform Timidity to start automatically:
    sudo gedit /etc/default/timidity
    
    Uncomment the line to enable the sequencer. That is, change:
    #TIM_ALSASEQ=true
    
    to:
    TIM_ALSASEQ=true
    
  3. Add a desktop entry for Timidity:
    sudo gedit /usr/share/applications/timidity.desktop
    
    Add:
    [Desktop Entry]
    Encoding=UTF-8
    Name=Timidity MIDI Player
    Comment=Play MIDI audio files
    Exec=timidity -ig
    Terminal=false
    Type=Application
    StartupNotify=false
    MimeType=audio/midi;
    Categories=Application;AudioVideo;
    Icon=
    #NoDisplay=true
    
  4. (optional) Make Timidity the default MIDI player (after first having added a desktop entry as in the previous step):
    sudo cp /usr/share/applications/defaults.list /usr/share/applications/defaults.list.backup.midi
    sudo gedit /usr/share/applications/defaults.list
    
    Insert/replace the audio/midi entry as follows:
    audio/midi=timidity.desktop
    
  5. (optional; recommended) Install high quality sound fonts:
    wget -c -P /tmp/ http://www.fbriere.net/debian/dists/stable/misc/deb/eawpatches_12-1~fbriere.4_all.deb
    sudo dpkg -i /tmp/eawpatches_12-1~fbriere.4_all.deb
    sudo gedit /etc/timidity/timidity.cfg
    
    Change:
    source /etc/timidity/freepats.cfg
    
    to:
    source /etc/timidity/eawpatches.cfg
    
  6. (optional) Reduce Timidity's CPU usage:
    sudo gedit /etc/timidity/timidity.cfg
    
    Add:
    opt EFresamp=d          #disable resampling (or "opt EFresamp=l" for linear resampling)
    opt EFvlpf=d            #disable VLPF
    opt EFreverb=d          #disable reverb
    opt EFchorus=d          #disable chorus
    opt EFdelay=d           #disable delay
    
    Save and close the file.

Install GParted (disk partition utility)

  1. sudo apt-get install gparted
    

Install Mozilla Thunderbird (email client)

  1. sudo apt-get install mozilla-thunderbird
    

Install Brasero (CD/DVD burner)

  1. sudo apt-get install brasero
    

Install GnomeBaker (CD/DVD burner)

  1. sudo apt-get install gnomebaker
    

Install Sound Juicer (audio CD ripper)

  1. sudo apt-get install sound-juicer
    

Install Acroread (PDF viewer)

I prefer the default Evince viewer to Acroread (even though Evince can't do forms yet) because it is faster and cleaner.

  1. sudo apt-get install acroread
    
  2. (optional) 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
    
  3. (optional) Install Acroread plugin for Firefox:
    sudo apt-get install mozilla-acroread
    

Install Skype

  1. Download and install Skype:
    sudo apt-get install libqt4-gui
    wget -c -O /tmp/skype.deb http://www.skype.com/go/getskype-linux-ubuntu
    sudo dpkg -i /tmp/skype.deb
    

Install Adobe Flash Player 9 plugin for Firefox

  1. Add the extra repositories. (In particular, make sure that feisty/multiverse is enabled.)
  2. Install Flash Player:
    sudo apt-get install flashplugin-nonfree
    

Install Sun Java

See the Restricted Formats page.

  1. Add the extra repositories. (In particular, make sure that feisty/multiverse is enabled.)
  2. sudo apt-get install sun-java6-jre sun-java6-plugin
    sudo update-alternatives --config java
    
    Select the appropriate Sun Java option.

Install TeX Live (LaTeX)

  1. Install TeX Live along with some useful packages:
    sudo apt-get install texlive texlive-generic-extra texlive-latex-extra texlive-math-extra texlive-pstricks latex-beamer texpower psutils
    
  2. Here is a sample LaTeX file and the makefile to compile it with.

Install teTeX (LaTeX)

Note: teTeX is not being developed anymore, so I recommend TeX Live instead.

  1. Install teTeX:
    sudo apt-get install tetex-base tetex-bin tetex-extra
    

Install Octave (Matlab replacement)

  1. Install Octave:
    sudo apt-get install octave
    

Install Gnuplot (plotting/graphing utility)

  1. sudo apt-get install gnuplot
    

Install Development Tools

  1. Basic compilers and tools:
    sudo apt-get install build-essential
    
  2. (optional) OpenGL and SDL development:
    sudo apt-get install nvidia-glx-dev libglew-dev libsdl1.2-dev libsdl-ttf2.0-dev libsdl-image1.2-dev libsdl-mixer1.2-dev
    
  3. (optional) GNU multi-precision arithmetic library:
    sudo apt-get install libgmp3-dev libgmp3-doc
    

Install CVS (version control system)

  1. sudo apt-get install cvs
    
  2. (optional) Install Meld, a visual diff and merge tool for file comparisons:
    sudo apt-get install meld
    
  3. (optional) Install TkCVS, a GUI front-end for CVS:
    sudo apt-get install tkcvs
    

Install Subversion (version control system)

  1. On both server and client:
    sudo apt-get install subversion
    
  2. On the server (setting up SVN tunneled through SSH):
    1. Make a directory for the repositories to sit:
      mkdir $SVN_DIR
      
      Typically, use /home/$USER/svn as $SVN_DIR.
    2. Create a repository:
      svnadmin create $SVN_DIR/$PROJECT
      
      where $PROJECT is your project name
    3. Turn off anonymous access:
      nano $SVN_DIR/$PROJECT/conf/svnserve.conf
      
      Add the following lines:
      [general]  #section heading
      anon-access = none # turn off anonymous access
      
    4. (optional) Import existing content to the repository:
      svn import /path/to/original/content/ file://$SVN_DIR/$PROJECT[/deeper]
      
  3. On the client:
    1. Initial checkout:
      svn checkout svn+ssh://$SVN_SERVER/$SVN_DIR/$PROJECT[/deeper/]
      
    2. Subsequent updates, commits, etc.:
      svn update/commit/add/remove/rename/revert [filenames]
      
    3. (optional) Install Meld, a visual diff and merge tool for file comparisons:
      sudo apt-get install meld
      

Install GVim (editor)

  1. sudo apt-get install vim-gnome
    
  2. (optional) Tinker with your ~/.vimrc file to your heart's content. (See my ~/.vimrc for an example. It contains several key mappings to make controls more standard and sane.)
  3. (optional) Make gvim the default text editor:
    sudo sed -i.backup.gvim -e's@gedit.desktop@gvim.desktop@g' -e's@text/x-csrc=gvim.desktop@text/x-csrc=gvim.desktop\ntext/x-c++hdr=gvim.desktop\ntext/x-c++src=gvim.desktop\ntext/x-csharp=gvim.desktop\ntext/x-tex=gvim.desktop@g' /usr/share/applications/defaults.list
    sudo sed -i.backup -e's@MimeType=text/plain;@MimeType=text/plain;text/html;text/css;text/xml;text/x-dtd;text/x-chdr;text/x-csrc;text/x-c++hdr;text/x-c++src;text/x-java;text/x-csharp;text/x-tex;text/x-bibtex;text/x-readme;@g' -e's@NoDisplay=true@NoDisplay=false@g' /usr/share/applications/gvim.desktop 
    

Install jEdit (editor)

  1. Install Java.
  2. Add the jEdit repository to your etc/apt/sources.list file:
    sudo gedit /etc/apt/sources.list
    
    Add the following lines:
    deb http://switch.dl.sourceforge.net/sourceforge/jedit ./
    deb-src http://switch.dl.sourceforge.net/sourceforge/jedit ./
    
    Save and close the file.
  3. Install jEdit:
    sudo apt-get update
    sudo apt-get install jedit
    
  4. (optional) Make jEdit reuse windows when opening files to edit.
    sudo gedit /usr/bin/jedit
    
    Change:
    ... ${JEDIT} -jar "/usr/share/jedit/jedit.jar" $@
    
    to:
    ... ${JEDIT} -jar "/usr/share/jedit/jedit.jar" -reuseview $@
    

Install Firestarter (firewall front-end)

A few words of explanation to dispell some of the misconceptions about Firestarter. Ubuntu Linux has a built-in firewall called iptables. However, it is somewhat complicated to configure and maintain since it is command-line only. Firestarter is a tool that acts as a nice GUI front-end to iptables. As such, you can use Firestarter to configure the iptables firewall to your liking. After that you don't need to keep Firestarter running anymore. Thus, even if you close Firestarter, the iptables firewall (which is built into the Linux kernel and loads automatically on boot) will still be running.

Ubuntu, as installed, leaves all its ports open. So, if you want to install a server (e.g., SSH, Samba, etc.), you should first install Firestarter and then use Firestarter to close all ports except for those that your servers needs to listen to.

  1. Install Firestarter:
    sudo apt-get install firestarter
    
  2. Run Firestarter:
    sudo firestarter
    
    and then complete the setup wizard.

Install OpenSSH (SSH server)

  1. Install the Firestarter firewall front-end and make sure that all unnecessary ports are closed.
  2. sudo apt-get install openssh-server
    
  3. (optional) Change the SSH port from 22 to something else:
    sudo nano /etc/ssh/sshd_config
    
    Change
    Port 22
    
    to
    Port xxxx
    
    where xxxx is the alternative port number you want to use.
  4. (optional) Restrict access to a particular set of users:
    sudo nano /etc/ssh/sshd_config
    
    Add the following line:
    AllowUsers user1 user2 ... userN
    
    where user1, user2, ..., userN are the users you want to allow (all other users will be disallowed SSH access).
  5. (optional) Restart the SSH server if you made any of the optional configuration changes above:
    sudo /etc/init.d/ssh restart
    
  6. Use Firestarter to open the SSH port to those IP addresses to which you want to give SSH access.
  7. If you are behind a router on a home network, give your server a static local IP (e.g., 192.168.1.30) by clicking on the System / Administration / Network menu item and setting up a static IP. Note that the "gateway address" should be the router's address (e.g., 192.168.0.1, 192.168.1.0, or whatever).
  8. If you want to access your server over the Internet and are behind a router, configure the router to allow access to your server's SSH port.
  9. If you want to access your server over the Internet and your Internet Service Provider doesn't give you a static IP address, you need to set up a publicly accessible hostname.
  10. You might also need to send your hostname to your DHCP server.

Set up a static hostname

If you have a dynamic IP address, it can be difficult to access your computer over the Internet (e.g., via an SSH) because the IP address keeps changing. An elegant solution is to use a free service, called DynDNS, to create a name (e.g., yourname.dyndns.org) with which you can access your computer over the Internet so long as you keep DynDNS updated your latest IP address. We will use a script called ipcheck to automatically update DynDNS with your IP address.

  1. Sign up for a free dynamic DNS account with DynDNS and create a hostname and select a domain name (e.g., dyndns.org, podzone.org, etc.) for your computer.
  2. Install ipcheck:
    sudo apt-get install ipcheck
    
  3. Create a directory to store relevant scripts and data in the root user's home directory (i.e., /root):
    sudo mkdir /root/ipcheck
    
  4. Create a file that stores your DynDNS account username and password (for security, we will later make it so that only the root user can read this file):
    sudo nano /root/ipcheck/dyndns_account
    
    Enter your DynDNS account information into the file as below:
    username password hostname.domainname
    
    Save and close the file. Here, username and password are your DynDNS account username and password. hostname is the hostname you chose, and domain is the domain you selected (e.g., dyndns.org, podzone.org, etc.).
    Restrict the permissions for the file so that only the root user can read it.
    sudo chmod o-r /root/ipcheck/dyndns_account
    
  5. Create a script to inform DynDNS of the current IP address:
    sudo nano /root/ipcheck/dyndns_update.sh
    
    Enter the following code into the script file:
    #!/bin/sh
    cd /root/ipcheck/
    if [ -f ipcheck.dat ]; then
      /usr/sbin/ipcheck -l -r checkip.dyndns.org:8245 --acctfile dyndns_account
    else
      /usr/sbin/ipcheck --makedat -l -r checkip.dyndns.org:8245 --acctfile dyndns_account
    fi 
    
    Save and close the file. When called, this script will get the current IP address (using a free service provided by DynDNS). Then, if the IP address changed, the script will update DynDNS with the new address.
    Make the script file executable:
    sudo chmod +x /root/ipcheck/dyndns_update.sh
    
  6. Finally, schedule the script to be run periodically:
    sudo crontab -e
    
    Append the following line to the list of crontab tasks in order to schedule our script to run every 10 minutes:
    */10 * * * * test -x /root/ipcheck/dyndns_update.sh && /root/ipcheck/dyndns_update.sh > /dev/null
    
    Save and close the file.

Windows compatibility layer (Wine)

Wine is an implementation of the Windows API that allows you to run Windows applications directly in Linux.

  1. Add the Wine repository to your sources list:
    wget -q http://wine.budgetdedicated.com/apt/387EE263.gpg -O- | sudo apt-key add -
    sudo wget http://wine.budgetdedicated.com/apt/sources.list.d/feisty.list -O /etc/apt/sources.list.d/winehq.list
    sudo apt-get update
    
  2. Install Wine:
    sudo apt-get install wine
    
  3. To run a Windows program from the terminal:
    wine program.exe
    

Install Nautilus Actions (Nautilus context-menu customizer)

  1. Add the extra repositories. (In particular, make sure that feisty/universe is enabled.)
  2. Install Nautilus Actions:
    sudo apt-get install nautilus-actions
    
  3. To add customized entries to the Nautilus right-click context menu, run:
    nautilus-actions-config
    
    and twiddle away.
  4. Here are some useful schemas that you can import into Nautilus Actions:

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 disk image (ISO file)

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:

  1. Check that /etc/X11/xorg.conf contains the correct HorizSync and VertRefresh options in the "Monitor" section as follows.
    sudo ddcprobe | grep monitorrange
    
    The first two values returned are your HorizSync rates, the second pair is your VertRefresh values.
    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 make sure the HorizSync and VertRefresh lines exist and have the appropriate values (e.g., 30-96 and 50-160):
    Section "Monitor"
                ...
                HorizSync          30-96
                VertRefresh        50-160
    EndSection
    

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 /boot/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
    

Securely remote desktop into an Ubuntu machine

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 -fN herakles
    ssh -fN lion
    
  3. rdesktop -r disk:sync=/home/$USER/local_directory 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 SFTP is faster, more secure, 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 user_name -W CUCS -I localhost -p 2017
    
    Or smbmount to mount the share:
    smbmount //smb.cs.cornell.edu/win local_directory -o ip=localhost,port=2017,username=user_name,workgroup=CUCS
    
    And smbumount to unmount it:
    smbumount local_directory
    

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.

Customize theme and fonts

  1. gnome-theme-manager
    
    Click "Theme Details", and fiddle away. My preferred settings are: Controls="Clearlooks", Window Border="IndustrialTango", Icons="Tango".
  2. gnome-font-properties
    
    My preferences are "App=Sans 10, Desktop=Sans 10, Window title=Sans 10, Terminal=FreeMono Medium 12".

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 -p -R /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
    

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.

Restart the Gnome Desktop Manager (GDM)

  1. Close all open programs.
  2. Either press CTRL+ALT+BACKSPACE or run:
    sudo /etc/init.d/gdm restart
    

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
    

Restore 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. Extensions: Google Browser Sync, NoScript, Forecastfox l10n, SearchWP, SearchBox Sync, Searchbar Autosizer, Context Search, DownloadThemAll!, VideoDownloader, lget, Linkification, CustomizeGoogle, Image Zoom, Web Developer.
  2. (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 indow; 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.

Dual Monitors

I'm feeling too lazy to write a step-by-step guide for this one. Instead, I'll post my /etc/X11/xorg.conf file which contains the settings for my dual monitor setup (using a dual head GeForce 7300GS card with a Hanns-G flat panel and a Micron CRT monitor). The "Device", "Monitor", "Screen", "ServerFlags", "ServerLayout", and "Extensions" sections are all relevant.

With my /etc/X11/xorg.conf in mind, here's the short explanation. Basically there must be two "Device" sections, two "Monitor" sections, and two "Screen" sections (linking the appropriate Devices to the appropriate Monitors). The "ServerLayout" section specifies how the Screens are positioned relative to each other. The "ServerFlags" section turns Xinerama on or off. Xinerama allows the two monitors to share one big virtual screen (which I prefer). Turning Xinerama off makes the two monitors have separate and independent screens and so, for example, you can't drag windows between the screens, which is a drag (sorry!). I recommend initially turning off Xinerama while you set things up. Turn Xinerama on only after you've got your screen resolution, etc. set up nicely. This is because you can't access or change the screen resolution with the current implementation of Xinerama. Finally, the "Extensions" section is necessary if you use Xinerama with nVidia drivers to work around this nVidia bug.

Compress and extract a file or directory

  1. Compress:
    tar -cvzf archive_name.tar.gz fileOrFolder
    
  2. Extract:
    tar -xvzf archive_name.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