The Grub 2 Guide

The Grub 2 Guide
(formerly Grub 2 Basics)

According to the Release Notes, a Wubi upgrade to 10.10 from 10.04 fails and is still not recommended – “File not found”.
Bug # 613288
If you have upgraded to 10.10 and cannot boot normally:
Boot the LiveCD, make mount points and mount your Windows partition. Then mount your wubi installation. Note you must change sda1 to your Windows partition designation.

sudo mkdir /mnt/windows /mnt/wubi
sudo mount /dev/sda1 /mnt/windows
sudo mount -o loop /mnt/windows/ubuntu/disks/root.disk /mnt/wubi
gksu gedit +80 /mnt/wubi/boot/grub/grub.cfg

Remove all the lines above the first “menuentry” line (Approximately line 85). Save the file and then reboot. Do not run update-grub before rebooting.

Good News on Documentation
As of 2 July 2010 there is a new GNU Grub Manual. It is available on-line, as well as in HTML and PDF versions. It’s a step in making threads such as this unnecessary!

More Good News
As of late July 2010 grub-pc (1.98-1ubuntu7) will only display /, /boot, or /boot/grub partitions on which to install Grub 2. If running grub-install or dpkg-reconfigure grub-pc the user will no longer see every device and partition (including Windows). This should greatly reduce the chance of installing Grub 2 on a Windows system partition and making Windows unbootable. There will also be much less chance of installing Grub 2 to every existing partition.

Important Note to Wubi (Windows Ubuntu) Users: Grub Update results in “No Such Disk”:
A late July 2010 Grub 2 update is causing a “no such disk” error for some users of WUBI, resulting in an unbootable system. If the system doesn’t display the original Windows menu, the most likely cause of the failure is that Grub 2 was installed in the MBR and/or on the Windows partition. To correct this, restore the Windows bootloader using this link:
How to restore the Ubuntu/XP/Vista/7 bootloader

Whether the failure is due to improper user selections or Grub 2’s failure to recognize a Wubi install, it has been reported in the following bug and users can review it for status updates and recovery options when they become available:

“Fix Symbol ‘grub-puts’ Not Found” Error Message:…ound-when.html
If you can get to a normal installation, run the grub-install command or use the “dpkg-reconfigure grub-pc” command to put Grub onto your current partition. If you have to use the Live CD, use chroot to run these commands (see chroot link in my signature line.

Note: Most of this information has been incorporated, with a few graphics, into a page in the Ubuntu Help site. I will try to keep this post up-to-date and users are free to continue to post comments here. The help page is located here:

  1. Introduction
  2. First Look Differences
  3. Improvements
  4. Booting Grub
  5. Grub 2 Files & Options
  6. Adding Entries to Grub 2
  7. Removing Entries from Grub 2
  8. Grub 2 Splash Images & Theming
  9. Changing Menu Resolution
  10. Password Protection
  11. Booting to Recovery Mode w/o Menu Option
  12. Uninstalling GRUB 2 > GRUB
  13. Reinstalling GRUB 2 from the LiveCD
  14. Booting to LiveCD ISO
  15. Booting from the Rescue Mode
  16. Restoring GRUB2 / XP / Vista / Win 7 Bootloaders
  17. Grub Rescue Image
  18. Selected Problems & Bugs
  19. Links

  1. Introduction
    I’ve written this guide to present some basic information about Grub 2. It is meant for users who may be familiar with basic editing of the original Grub (Grub Legacy) menu.lst and wonder how it carries over to Grub 2. The actual version of Grub 2 used in Ubuntu 9.10, Karmic Koala is 1.97~beta4; 1.98 is the Ubuntu 10.04, Lucid Lynx version. In keeping with Ubuntu’s “stable release” philosophy, 1.97~beta4 will remain the official version in 9.10/Karmic and will not be updated to 1.98. In this guide, any reference to Grub 2 will refer to the 10.04 Lucid Lynx 1.98 version, with major differences noted.

    Grub 2 will be the default in Ubuntu 9.10, Karmic Koala but the plan is not to convert over previous Grub legacy installations to Grub 2.
    Official Announcement / Story

    StartUp-Manager supports Grub 2, but not all options are available. The two most-used items, however, are: setting the default kernel/OS and setting the menu timeout delay. There are plans for a StartUp-Manager 2 that works only for Grub 2 but it is still under development according to its creator. To view a guide on installing and running StartUpManager, view the StartUpManager community doc or the forum post on which it was based:

    Official documentation at this point is still being created, which is partly the reason for this post. More comprehensive and complete documentation will hopefully be forthcoming from the developers and volunteers. Of the existing documentation, I have have provided several links to the better sources at the end of this post.

    For troubleshooting and modifying the Grub menu, it is important to know which version you are using (Grub legacy, 0.97; Grub 2 in Karmic 1.97~beta4; Grub 2 in Lucid 1.9. To confirm the version of Grub used in your system, run this command:

    grub-install -v

    Which should produce something like this:

    drs305@mycomputer:~$ grub-install -v
    grub-install (GNU GRUB 1.97~beta4)
  2. First Look Differences: GRUB vs GRUB 2
    At first boot, there will not be much difference in what the user sees on the boot menu. The one exception is a clean install of Ubuntu 9.10 with no other installed operating system. In this case, GRUB 2 will boot directly to the login prompt or Desktop without displaying a menu. Other major differences:

    • No ”/boot/grub/menu.lst”. It has been replaced by ”/boot/grub/grub.cfg”.
    • Hold down SHIFT to display the hidden menu during boot (formerly ESC is GRUB legacy).
    • There is no “find /boot/grub/stage1” at the grub prompt. Stage 1.5 has also been eliminated.
    • The main menu file, ”/boot/grub/grub.cfg” is not meant to be edited, even by ‘root’.
    • ”grub.cfg” is overwritten anytime there is a update, a kernel is added/removed or the user runs `update-grub` *
    • The user can use a custom file, ”/etc/grub.d/40_custom”, in which the user can place his own entries. This file will not be overwritten.
    • The primary configuration file for changing menu display settings is ”/etc/default/grub”.
    • There are multiple files for configuring the the menu – ”/etc/default/grub” mentioned above, and all the scripts in /etc/grub.d/ folder.
    • Other operating systems, such as Windows, should automatically be recognized and added to the menu.
    • No changes made in the configuration files will take effect until the `update-grub` command is also run.

    * To update the GRUB 2 menu, the command sudo update-grub will be used throughout this guide. update-grub actually runs the command “grub-mkconfig -o /boot/grub/grub.cfg” This runs several scripts and incorporates the results into /boot/grub/grub.cfg which detemines what is seen on the screen during boot. Since the GRUB 2 developers do not intend to remove the update-grub ‘stub’, it will be used for simplicity and ease of use.

  3. Improvements
    GRUB 2’s major improvements over the original GRUB include:

    • New configuration file structure
    • Scripting support including conditional statements and functions
    • Dynamic module loading
    • Rescue mode
    • Themes – under development
    • Graphical boot menu support and improved splash capability
    • Boot Ubuntu LiveCD and some other ISO images directly from hard drive
    • Non-X86 platform support (such as PowerPC)
    • Universal support for UUIDs (not just Ubuntu)
    • Improved internationalization, including support for non-ASCII characters
  4. Booting Grub
    Grub 2 loads before the operating system. It’s modular components are loaded on an as-needed basis. Menu display behavior is generally determined by settings in /etc/default/grub. Review the “Grub 2 Files & Options” section for specific entry and formatting guidance.

    The main options for displaying the menu are:

    • Initial Default
      • Grub 2 will boot straight into the default operating system if no other operating system is detected. No menu will be displayed. If another operating system is detected, the Grub 2 menu will display.
    • Timed display.
      • The default delay is 10 seconds. If no user input is made Grub 2 boots to the default entry.
      • The countdown can be stopped by pressing any key. The user must then make a selection manually.
      • The booted entry is determined by the DEFAULT= setting in /etc/default/grub, The first “menuentry” is 0.
    • Hidden
      • The user can interrupt the boot process and display the menu by holding down the SHIFT key until the menu displays. Grub 2 searches for a depressed SHIFT key signal during boot. If the key is pressed or Grub 2 cannot determine the status of the key, the menu is displayed. Note: The “SHIFT” keystatus check is currently nested within in a conditional statement within /etc/grub.d/30_os-prober and may not work under certain circumstances.
      • The time the screen remains blank but available for display is determined by a setting in /etc/default/grub.
      • To provide visual feedback during while the countdown continues, a countdown display can be shown on the screen.
      • At the end of the timeout, the default entry determined in /etc/default/grub will be selected.
    • Saved
      • If the default option is set to “saved”, the last kernel/system successfully booted will be selected and run if no input is made.
      • Unlike GRUB, GRUB 2 stores the “saved” entry as a string, not as a menu position number. In GRUB 2, the result is applied more consistently. Example: If the first entry (kernel -15) becomes the second entry due to a kernel update, it will still be the “saved” entry even though it’s position on the menu has changed.
  5. Grub 2 Files & Options
    Many of the files in /boot/grub will not be recognizable by users of Grub Legacy. Especially noticeable are the multitude of *.mod files. Grub 2 is modular and these files are loaded as necessary by the grub bootloader.

    The Grub 2 user-configurable settings are contained mainly in /etc/default/grub and the files in /etc/grub.d. When update-grub is executed the results are input into the /boot/grub/grub.cfg file.

    • /boot/grub/grub.cfg
      • This is the main Grub 2 file. It “replaces” Grub Legacy’s /boot/grub/menu.lst This file contains the Grub menu information but unlike Grub Legacy’s menu.lst file, grub.cfg is not meant to be edited.
        • grub.cfg is automatcially generated when “update-grub” is executed:
        • Each section (### BEGIN) is clearly delineated and references the file in the /etc/grub.d folder from which the information was generated.
        • grub.cfg is updated by running the “update-grub” or “update-grub” command as root.
        • By default, and whenever the “update-grub” command is executed, this file is made “read-only”. This is in keeping with the intent that the file should not be edited manually. If you must edit this file, instructions are provided in Section 2.
      • Sample grub.cfg including Windows and one manual entry (41_srcd):
        # It is automatically generated by /usr/sbin/grub-mkconfig using templates
        # from /etc/grub.d and settings from /etc/default/grub
        ### BEGIN /etc/grub.d/00_header ###
        if [ -s $prefix/grubenv ]; then
        set default="0"
        if [ ${prev_saved_entry} ]; then
          set saved_entry=${prev_saved_entry}
          save_env saved_entry
          set prev_saved_entry=
          save_env prev_saved_entry
          set boot_once=true
        function savedefault {
          if [ -z ${boot_once} ]; then
            save_env saved_entry
        function recordfail {
          set recordfail=1
          if [ -n ${have_grubenv} ]; then if [ -z ${boot_once} ]; then save_env recordfail; fi; fi
        insmod ext2
        set root='(hd0,1)'
        search --no-floppy --fs-uuid --set 444539ba-ab9e-4028-94f5-c1a86b5ec7c1
        if loadfont /usr/share/grub/unicode.pf2 ; then
          set gfxmode=640x480
          insmod gfxterm
          insmod vbe
          if terminal_output gfxterm ; then true ; else
            # For backward compatibility with versions of terminal.mod that don't
            # understand terminal_output
            terminal gfxterm
        insmod ext2
        set root='(hd0,1)'
        search --no-floppy --fs-uuid --set 444539ba-ab9e-4028-94f5-c1a86b5ec7c1
        set locale_dir=($root)/boot/grub/locale
        set lang=en
        insmod gettext
        if [ ${recordfail} = 1 ]; then
          set timeout=-1
          set timeout=10
        ### END /etc/grub.d/00_header ###
        ### BEGIN /etc/grub.d/05_debian_theme ###
        set menu_color_normal=white/black
        set menu_color_highlight=black/light-gray
        ### END /etc/grub.d/05_debian_theme ###
        ### BEGIN /etc/grub.d/10_linux ###
        menuentry 'Ubuntu, with Linux 2.6.32-16-generic' --class ubuntu --class gnu-linux --class gnu --class os {
            insmod ext2
            set root='(hd0,1)'
            search --no-floppy --fs-uuid --set 444539ba-ab9e-4028-94f5-c1a86b5ec7c1
            linux    /boot/vmlinuz-2.6.32-16-generic root=UUID=444539ba-ab9e-4028-94f5-c1a86b5ec7c1 ro   quiet splash
            initrd    /boot/initrd.img-2.6.32-16-generic
        menuentry 'Ubuntu, with Linux 2.6.32-16-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
            insmod ext2
            set root='(hd0,1)'
            search --no-floppy --fs-uuid --set 444539ba-ab9e-4028-94f5-c1a86b5ec7c1
            echo    'Loading Linux 2.6.32-16-generic ...'
            linux    /boot/vmlinuz-2.6.32-16-generic root=UUID=444539ba-ab9e-4028-94f5-c1a86b5ec7c1 ro single 
            echo    'Loading initial ramdisk ...'
            initrd    /boot/initrd.img-2.6.32-16-generic
        menuentry 'Ubuntu, with Linux 2.6.32-14-generic' --class ubuntu --class gnu-linux --class gnu --class os {
            insmod ext2
            set root='(hd0,1)'
            search --no-floppy --fs-uuid --set 444539ba-ab9e-4028-94f5-c1a86b5ec7c1
            linux    /boot/vmlinuz-2.6.32-14-generic root=UUID=444539ba-ab9e-4028-94f5-c1a86b5ec7c1 ro   quiet splash
            initrd    /boot/initrd.img-2.6.32-14-generic
        menuentry 'Ubuntu, with Linux 2.6.32-14-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
            insmod ext2
            set root='(hd0,1)'
            search --no-floppy --fs-uuid --set 444539ba-ab9e-4028-94f5-c1a86b5ec7c1
            echo    'Loading Linux 2.6.32-14-generic ...'
            linux    /boot/vmlinuz-2.6.32-14-generic root=UUID=444539ba-ab9e-4028-94f5-c1a86b5ec7c1 ro single 
            echo    'Loading initial ramdisk ...'
            initrd    /boot/initrd.img-2.6.32-14-generic
        ### END /etc/grub.d/10_linux ###
        ### BEGIN /etc/grub.d/20_memtest86+ ###
        menuentry "Memory test (memtest86+)" {
            insmod ext2
            set root='(hd0,1)'
            search --no-floppy --fs-uuid --set 444539ba-ab9e-4028-94f5-c1a86b5ec7c1
            linux16    /boot/memtest86+.bin
        menuentry "Memory test (memtest86+, serial console 115200)" {
            insmod ext2
            set root='(hd0,1)'
            search --no-floppy --fs-uuid --set 444539ba-ab9e-4028-94f5-c1a86b5ec7c1
            linux16    /boot/memtest86+.bin console=ttyS0,115200n8
        ### END /etc/grub.d/20_memtest86+ ###
        ### BEGIN /etc/grub.d/30_os-prober ###
        menuentry "Microsoft Windows XP Home Edition (on /dev/sda1)" {
            set root=(hd0,1)
            chainloader +1
        ### END /etc/grub.d/30_os-prober ###
        ### BEGIN /etc/grub.d/40_custom ###
        menuentry "Jaunty 2.6.28-15-custom" {
            save_env saved_entry
            set root=(hd0,8)
            linux    /boot/vmlinuz-2.6.28-15-custom root=UUID=48e03255-22b3-488b-ae7e-9dbe4e2beac7 ro  quiet splash
            initrd    /boot/initrd.img-2.6.28-15-custom
        menuentry "SystemRescue" {
            save_env saved_entry
                set root=(hd0,6)
                linux   /sysrcd/rescuecd subdir=sysrcd setkmap=us
                initrd  /sysrcd/initram.igz
        ### END /etc/grub.d/40_custom ###
    • /etc/default/grub
      • This file contains information formerly contained in the upper section of Grub Legacy’s menu.lst and items contained on the end of the kernel line. The items in this file can be edited by a user with administrator (root) privileges.
        # If you change this file, run ‘update-grub’ afterwards to update
        # /boot/grub/grub.cfg.

        GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
        GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash”

        # Uncomment to disable graphical terminal (grub-pc only)

        # The resolution used on graphical terminal
        # note that you can use only modes which your graphic card supports via VBE
        # you can see them in real GRUB with the command `vbeinfo’

        # Uncomment if you don’t want GRUB to pass “root=UUID=xxx” parameter to Linux

        # Uncomment to disable generation of recovery mode menu entries

        # Uncomment to get a beep at grub start
        #GRUB_INIT_TUNE=”480 440 1″

    • GRUB_DEFAULT – Sets the default menu entry. Entries may be numeric or “saved”
      • GRUB_DEFAULT=0 – Sets the default menu entry by menu position. As Grub Legacy, the first “menuentry” in grub.cfg is 0, the second is 1, etc.
      • GRUB_DEFAULT=saved – (Grub 1.98) Enables the “grub-reboot” and “grub-set-default” commands.
        • This setting allows the use of the following commands to set a default OS. The default OS will not be set merely by an interactive selection of an OS from the menu.
        • grub-set-default. Sets the default boot entry until changed.
          • The format is “sudo grub-set-default X, with X being the menuentry position (starting with 0 as the first entry) or the exact menu string. Examples: sudo grub-set-default 3 or sudo grub-set-default “Ubuntu, Linux 2.6.32-15-generic”
          • To obtain the existing menuentry choice number (starting from 0) or the menuentry “string”, run “grep menuentry /boot/grub/grub.cfg”
        • grub-reboot. This command sets the default boot entry for the next boot only. The format of the command is the same as for “grub-set-default” (see above).
        • For an example of how to enable the “saved” option with a custom menu, see the “Custom User Entries” section.
      • GRUB_DEFAULT=”xxxx” – An exact menu entry, including the quotation symbols, may also be used. In this case, location in the menu will not matter. Example: GRUB_DEFAULT=”Ubuntu, Linux 2.6.31-9-generic”
    • GRUB_SAVEDEFAULT=true * If set to true this setting will automatically set the last selected OS from the menu as the default OS on the next boot. No commands need be run to set the default OS. For this entry to work, the GRUB_DEFAULT entry should be set to saved.
    • GRUB_TIMEOUT=5 – No change from Grub Legacy. This is the number of seconds before the default entry is automatically booted.
      • Setting this value to -1 will cause the menu to display until the user makes a selection.
      • To display the menu on each boot use a value of 1 or higher.
      • This command defers to the GRUB_HIDDEN_TIMEOUT command. If the GRUB_HIDDEN_TIMEOUT option is interrupted by pressing the SHIFT key, the GRUB_TIMEOUT counter begins its countdown.
      • Caution: Holding down the “SHIFT” key will not display the menu if “GRUB_TIMEOUT=” is set to “0” .
      • In addition to editing the file as root, you can also run the following commands the check and change the default timeout value. The first checks the existing timeout, the second replaces the value. Replace T with the new value.
        cat /etc/default/grub | grep 'GRUB_TIMEOUT='   # Checks current TIMEOUT value.
        sudo sed 's/GRUB_TIMEOUT=5/GRUB_TIMEOUT=T/g' -i /etc/default/grub  # Change TIMEOUT value. Replace T with new value.
    • GRUB_HIDDEN_TIMEOUT=0 [ Note: This setting only applies to computers with only a single operating system. ]
      • The hidden timeout option allows a screen to be displayed without the Grub 2 menu, awaiting input from the user for a given number of seconds. It is available to single-OS computers – if multiple OS’s are known to Grub 2, this option is bypassed.
        On single-OS computers:

        • The menu will be hidden unless the user adds a # symbol to the beginning of this line ( # GRUB_HIDDEN_TIMEOUT=0 ) and the GRUB_TIMEOUT value is greater than 0.
        • If a background image is designated in 05_debian_theme it will be displayed rather than a blank screen during a hidden menu timeout.
        • For integers greater than 0:
          • The system will pause without displaying a menu for the designated number of seconds. If the user does not press the SHIFT key during the timeout the system will then boot the default OS/kernel.
          • If the user presses the SHIFT key to display the menu, the menu will be displayed for the number of seconds designated by the GRUB_TIMEOUT value unless the user again intervenes.
        • With a value of 0:
          • Unless the user intervenes, the system will boot the default OS/kernel with only a slight delay. No menu will be displayed.
          • The user may force displaying the menu as the computer boots by holding down the SHIFT key.

        On computers on which Grub 2 recognizes multiple OS’s:

        • This entry is ignored.
        • The menu will be displayed for the value designated in GRUB_TIMEOUT.
        • The hidden menu timeout option is not available, as it is bypassed by a conditional in /etc/grub.d/30_os-prober.
        • The system can still boot without displaying a menu by setting the GRUB_TIMEOUT value to 0, however a timeout delay with a blank screen is not available.
        • The keystatus check for SHIFT key usage is bypassed by the scripts. Holding down the SHIFT key during boot will not display the menu.
        • If the user of a multi-OS computer wishes to hide the menu while incorporating a blank screen timeout the scripts in /etc/grub.d/30_os-prober can be modified. Please refer to Grub 2 Title Tweaks.
      • true – No countdown is displayed. The screen will be blank.
      • false – A counter will display on a blank screen for the duration of the GRUB_HIDDEN_TIMEOUT value.
    • GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
      • Determines the descriptive name in the menu entry. (Ubuntu, Xubuntu, Debian, etc.)
      If it exists, this line imports any entries to the end of the ‘linux’ command line (Grub Legacy’s “kernel” line) for both normal and recovery modes. This is similar to the “altoptions” line in menu.lst
    • GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash”
      This line imports any entries to the end of the ‘linux’ line (Grub Legacy’s “kernel” line). The entries are appended to the end of the normal mode only. This is similar to the “defoptions” line in menu.lst. For a black screen with boot processes displayed in text, remove “quiet splash”. To see the grub splash image plus a condensed text output, use “splash”. This line is where other instructions, such as “acpi=off” are placed.

      For the GRUB_CMDLINE_LINUX_DEFAULT and GRUB_CMDLINE, quotation marks are required (single or double) if the entry is more than one alphanumeric entry. For example, quiet splash requires single or double quotes, while an entry such as quiet would not.

    • #GRUB_TERMINAL=console
      Uncomment to disable graphical terminal (grub-pc only). This can be useful if the user plans on spending a lot of time in the GRUB 2 command line mode. Scrolling and screen responsiveness will be greatly speeded up.
      Uncomment if you don’t want GRUB to pass “root=UUID=xxx” parameter to Linux
      Update: A bug requires quotation symbols be added for this option to be enabled. Change true to “true” and uncomment the line to eliminate UUIDs for linux entries.
    • #GRUB_GFXMODE=640×480
      You can add this line and remove the # symbol to make it active. This entry sets the resolution of the graphical menu (the menu text size). It provides resolutions supported by the user’s graphics card (e.g. 640×480, 800×600, 1280×1024, etc). The setting applies only to the boot menu text.
    • From the GRUB 2 menu you can display available resolutions by typing “c” and then at the “grub>” prompt type “vbeinfo”
      Add or uncomment this line to prevent “Recovery” mode kernel options from appearing in the menu. If you want a “Recovery” option for only one kernel, make a special entry in /etc/grub/40_custom.
    • GRUB_DISABLE_OS_PROBER=”true” * Enables/disables the os-prober check of other partitions for operating systems, including Windows, Linux, OSX and Hurd.
    • GRUB_INIT_TUNE=”480 440 1″
      • Introduced in Grub 1.98 (Lucid)
      • When uncommented, plays a single beep just prior to the Grub 2 menu display.
      • The format unless a file is named is: “tempo [pitch1 duration1] [pitch2 duration2] …”
      • The duration is based on the tempo. A tempo of 60 gives the duration a value of 1 second, 120 is .5, 240 is .25, 480 is .125, etc. The length of the tone can be changed by modifying either the tempo (all tones) or duration (individual tone).
        • Just a bit of fun:
          • Warning: The menu will not be displayed until the tone is finished
          • Close Encounters/5 Tone: GRUB_INIT_TUNE=”480 900 2 1000 2 800 2 400 2 600 3″
          • Fur Elise (note long): GRUB_INIT_TUNE=”480 420 1 400 1 420 1 400 1 420 1 315 1 370 1 335 1 282 3 180 1 215 1 282 1 315 3 213 1 262 1 315 1 335 3 213 1 420 1 400 1 420 1 400 1 420 1 315 1 370 1 335 1 282 3 180 1 215 1 282 1 315 3 213 1 330 1 315 1 282 3″
      • Online documentation is available by typing “info grub –index-search play” in a terminal.

      * Entries which are not found in the default file and must be added by the user.

    • /etc/grub.d/
      • The files in this folder are read during execution of “update-grub” or “update-grub” commands. The contents are imported into /boot/grub/grub.cfg

        The order of the entries in the grub menu is based on the order of the file names. File named with a starting numeral are run before those beginning with a letter. The order the files are run determines the menu order in grub.cfg.
        Custom entries can be added to the “40_custom” file or in a newly created file.

        Any file created must be executable in order to be included in the grub.cfg file during the “update-grub” command.

        • 00_header
        • 05_debian_theme: Set background and text colors, themes
        • 10_hurd Locates Hurd kernels
        • 10_linux Locates Linux kernels based on results of the “lsb_release” command.
        • 20_memtest86+: If the file /boot/memtest86+.bin exists, it is included as a menu item.
        • 30_os-prober: Searches for Linux and OS’s on other partitions and includes them in the menu.
        • 40_custom: A template for adding custom menu entries which will be inserted into grub.cfg upon execution of the “update-grub” command. This and any other custom file must be made executable to allow importation into grub.cfg.
  6. Adding Entries to Grub 2
    Menu entries can be added to grub.cfg automatically or manually.

    • Automatically.
      • When “update-grub” or “update-grub” is executed, Grub 2 will search for linux kernels and other Operating Systems. What and where is looks is based on the files contained in /etc/grub.d folder.
        • 10_linux searches for installed linux kernels on the same partition.
        • 30_os-prober searches for other operating systems.
    • Custom User Entries (/etc/grub.d/40_custom).
      • Entries to grub.cfg can be manually inserted by creating a file in the /etc/grub.d folder.
        • The name of the file determines the order in the menu. 30_os-prober entries will be placed before 40_custom entries, which will be placed before 50_my-sample entries.
        • Any created file must be made executable. This can be done as root by running “sudo chmod +x /etc/grub.d/filename“.
        • The files in the /etc/grub.d folder will be read and the contents included in grub.cfg when the “update-grub” command is executed as root.
      • A sample entry. This file creates a menu item for running the SystemRescueCD (previously installed) from a partition created on sda10. Folders and files must have been copied to the correct location in accordance with the SystemRescueCD if you wish to actually use this entry. Note this entry will not work for a SystemRescue ISO. See Section 14 for instructions on how to add an entry to boot ISO images.
        • Quote:
          exec tail -n +3 $0
          # This file provides an easy way to add custom menu entries. Simply type the
          # menu entries you want to add after this comment. Be careful not to change
          # the ‘exec tail’ line above.

          menuentry “System Rescue CD” {
          set root=(hd0,10)
          linux /sysrcd/rescuecd subdir=sysrcd setkmap=us
          initrd /sysrcd/initram.igz

        • Note the new partition naming convention. Devices start counting from “0” as done previously. sda is designated as “hd0”, sdb is “hd1”, etc. However the first partition is now designated as sda1. Counting partitions does not start with “0”. sda5 is “5”.
        • If the user wishes to get visual confirmation in the terminal that the 40_custom file contents are being added when “update-grub” is executed, the following line can be added to the /etc/grub.d/40_custom file:
          • Quote:
            echo “Adding 40_custom menu entries.” >&2
          • Place this line immediately after the first line – “#!/bin/bash” – and before the “exec tail -n +3 $0” line.
      • Tip: If you want to have your custom entries at the top of the menu (say you want custom titles), create a new file and name it “07_xxxx”. Since the files in /etc/grub.d/ are read sequentially, those in “07_custom” will be placed before those of “10_linux”. I recommend not naming a custom menu file lower than 06 so that any theme run from 05_debian_theme is allowed to run before any custom menu is created. After creating the file, run sudo update-grub and then check the value of “DEFAULT” in /etc/default/grub. If it doesn’t point to the correct menuentry, change the value of DEFAULT to the correct menuentry value.
      • Omitting memtest86+: To prevent “memtest86+” entries in your Grub 2 menu, remove the “executable” bit from /etc/grub.d/20_memtest86+. You can do this via a file browser by selecting “Properties (right click), Permissions”, or via the command line:
        sudo chmod -x /etc/grub.d/20_memtest86+
      • Omitting Recovery Mode entries: The file /etc/grub.d/10_linux was recently updated to include a check for recovery mode options. Edit /etc/default/grub and add or change this line:

        If you have an older version of /etc/grub.d/10_linux and the above does not work after updating grub, you can prevent “Recovery mode” entries in your Grub 2 menu, by editing /etc/grub.d/10_linux. If there are no conditional “if” statements concerning the recovery mode, place a comment symbol (#) in front of the following lines (at approximately line 146) of the old file:

        # linux_entry “${OS}, Linux ${version} (recovery mode)” \
        # “single ${GRUB_CMDLINE_LINUX}”

        If you wish to retain one “Recovery mode” entry for insurance, you can add an entry to /etc/grub.d/40_custom which will appear at the bottom of your grub menu.

      • Building a Totally Customized Menu: Ok, admit you are a control freak and you want to see only what you build yourself – customized titles, no “memtest86+” and no extra kernels. Here is how you do it:
        • Run sudo update-grub to get the current available kernels.
        • Copy the desired “menuentry” listings from /boot/grub/grub.cfg to /etc/grub.d/40_custom The entry begins with the line starting with “menuentry” and ends with a line containing “}”.
        • Add any other “menuentry” items you wish to see on the boot menu.
        • Edit the titles of the “menuentry” line if desired (between the quotation symbols). Do not change the lines following the “menuentry” line. Each entry should start with a “menuentry” line and end with a “}” on the last line.
        • Remove the executable bit from /etc/grub.d/10_linux, /etc/grub.d/20_memtest86+ and /etc/grub.d/30_os-prober
          Removing the executable bit from any file in /etc/grub.d will exclude the file from being included in grub updates.

          sudo chmod -x /etc/grub.d/10_linux /etc/grub.d/20_memtest86+ /etc/grub.d/30_os-prober
        • Run “sudo update-grub”
        • The updated /boot/grub/grub.cfg file should now contain only sections for “00_header”, “05_debian_theme” and “40_custom”.
        • The grub.cfg file will not be updated with the addition of a new kernel. To add a new kernel, make “10_linux” executable, run “sudo update-grub” to refresh the available kernels, and repeat these instructions.
      • Don’t forget to run “sudo update-grub” after making any changes to your /etc/grub.d files.
    • Manual Editing of grub.cfg (Not encouraged)
      Manual editing of /boot/grub/grub.cfg is not encouraged. Think of grub.cfg as a result, not as an initiator. The files that should be edited are contained in the /etc/grub.d folders and the /etc/default/grub file.

      In order to discourage its editing, grub.cfg is read-only. Even attempting to open, edit and save this file using root privileges cannot be done until the ‘read-only’ status is changed. If you must edit this file:

      sudo chmod +w /boot/grub/grub.cfg
      gksudo gedit /boot/grub/grub.cfg

      Note: This file is returned to ‘read-only’ status anytime the update-grub command is run.

  7. Removing Entries from Grub 2
    Entries should be removed by editing or removing files in the /etc/grub.d folder. The /boot/grub/grub.cfg file is read-only and should not normally require editing.

    • Automatically.
      • Too Many Kernels?
        • If you are not sure of the kernel you are currently using, in a terminal type “uname -r”.
        • Kernels removed via APT (Synaptic, “apt-get remove”, etc.) will automatically update grub.cfg and no user action is required. A great tool for removing kernels (and menu entries) is Ubuntu-Tweak, a safe and easy-to-use GUI app.
        • Many users keep one previous kernel known to work on the machine as a backup.
          • Synaptic
            • Type the kernel number in the search window at the upper right (for example – 2.6.28-11).
            • Find the “linux-image” and “linux-headers” files for the applicable kernel (example – linux-image-2.6.26-11 or “linux-image-2.6.26-11-generic).
            • Right click and select “Mark for Complete Removal” and then press the Apply main menu button.
            • The kernels will be removed from your system and from the Grub menu.
          • Ubuntu-Tweak
            • Go to the Ubuntu-Tweak download page.
            • Add the repository as per the instructions, or download the file manually and double-click the .deb file to install.
            • Ubuntu-Tweak will be available under Applications > System Tools.
            • To clean the kernels:
              • Select “Package Cleaner” on the left and “”Clean Kernel” from the right panel.
              • Press the “Unlock” button at the lower right, enter your password.
              • Select from the displayed list the kernel images and headers you wish to remove. The kernel in use is not listed.
              • Press the “Cleanup” button at the lower right to remove the selected kernel images and headers.
          • Too Many Operating Systems?
            • Other Operating Systems which have been removed from the computer will also be removed from the menu once “update-grub” is run as root.
            • Menu items are placed on the Grub2 menu by scripts. If you don’t want other Operating Systems to be entered in the menu, disable /etc/grub.d/30_osprober
              • Run this command to stop the script from running: sudo chmod -x /etc/grub.d/30_os-prober
              • DISABLE_30_OS-PROBER=’true’ in /etc/default/grub
          • Memtest86+
            • Code:
              sudo chmod -x /etc/grub.d/20_memtest86+
        • Run the update-grub command to allow the changes to be incorporated in grub.cfg
    • User-Created Entries.
      • To remove a user-created menu entry, remove the applicable file from the /etc/grub.d folder.
      • If a custom file contains multiple entries, individual items may be removed and others retained.
      • Once the file has been removed or edited, run “update-grub” to update grub.cfg.
  8. Grub 2 Splash Images & Theming
    Why reinvent the wheel? Visit this site for an excellent presentation on creating Grub 2 images:

    However, if encrypted disks are not an issue, here are the basics:

    • Manually copy grub splash images into the /usr/share/images/grub folder or install the default grub2 splash images via Synaptic or:
      sudo apt-get install grub2-splashimages
    • The grub2’s splash images are controlled by /etc/grub.d/05_debian_theme. Open this file for editing:
      gksudo gedit /etc/grub.d/05_debian_theme
      • Grub 1.97~beta4
        Find the following line and edit the highlighted area, replacing it with the grub splash image you wish to use (and located in /usr/share/images/grub):

        for i in {/boot/grub,/usr/share/images/grub}/moreblue-orbit-grub.{png,tga} ; do

        Note: There is a period ( . ) following the filename.

        • At one point Grub 2 splash images were downloaded and stored in /usr/share/images/desktop.base If this is where your grub images are stored, change the address in the previous command accordingly ( … /usr/share/images/desktop-base} … ).
      • Grub 1.97 (non-beta) & later)
        It’s a little easier to understand in Grub 1.97 (non-beta) and later versions of Grub. Find the following line and edit the highlighted area, replacing it with the path and grub splash image you wish to use:


        Example: WALLPAPER=”/home/my_username/grub_images/my_grubimage.png”

        • At one point Grub 2 splash images were downloaded and stored in /usr/share/images/desktop.base If this is where your grub images are stored, change the address in the previous command accordingly ( … /usr/share/images/desktop-base} … ).
    • Save the file, then update grub2:
      sudo update-grub

    A Note About Grub 2 Theming
    Theming is still under development in Grub 2. There are several different approaches being taken and users of Lucid have had success incorporating theming into their bootlaoder menus. For those interested in trying out the experimental theming possibilities, here are some references:
    GRUB2 theming for lucid? This thread has an excellent discussion about the state of theming in in bootloaders, as well as instructions on how to set it up as you get further into the thread. Both BURG and Grub 2 experimental are discussed.
    Grub 2 Experimental: One method of introducing theming, when combined with this Launcpad PPA for Grub 2 experimental, Felix Zielcke’s PPA
    BURG: and

  9. Changing Menu Resolutions
    If the user wishes to change the resolution of the GRUB 2 screen while using a splash image follow these steps:

    1. Set the desired resolution in /etc/default/grub
      • Change the value of GRUB_GFXMODE= (Example: GRUB_GFXMODE=800×600)
        • If unsure of what resolutions are available to GRUB 2 they can be displayed by typing vbeinfo in the GRUB 2 command line. The command line is accessed by typing “c” when the main GRUB 2 menu screen is displayed.
    2. Select an image of the same size and make the change in /etc/grub.d/05_debian_theme
      • The image name is located in the line beginning with ” for i in {/boot”
      • If an image of the correct size is not used, the menu will not be positioned correctly.
      • Use the image editor of your choice to create/resize an image to the correct size.
      • The user may be able to view the image size via Properties in a file browser (check the Properties Image tab in Nautilus).
    3. Run update-grub as root to add the new settings to /boot/grub/grub.cfg
  10. Basic Password Protection

    Note: To reduce the size of this entry, a separate post with information on establishing Grub 2 password protection is located on the Ubuntu forums at: Grub 2 Password Protection and in the links at the bottom of this post.

    Grub 2 currently supports unencrypted password protection. Encrypted password protection using PBKDF2, as well as password scripting, is currently under development.

    Some of the major points regarding Grub 2 password protection:

    • Grub 2 has the ability to set password protection on individual menuentries and/or for specific users. Examples: Password protect Windows Recovery; prevent user2 from opening the Recovery mode.
    • If password protection is enabled, the superuser username and password are required to gain access to the Grub 2 command line and menu editing modes.
    • The username and/or password do not have to be the same as the Ubuntu logon name/password.
    • This is basic password security. The name/password are unencrypted; anyone having physical access to the machine and more than an elementary knowledge of how Linux works will be able to access the configuration files and bypass this feature.
    • Grub 2 password protection is still being developed. Encryption is available in experimental versions only. If password protection is used, recheck your scripts for changes whenever a new Grub 2 update is released. In 1.97~beta4, passwords must be assigned to each desired menu item. In Lucid Lynx, expect Grub 1.97 to password protect the entire Grub 2 menu if a superuser is designated.
  11. How to Boot to the Recovery Mode w/o a Menu Option
    1. If you have Grub 2 set to boot without displaying the menu at all, hold the SHIFT key down until the menu displays. (In Grub it was the ESC key.)
    2. Press any key once the menu is displayed to ‘freeze’ it. Then arrow to the kernel you want to boot.
    3. Press “e”
    4. Scroll to the end of the “linux /boot/vmlinuz….” line. If displayed, remove “quiet” and/or “splash”. Add the word “single” to the end of the line.
    5. Press CTRL-X to boot to the Recovery menu.
  12. Uninstalling GRUB 2
    The command line produces a cleaner uninstall and reinstallation. While adding and removing the packages can be accomplished with Synaptic, certain steps must be accomplished in a terminal.

    • Open a terminal: Applications, Accessories, Terminal.
    • Make backup copies of the main GRUB 2 folders & files
      • Code:
        sudo cp /etc/default/grub /etc/default/grub.old
        sudo cp -R /etc/grub.d /etc/grub.d.old
        sudo cp -R /boot/grub /boot/grub.old
    • Remove GRUB 2
      • Ensure you have an Internet connection and reliable power source. An interruption of either could leave your system in an unbootable condition.
      • Code:
        sudo apt-get purge grub-common grub-pc
      • The user will be warned the system will be unbootable without installing another bootloader.
      • Once the packages are removed, many files will still remain in ‘/boot/grub’
    • Install GRUB 2
      • Code:
        sudo apt-get install grub-common grub-pc
        • The user will be asked for any special commands to add to the default “linux” line. If you aren’t sure, leave it blank, press the TAB key to highlight “OK” and press ENTER.
        • Select the appropriate drive on which to install Grub2 (sda, sdb, etc) by highlighting the entry and pressing the space bar. Normally a partition (sda1, etc) should not be selected.
      • Code:
        sudo update-grub
      • Reboot
  13. Reinstalling GRUB 2 from LiveCD
    If you cannot boot from GRUB 2 and need to reinstall it, here is the simple method. For more details or for advanced options, refer to the Ubuntu community documentation here: Grub2 – Reinstalling GRUB 2:

    • Boot the Karmic or Lucid LiveCD (Try without installing).
    • From the Desktop, open a terminal – Applications, Accessories, Terminal.
    • Determine your normal system partition – `sudo fdisk -l` (That is a lowercase L)
    • If you aren’t sure, run `df -Th`. Look for the correct disk size and ext3 or ext4 format.
    • Mount your normal system partition:
      sudo mount /dev/sdXY /mnt
      • Example: sudo mount /dev/sda1 /mnt
      • Note: The partition to mount is normally the partition on which Ubuntu was installed: sda1, sdb5, etc. If you have a separate /boot partition, use the device on which the /boot partition is located. Grub 2 works best when installed in the MBR of the drive to which BIOS boots. Also remember that you mount the partition (including the number) in this step, but you do not include the partition number when you run the “sudo grub-install” command later.
      • Note: GRUB 2 counts the first drive (X) as “0”, but the first partition (Y) as “1”
    • Only if you have a separate boot partition:
      • Code:
        sudo mount /dev/sdXY /mnt/boot

        with sdXY being your /boot partition designation.

    • Reinstall GRUB 2:
      sudo grub-install --root-directory=/mnt /dev/sdX
      • Example: sudo grub-install –root-directory=/mnt /dev/sda
      • Note: Substitute the device on which Ubuntu was installed – sda, sdb, etc. Do not specify a partition number.
    • Unmount the partition *:
      sudo umount /mnt
      • * Note: If you mounted a separate /boot partition, unmount it first:
        sudo umount /mnt/boot
    • Reboot.
  14. Booting LiveCD and Other ISOs
    Grub 2 provides the capability to boot certain .iso images. These image files (ISO’s) include the Ubuntu LiveCDs, SystemrescueCD and the Parted Magic CD.

    The following examples assume the ISO image is located on the user “drs305″‘s Desktop on sda1. The address of the file, named test.iso would be /home/drs305/Desktop/test.iso. Grub 2 uses the convention (hd0,1) to designate sda1. The user must change the path and filenames in the following examples to match the location of the ISO image on their system.

    In order to incorporate an ISO boot option into the Grub2 menu, take the following steps:

    • Open the /etc/grub.d/40_custom file for editing as root, or create another custom file in the same folder.
    • Create a menuentry. Leave the existing first 5 lines of the file alone. Any entries should be made below the pre-existing lines.
    • Make sure the partition, path and filename are correct for the image you will be using.
    • Ensure there are no spaces at the end of any lines.
    • Save the file, run “sudo update-grub”, and then check the contents of /boot/grub/grub.cfg to make sure the contents of the 40_custom file are included. The user will not see the custom file listed in the terminal during the running of the update-grub command.

    The following are examples of an Ubuntu LiveCD, the SystemRescueCD, and the Parted Magic CD. In the examples, the ISO images are stored on user “drs305″‘s Desktop on sda1. These entries would be added to the /etc/grub.d/40_custom file.

    • For the SystemRescue CD, replace “rescuecd with “rescue64” on 64-bit systems.
    • The “quiet” option has been omitted from the “linux” line in order for the user to see progress during boot. Even so, there may be periods where the boot appears to halt. Let it continue unless an error message is visible.
    menuentry "Lucid ISO on /dev/sda1" {
    loopback loop (hd0,1)/home/drs305/Desktop/ubuntu-10.04-beta2-desktop-amd64.iso
    linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/home/drs305/Desktop/ubuntu-10.04-beta2-desktop-amd64.iso noprompt 
    initrd (loop)/casper/initrd.lz
    menuentry "  SystemRescue-ISO on /dev/sda1" {
    loopback loop (hd1,5)/home/drs305/Desktop/systemrescuecd-x86-1.5.1.iso
    linux (loop)/isolinux/rescuecd setkmap=us isoloop=/home/drs305Desktop/systemrescuecd-x86-1.5.1.iso
    initrd (loop)/isolinux/initram.igz
    menuentry "Test Parted Magic ISO on /dev/sda1" {
    set root=(hd0,1)
    loopback loop (hd0,1)/home/drs305/Desktop/pmagic-4.10.iso
    linux (loop)/pmagic/bzImage iso_filename=/home/drs305/Desktop/pmagic-4.10.iso boot=live load_ramdisk=1 prompt_ramdisk=0 noeject noprompt 
    initrd (loop)/pmagic/initramfs
  15. Booting from the Rescue Mode
    Here are some things to keep in mind regarding the rescue mode.

    • Use the “set” command to review the current rescue mode settings.
    • Use “ls” to see the partitions. You must determine the Ubuntu partition.
    • Use “ls (hdX,Y)/boot” to inspect the partition you think is the Ubuntu partition. If you find the correct partition, it will show files and the grub folder. (Example: ls (hd0,5)/boot )
    • Use “set prefix=(hdX,Y)/boot/grub to set the correct path to the grub folder. This must be correct before you can use rescue commands or load the kernel.
    • set root=(hdX,Y) X is the device/drive, starting with 0. Y is the partition, starting with 1. (Example: (hd0,1) is sda1. (hd3,5) is sdc5.
      • For Wubi installs, use: set root=(loop0)
    • You must load modules before you can use them, and the prefix path must be correct.
    • If an unknown command or file not found error message is generated, the path in the prefix is incorrect or the module is not loaded.
    • insmod normal help linux – Loads the normal, help, linuxmodules. If they load there is no terminal message. Additional modules may be loaded in the same manner.
    • linux /vmlinuz root=/dev/sdXY ro – Load the linux kernel, substituting the correct designations for “X” and “Y” (example: sda1). The user will see a message showing the kernel has been loaded. (See graphic above)
      • Note: For Wubi installs within Windows, use this code: linux /vmlinuz root=/dev/sdXY loop=/ubuntu/disks/root.disk ro
    • initrd /initrd.img Load the initrd image. When pressing enter, the user may or may not see a message in the terminal. (See highlighted graphic above)
    • boot

    More information on the rescue mode is available in the Command Line & Rescue Mode section of the Ubuntu Grub 2 community doc.

  16. Restoring GRUB2 / XP / Vista / Win 7 Bootloaders
    talsemgeest has written an excellent guide on how to restore the bootloaders of various operating systems following the installation of another one. Make sure you reference the section for “9.10 and Beyond”, which is for GRUB 2.

    Rather than duplicate his efforts in this post, here is the link to the original:

    Restoring Windows MBR without a Windows CD
    If you want to boot directly to Windows but Grub has overwritten the MBR, the normal procdeure is to use the Windows CD to restore things. If you do not have access to the Windows CD, the following commands will rewrite the MBR, removing Grub and allowing the system to boot directly into Windows.

    Boot the Ubuntu LiveCD, open a terminal (Applications, Accessories, Terminal) and enter the following commands. Make sure you correctly identify the Windows device (normally sda):

    sudo apt-get install lilo
    sudo lilo -M /dev/sda mbr

    Bonus Section: BSD Menuentry – If you need to have an entry to boot into BSD/Windows from the Grub2 menu, here is the menuentry to put into a custom file:

    menuentry “FreeBSD” {
    insmod ufs2
    set root=(hd1,1)
    chainloader +1
  17. Grub Rescue Image
    A bootable Grub 2 rescue image is available for both floppies and CDs. To obtain the images, install “grub-rescue-pc”. Once installed, three images are available in /usr/lib/grub-mkrescue. Use the I]grub-mkrescue [/I] command to create the rescue ISO. See the MAN page for more information. Note: A customized rescue ISO only uses the current systems Grub 2 /boot/grub files. No information from /etc/grub.d or /etc/default/grub is imported.

    The ISO only boots to the grub prompt. It uses the Grub 2 files found on the ISO; if the problem is with the system’s Grub 2 files the rescue ISO should boot. However, the ISO contains no kernels and must be told where to find the correct kernel and initrd files on the system. The user must know the drive/partition on which the boot files are located and the non-Grub files must exist and be uncorrupted.

    If the user hasn’t made a rescue floppy/ISO, other alternatives include the Ubuntu Installation/LiveCD or SuperGrub Disk.

    • grub-rescue-floppy.img – For floppy images.
      • To Install:
      • Insert a disk in the floppy drive.
      • Code:
        fdformat /dev/fd0
        mkfs -t msdos /dev/fd0
        dd if=/usr/lib/grub-rescue/grub-rescue-floppy.img of=/dev/fd0
    • grub-rescue-cdrom.iso – When burning the image to a CD, select the option to copy an image and not the files.
      • Generate the image using the following command:
        • Code:
          grub-mkrescue --output=<path/filename>
      • If an error message “/usr/bin/grub-mkrescue: 324: xorriso: not found”, install the xorriso package and rerun the command.
      • Copy the ISO image to a CD using the CD burning app of your choice.

    Once the grub rescue floppy/CD boots to the grub prompt, run the following commands.

    The commands are slightly different than those used for booting by other means. The Grub 2 files on the floppy/CD are used, and only the kernel and initrd.img files need to be loaded.

    Command line tips:

    • Drives start counting at 0 (sda=0, sdb=1, etc). Partitions start counting at 1 (1=1, etc). Substitute the correct drive letter for X, correct number for Y, and substitute the correct numbers for (hd0,1).
    • You must type the entire path and kernel and initrd names if (hdX,Y)/vmlinuz and (hdX,Y)/initrd.img do not exist. You can check by running this command:
      • ls (hdX,Y)/

      If vmlinuz and initrd.img do not exist at (hdX,Y)/, you can simplify the typing using the TAB complete feature.

    • On the linux line, type “vml” and then TAB to help complete the kernel number. Ensure the complete kernel name is entered. Be sure to fill the kernel number completely, and don’t forget the “root=” and “ro” sections of the linux line.
    • On the initrd line, type “ini” and TAB to fill in a large part of the name. Continue typing/TABBING to ensure the complete .img name is used.
    • Sections in bold should be changed to match the user’s system.
    set root=(hd0,1)
    linux (hdX,Y)/vmlinuz root=/dev/sdXY ro
    # or if (hdX,Y)/vmlinuz does not exist:
    linux (hdX,Y)/boot/vmlinuz- root=/dev/sdXY ro
    # then
    initrd (hdX,Y)/boot/initrd.img 
    # or if (hdX,Y)/initrd.img does not exist:
    initrd (hdX,Y)/boot/initrd.img-2.6.33-25-generic 
  18. Selected Problems & Bugs

    meierfra has been busily building pages which detail how to solve many of the common problems users are experiencing with Grub 2. His SourceForge web page should be one of the first stops for those seeking answers to Grub 2 issues.

    Wubi (Windows Ubuntu) Users – wubildr
    Grub2 updates in the spring of 2010 triggered a bug in the ntfs module causing Wubi boot failures. The solution to this boot problem was posted by Agostino Russo and is found in this Lucid Lynx LaunchPad Bug Report #477169, Post 210. The module causing the errors has been fixed and replacing the “wubildr” file in Windows permanently solves this problem. meierfra has kindly provided clear instructions on how to fix this problem at…lems:Wubi_9.10

    “Fix symbol ‘grub_puts’ not found” Error. After Upgrading from Karmic to Lucid
    BIOS and the Grub2 device map may no longer agree. See this post:…ound-when.html

    Lose Ubuntu/Windows After Installing the Other
    If you have lost the ability to boot into Windows or Ubuntu following the installation/reinstallation of the other OS it could be an overwritten MBR issue. If the OS was previously working, there is an excellent guide written by talsemgeest that may very well restore the lost OS. Here is the link:
    How to restore the Ubuntu/XP/Vista/7 bootloader (Updated for Ubuntu 9.10)

    No Menu On Initial Boot
    If you are already on the Ubuntu Desktop, run “sudo update-grub”. This may detect additional operating systems, which may allow the Grub menu to be displayed on the next boot. Otherwise:
    Open /etc/default/grub:

    gksu /etc/default/grub

    Disable the “GRUB_HIDDEN_TIMEOUT=” line by placing a # symbol at the beginning of the line.
    Set “GRUB_TIMEOUT=” to a positive integer (number of seconds to display the menu before automatic selection) or “-1” to wait for the user to press ENTER (no timeout). The entry will look like this:


    Save the file, update grub (“sudo update-grub”) and reboot.

    External Drive Installs – Bug bug/496435
    Installs of Ubuntu on external drives can cause problems as grub-install uses device names (e.g. sda, sdb) rather than UUIDs in certain circumstances. If connected to another machine when an update of grub-pc is made, the upgrade may be written to the incorrect device and make the computer unbootable.

    A workaround is posted on the bug link above.

    External Drive Installs and MBR – Bug bug/414996
    When installing Ubuntu to a USB drive, the potential exists for GRUB 2 to write to the hard drive’s MBR or split the installation between the hard drive and the USB drive (rather than completely on the USB device). This can render the main drive unbootable.

    Workaround: During the final stages of the install there is an “Advanced” button which allows the user to select the install location.

    HP Machines Fails to Load Grub after Using Windows – Bug [URL=”″%5Dbug/441941/URL%5D
    After installing Grub 2 on a HP machine, the system boots normally until the first time it’s booted into Windows. On the next boot, the system hangs at “Grub loading”.

    Workaround: HP protection tools are rewriting to the MBR when Windows is run. The protecttools app must be removed/disabled. Refer to post #10 in the Bug Report.

    VGA Deprecated” Message on Boot
    Symptom: A blank screen appears with a message concerning VGA being deprecated after the menu item is selected (manually or by default). The message will be a variation of: “VGA=792 is deprecated. Use set GFX payload=1024x768x24, 1024×768 using the linux command instead.”

    The message probably is informing the user that there is a vga entry on either the “GRUB_CMDLINE_LINUX_DEFAULT=” or “GRUB_CMDLINE_LINUX=” line of /etc/default/grub. “Deprecated” means that there is a newer, preferred way to convey this instruction in GRUB 2. (Note the “vga=” method will still work, despite the message. It is advisory only.)

    In the example above, the line would probably look something like:

    GRUB_CMDLINE_LINUX_DEFAULT=quiet splash vga=792″

    To conform to the desired format and eliminate the message, change the above lines in /etc/default/grub to look like the following, using the “vga” value, and translated value, found in your current default file:


    Save the file and run “sudo update-grub” for the changes to be incorporated in the menu.
    There is a vga conversion table located at: From the GRUB 2 command line, you can run “vbeinfo” to see resolutions supported by your system.

    File Not Found (From a Grub 2 prompt)
    Not to be confused with the Grub Legacy “File Not Found – Error 15” (See next).
    When this message appears in Grub 2, it means that G2 cannot find one or more of the files required to accomplish the task. If this occurs, the user can use the “ls” command to find out what drives/partitions G2 sees. The output normally is something like (hd0) (hd0,1) (hd0,2) (hd0,5) (hd1) (hd0,1), etc. Remember the first drive (X) is “0”, the first partition (Y) is “1”. You can then inspect the contents, checking for the proper files with /boot, with “ls (hdX,Y)/boot”, for instance.

    Often in this case the user must reset “root” and/or “prefix”. You can see the current settings from the G2 command line with the command “set”. If you know the device/partition you want to boot, from the Grub 2 terminal run the following. You will get no feedback if there isn’t an error. You can check the results by running “set” again.

    set root=(hdX,Y)                    # Example:  set root=(hd0,5)
    set prefix=(hdX,Y)/boot/grub        # Example for a normal Ubuntu install on sda1: set prefix=(hd0,1)/boot/grub

    error: no such device: 86d32ee3-aec6-490b-8dab-e5cfff9c7af9
    This error is the result of a failure of the GRUB 2 search function. There are various bugs associated with the search function. At the Grub2 menu, highlight the OS you want to boot. Press “e” to edit the menuentry. Delete the entire “search …” line, then CTRL-x to boot.

    If the above does not solve the problem, hightlight the OS you want to boot, press “e” to enter the grub edit mode, and on the line beginning with “linux /” change the section “root=UUID…” to “root=/dev/sdXY …” with sdXY being the drive and partition on which the system is installed.

    Once you have booted into the system, you will modify the /usr/lib/grub/grub-mkconfig_lib file in accordance with this link:
    Boot Problems:search

    File Not Found (Error 15)
    This error is the result of a GRUB 2 installation to /boot but a Master Boot Record ( MBR ) which still contains Grub legacy. This can happen if you don’t select your drive when running sudo upgrade-from-grub-legacy. Shortly after starting this command the user will be asked to select the device (sda, sdb, etc). Highlight the drive and press the space bar to select it when presented with this screen. Failure to select a drive will result in an Error 15.

    To recover from this error, GRUB 2 must be reinstalled. Go to the community documentation File Not Found (Error 15) for instructions.

    If you find you need to remove the following lines manually to get Grub to boot properly:

    save_env recordfail

    Open /etc/grub.d/10_linux with admin rights:

    gksu gedit /etc/grub.d/10_linux

    Look for this section and comment the lines in bold;

    linux_entry ()
    menuentry “$1” {
    save_env recordfail

    Change it to:

    – linux_entry ()
    menuentry “$1” {
    # recordfail=1
    # save_env recordfail

    Save the file, then run

    sudo update-grub

    The two lines should no longer appear when you press E to view the selection in the Grub 2 menu. You will see a “save_env save_entry” line but this should not cause the failure if you successfully booted the previous time.

    Grub 2 Hangs 10-30 Seconds between Grub 2 Loading and Menu Display.
    This is a known bug that can be caused by GRUB 2 and /boot being loaded on different partitions. To fix the problem, run

    sudo dpkg-reconfigure grub-pc

    Select to load Grub 2 on the same device as the /boot partition. In your system BIOS, change the drive to boot from first to the drive with the /boot partition.

    Wubi Installs within Windows Won’t Boot.
    This bug has been fixed in Ubuntu 10.04. For prior versions, the user is greeted with “Try (hd0,0) : NTFS5: ” This is a known bug as well as others that may cause Wubi boot failures. Refer to meierfra’s Boot_Problems:Wubi_9.10 page.

    “Grub loading. The symbol ‘ ‘ not found. Aborted.” on Dell machines..
    On Dell computers with Dell DataSafe Local Backup (DDSLB) installed, the above message is displayed with a series of characters within the ‘ ‘ section. This is a reported bug,
    bug #482757. Thanks to merry_meercat’s post which details how to fix the problem.

    “error: the symbol `grub_xputs` not found”.
    Use the Live CD to chroot into your Ubuntu partition and purge/reinstall Grub2. See post #5 here:…39&postcount=5.

    Grub “error: out of disk” or “failed to boot default entries”.
    This error message is sometimes generated when Grub 2 cannot properly write to the file /boot/grub/grubenv. Refer to meierfra’s Boot_Problems:Write page.

    “Grub loading. The symbol ‘ ‘ not found. Aborted.” on Dell machines..
    On Dell computers with Dell DataSafe Local Backup (DDSLB) installed, the above message is displayed with a series of characters within the ‘ ‘ section. This is a reported bug,
    bug #482757. Thanks to merry_meercat’s post which details how to fix the problem.




A large number of Linux Distributions these days including Fedora,Ubuntu,Kubuntu etc which have become quiet popular and are increasingly being accepted by the Desktop Users lack proper support for playing the popular Audio/Video Formats right out of the box mainly because of certain patent and royalty issue . The issue of no cross platform file compatibility has been robbing common users of ability to display files and this has been one of the major reason for slow adaption of Linux on the Desktop Front. The case isn’t that the Linux dosent support these formats but is not intentionally added to the Linux distribution because of

// <![CDATA[//
// <![CDATA[//

legal reasons. However with a bit of tweaking/installing applications it is possible to run these files in the Linux Operating system . Here in this article we look at playing various Audio/Video format on the Linux Operating System. The system on which these have been tried is a Fedora Core 6 based distribution however all these should be equally applicable to other Linux distributions.

Real Player

Playing Real Media(.rm) Files :-

Real Player has been available on the Unix/Linux platform since a number of years . The Current version of the realplayer available on linux is the RealPlayer 10 though not as feature rich or rich in user interface as one available on the windows platform but still very usable and does the job of playing audio/video files quiet well and can be obtained at the following address .

Besides having ability to play the RealMedia(Audio and Video) (.rm,.ra,.rv,.rmvb) File , it can be used for playing mp3 files , (.3gpp) files popularly used in cellphone cameras , and the open source Audio format Ogg Vorbis(.ogg).

The Linux Version of Popular Real Player

Playing mp3 files : –

Mp3 is one of the most widely used audio format around the world right now so it would be silly if Linux could not play mp3 .

A number of players exist for playing mp3 files :-


This is command line based audio player that forms the backbone of number of graphically available Audio players , it is one of the most efficient player on the Linux platform and can play mp3 files on as low hardware specs as a 120Mhz Pentium Processor based computer . A similar command line application is mpg321 that can be used for playing mp3 files.

mpg123 or mpg321 file name – To play mp3 file

Ctrl + C – This skips to next track

Typing Ctrl + C Twice – quits the application

mpg123 -z *.mp3 : – Command would play all the mp3 files in the directory with a shuffled play-list.

mpg123 -w filename.wav filename.mp3 :- This command would convert the mp3 file to wav file , whic can then be used for burning on to cd to make audio cd.

However if your audio files/file is located in some location in sub-folders and u don’t know exact location then following command can be used

mpg123 $ (find -name “Filename”)

Website : –
Website : –


This is the WinAmp alternative for the Linux platform and has been in existence for quiet some time now , it is based on mpg123 library for playing mp3 files . The application has look similar to winamp application and can be beautified with a number of skins , also XMMS supports a large number of plugins that add extra functionality to the player. Besides having ability to play mp3 files it can be used for plying WMA files also by installing external plugin.(
Website : –


Xine is also one of the popular video playback engine , Xine is based upon xine-lib and uses external libraries to play popular audio/video files. Xine with external plugin can play popular Windows Media files, AVI,MPG,etc and can be used for playing VideoCD/DVD .It can be used for playing DVD movies with the use of external library livdvdcss ,though because of legal issues its use may be illegal in some places . Xine provides powerful API that can be used by other external application for playing Video files and Video processing . A Number of frontends exist for Xine including totem(Gnome) , Kaffeine (KDE) , xine-ui etc. Xine can play almost all popular file-formats by install extra w32codecs which are dll files used by xine for decoding popular media formats .
Here is the list of supported video codecs from the Xine website

Kaffeine a popular video frontend to Xine on KDE
Video codecs supported

o mpeg 1/2
o mpeg 4 (aka OpenDivX)
o ms mpeg 4
o divx 3/4/5
o windows media video 7 & 8
o motion jpeg
o Cinepak
o DV
o ms video 1 (msvc)
o ms rle
o Sorenson SVQ1/SVQ3 (often used in Quicktime trailers)
o creative yuv (cyuv)
o roq video
o theora
via external binary/win32 codecs (not included in xine):
o Indeo 3.1-5.0
o Window Media Video 8,9
o On2 VP3.1
o I263
o Real Media 2.0, 3.0, 4.0
currently unsupported/untested Formats:
o 3ivx
o h263 (aka Real Video 1.0)

File formats (System layer / media types)

* direct DVD playback (of unlocked/unencrypted DVDs, see below)
* Video CD
* Audio CD
* mpeg program streams (.mpg, .mpeg)
* mpeg transport streams (.ts)
* ogg (.ogg, .ogm)
* avi (.avi)
* asf (.asf, .wmv, .wma)
* quicktime (.mov, .mp4)
* mpeg-video (.mpv, .m2v)
* mpeg-audio (.mp2, .mp3)
* Sega Saturn FILM (.cpk)
* Id Software RoQ (.roq)
* wav (.wav)
* Autodesk FLIC (.fli)
* real (.rm, .ra, .ram)
* raw dv (.dv)
* network graphics format (.png, .mng)
* Creative Voice (.voc)
* Sun/NeXT SND/AU (.snd, .au)
* Wing Commander III (.mve)
* Westwood Studios files (.vqa, .aud)
* Electronic Arts WVE (.wve)
* AIFF (.aif, .aiff)
* YUV4MPEG2 (.y4m)
* SMJPEG (.mjpg)
* raw AC3 (.ac3)
* Dialogic VOX (.vox)
* TechnoTrend PVA (.pva)
* Playstation STR (.str)
* Nullsoft Video (.nsv)
* 4X Technologies (.4xm)

Audio codecs supported:

o mpeg audio (layer 1,2,3)
o a/52 (aka ac3, dolby digital)
o aac (used in .mp4 files)
o dts (via external decoder)
o vorbis
o pcm
o adpcm (MS/IMA/DVI/Dialogic)
o mu-law and A-law
o roq dpcm
o Real Media dnet audio
o Real Media 28.8 audio
o DivX audio (WMA)
o GSM 6.10
o NSF (NES sound format)
o Speex
via external binary/win32 codecs (not included in xine):
o Intel Music Coder
o Voxware Metasound
o Real Media Sipro/Cook/dnet
o QDesign Music 1/2 (QDM1/QDM2)
currently unsupported/untested Formats:
o some formats frequently found in quicktime streams (Qualcomm Pure Voice…)

Xine with LCD Interface

Website : –


MPlayer stands for Movie Player for Linux and is another popular video player for Linux platform . Besides being open source as most of the application under Linux are , it is available not only on Linux , But also on Windows,OS X etc. MPlayer is a command line based application for playing video files and a number of frontends exist for mplayer making it easier for newbies to play Media Files. The List of supported file formats is quiet similar to Xine as MPlayer also uses some of the library used by xine for decoding videos including w32codec pack.
MPlayer website states that it can play damaged Video CD’s, bad AVI files with damaged index properly though i was not able to confirm it. So this may be another plus for some with collection of old VCD’s.
Another useful application included with Mplayer is mencoder which can convert one Mplayer playable format to another.

Some of the supported file formats are : – MPEG, VOB, AVI, OGG/OGM, VIVO, ASF/WMA/WMV, QT/MOV/MP4, FLI, RM, NuppelVideo, yuv4mpeg, FILM, RoQ, PVA, Matroska files, supported by many native, XAnim, RealPlayer, and Win32 DLL codecs. You can watch VideoCD, SVCD, DVD, 3ivx, RealMedia, Sorenson, Theora, and MPEG-4 (DivX) movies too.
Above list of supported file formats taken from mplayer’s website.

One of the common frontend for MPlayer is Gmplayer which is skinnable .

Gmplayer the graphical frontend to MPlayer

Website : –

Video Lan Player : VLC Player

VLC Player is another of popular video player available under Linux . It is released under GNU General Public license and is available for different platform including Windows,Linux,BeOS,Mac OS X etc. VLC player is based upon free open source libraries like libdvdcss,FFMpeg for decoding various video formats. Since both Xine and Mplayer are based upon FFmpeg file hence the list of supported codecs without installing extra files is almost same for all three players. One Important feature of VLC Player is it’s ability to play files over NetWork Protocols. The Frontend of VLC player is created using wxWidgets toolkit and it’s appearance can be changed by using different skins. One Popular feature of VLC Player is it’s ability to play files that are incomplete/broken or partially downloaded , making it useful for previewing file while downloading on file-sharing networks. Besides this another interesting feature of vlc player is it’s ability to play files contained inside iso image. This might prove useful if you have copy of a cd on your hard-disk and you want to play file without burning on the cd. Besides this another thing for which you can use VLC player is to play FLV files on Linux/Windows which are Flash Video files popularly used on video-sharing website like YouTube .

Website : –

iTunes alternative to linux : – Banshee and Rhythmbox

Banshee :- is a music player for Linux platform written on Mono,C# and uses Helix and GStreamer as a backend to play Ogg,MP3 and other formats . Besides having a user friendly interface it can be used for Syncing iPODs, importing music from cd . Besides having all these features it’s feature can be extended via adding external plugins since it has a nice plug-in architecture . Banshee is released under MIT License .

Rhythmbox : – Rhythmbox is gnome application based upon GStreamer architecture and has a similar interface to itunes. With SoundJuicer plugin it can import audio cd’s , it has ability to sync iPODs . It has support for Internet Radio . Besides all the features being a gnome application it integrates with gnome quiet nicely . Some of the popular plugins are :-

Gaim-RhythmBox : – Shows song information for currently playing song in the Gaim instant messenger .

BlueRemote : – Allows controlling of rhythmbox from a blue tooth enabled phones .

FoxyTune : – Allows controlling of rhythmbox application from Mozilla FireFox browser without leaving the browser .

Rhythmbox running on FC 6

Website : –
Website : –
Article written by Ambuj Varshney<> for
(C) 2007 Ambuj Varshney

Top things to do after installing ubuntu linux

So you’ve just installed Ubuntu 9.10, the cute and cuddly Karmic Koala, but now you’re confronted with a most pertinent question, “What do i do now?” Ubuntu is a very complete and full-featured Linux distribution, but no operating system can come with everything you want. There’s much more fun to be had in what comes after installing the OS on your machine: now you get to set it up with all the best software it didn’t already come with! This list of the top things to do immediately after installing your newly acquired copy of Ubuntu doubles as a general list of great software to try out and use, complete with links to any special instructions on how to set them up, Terminal commands for those who prefer a command-line interface (CLI), and when available, personal package archives (PPA), repositories to keep the applications at their newest version, not just the security updates provided for you by default. Repositories can be added easily by clicking the “Add…” button in the “Other Software” tab of Software Sources and entering the provided APT Line. Feel free to pick and choose; enjoy!

Basic Stuff

Download Mirror & Updates

After every major Ubuntu release (beta, release candidate, and especially the final), the official servers will be unbearably sluggish. To select an alternative server, just launch Software Sources (System ⟶ Administration ⟶ Software Sources) and click the drop-down menu next to “Download from:” and select “Other…” at which point the Choose a Download Server window should pop up. If you know of a fast local server you may select it from the list, or you can try clicking the “Select Best Server” button to launch a tool that will test all the servers for the fastest connection and choose the best result.

Optionally, jump to the “Updates” tab. If you’ll always be running the newest version of Ubuntu and are using third-party repos, which we will be, then leaving the defaults should be fine. “Unsupported Updates (karmic-backports)” gives you, as the name implies, unsupported versions of future packages which are still in development which you probably don’t need or even want except in certain situations like having a newer-model Apple machine that requires bleeding edge updates. Packages may contain new features, introduce new interfaces, and not be sufficiently tested for inclusion in the ‘proposed’ repository. “Pre-released Updates (karmic-proposed)” is just the testing area for updates, recommended only to those interested in helping to test updates and provide feedback. Check that Ubuntu is scheduled to automatically find availably updates daily and to download all updates in the background to save yourself some time when it comes time to install them.

Before you go, head over to the “Statistics” tab and check it if it isn’t already. This anonymously sends the list of software you have installed and how often you use them to help collect statistics on which apps are the most popular.

When you click close, you will likely be prompted to reload the list of available software. Click reload. If you’re prompted with available updates when it finished reloading, follow the instructions to install them. If not, you can always manually check for and install updates via Update Manager (System ⟶ Administration ⟶ Update Manager). You should always keep your computer up-to-date.

Folder and Printer Sharing

If you want to be able to share files, folders, and printers with Windows machines, you’ll need the samba package. You can set this up graphically by right clicking on any folder and selecting “Properties” and going straight to the “Share” tab. Check off “Share this folder” and you should be prompted to install the Windows networks sharing service. After that’s installed, you’ll need to restart and you can click “Create Share” to be able to view the folder and it’s contents from other machines through the network.

Like any package, you may also install samba via Synaptic Package Manager (System ⟶ Administration ⟶ Synaptic Package Manager) or command-line (Applications ⟶ Accessories ⟶ Terminal).

Click here to install or use the following command:

sudo apt-get install samba

Time Synchronization

Ubuntu can keep your computer’s time accurate by syncing up with atomic clocks through tiers of servers while factoring out communication delays, and adjusting the time in a way that does not upset all the other processes that are running. The protocol for this is called Network Time Protocol (NTP). To set up NTP time synchronization graphically, launch Time & Date, also available through (System ⟶ Administration ⟶ Time & Date). Click the keys to unlock settings. Now, you can select your time zone, and configure it to “Keep synchronized with Internet servers”, at which point it will prompt you to Install NTP support. After that, click “Select Servers” and check off the server closest to you.

Click here to install or use the following command:

sudo apt-get install ntp

Restricted Essentials

DVD Playback

Most commercial DVDs are encrypted with Content Scrambling System (CSS), which attempts to restrict the software that can play a DVD. You’ll need to install libdvdcss if you want to play them. You can do so by first installing the libdvdread4 package via Synaptic Package Manager or Terminal.

Click here to install or use the following command:

sudo apt-get install libdvdread4

Then, within a Terminal window, enter:

sudo /usr/share/doc/libdvdread4/

Restricted Extras

The ubuntu-restricted-extras package includes a bunch of things Ubuntu isn’t legally allowed to ship with, namely unrar for unarchiving .rar files, Microsoft TrueType core fonts, Sun Java Runtime Environment (JRE), restricted codecs, and finally Adobe Flash Player. Like the rest of the packages and applications in this list unless noted otherwise, it’s available in the new Ubuntu Software Center (Applications ⟶ Ubuntu Software Center).

Click here to install or use the following command:

sudo apt-get install ubuntu-restricted-extras

I also recommend you at least give a fair chance to Gnash, an open source flash player on the list of high priority Free software projects. To install, you’ll first have to make sure you don’t have Adobe’s flash player installed via Synaptic or Terminal.


sudo apt-get purge flashplugin-installer nspluginwrapper

Finally, you can install the Gnash plugin via Synaptic of Terminal.

APT Line: ppa:gnash/ppa
Click here to install or use the following command:

sudo apt-get install mozilla-plugin-gnash

Eye Candy


The upcoming version 3.0 of the GNOME desktop environment which i can’t describe concisely other than that it is a new interface for interacting with your desktop. Some people think it looks pretty slick, but i won’t weigh in on the issue. If you’d like to try it, there is a version in the Ubuntu repos, but you’ll probably want something more up to date. You can build it yourself without too much difficulty, but hopefully there will be a PPA available soon.

Click here to install or use the following command:

sudo apt-get install gnome-shell

Advanced Desktop Effects Settings

If you want a Custom option in Visual Effects settings in Appearance (System ⟶ Preferences ⟶ Appearance) for some fancier features to play around with and show off, you’ll need Simple CompizConfig Settings Manager, or if you’re feeling more ambitious, Advanced Desktop Effects Settings.

APT Line: ppa:compiz/ppa
Click here to install or use the following command:

sudo apt-get install simple-ccsm

Replace “simple-ccsm” with “compizconfig-settings-manager” for the Advanced Desktop Effects Settings Manager.

Basic Compositing

Some of you may not need or want such superfluous visual effects; perhaps you lack the hardware or restricted drivers for accelerated graphics necessary for Compiz; maybe you just don’t want to use something that isn’t standards compliant, but still want basic compositing which some applications depend on. In that case, Metacity, the default window manager for GNOME, works great! You can enable it graphically, or with a simple command, but make sure to disable Compiz effects in Appearance.

For GUI lovers, hit Alt+F2 to open the Run Applicatoin dialog and enter gconf-editor to launch the GNOME Configuration Editor. In the left-hand sidebar, navigate to Apps ⟶ metacity ⟶ general and back in the main box check off compositing_manager, and Metacity will immediately start compositing, a much smoother transition than to Compiz. If you’re a CLI guy (relax ladies, i did it for the rhyme), you can run a quick command in Terminal.

Command: gconftool-2 -s ‘/apps/metacity/general/compositing_manager’ –type bool true

Extra Themes

There aren’t a whole lot of themes that come with Ubuntu, so if you crave more, there are several packages containing additional themes. Hopefully many of these packages can be merged in the future and have a more refined selection. They all must be installed via Synaptic or the terminal but only the themes from the Bisigi Project provided by the zgegblob-themes package requires the PPA. You can download individual themes from various websites like GNOME-Look.

APT Line: ppa:bisigi/ppa
Click here to install or use the following command:
sudo apt-get install arc-colors community-themes gdm-themes gnome-backgrounds gnome-colors gnome-themes gnome-themes-extras gnome-themes-more metacity-themes shiki-colors zgegblog-themes

Electric Sheep Screensaver

Fractal frames can look pretty sweet. Electric Sheep does a number of cool things with them. Primarily, it displays them as a screensaver, but on top of that and arguably just as cool, it downloads new popular ones through a distributed computing network so that the “gene pool” of animations, or “sheep” as they’re called, is constantly evolving. You can download a starter pack from and just extract them into ~/.electricsheep

Click here to install or use the following command:

sudo apt-get install electricsheep

Desktop Functionality

Application Launcher

For a beautiful application launcher, complete with plugins and a dock, you can try GNOME + Do.

APT Line: ppa:do-core/ppa
Click here to install or use the following command:

sudo apt-get install gnome-do

Universal Applets

After the death of Screenlets and gDesklets, a new widget framework called Universal Applets is being developed with the goal of producing applets that can be dynamically “plugged” into any application. While GNOME Do is definitely superior at the moment, Universal Applets is a promising concept for the future. It’s only available in a third party repository since it isn’t yet included in the Ubuntu repos and as such isn’t listed in the Software Center. It hasn’t even been packaged for karmic, but the Jaunty packages, though bug-ridden, work for me.

APT line: deb ./
Click here to install or use the following command:

sudo apt-get install universal-applets

Clipboard Manager

There is an annoying bug from 2004 in which copy/paste doesn’t work if the source is closed before the paste. Parcellite is a clipboard manager that works around that problem along with providing some other useful features.

Click here to install or use the following command:

sudo apt-get install parcellite

Audio/Video Creation & Editing

Video Editing

PiTiVi is an intuitive and featureful movie editor that was actually designed with the user interface in mind instead of just slopping on one feature after another. It is able to import and export video files in any format supported by the powerful GStreamer framework.

APT Line: ppa:gstreamer-developers/ppa
Click here to install or use the following command:

sudo apt-get install pitivi

Video Screen Capture

If you want to make screencasts to show off your awesome desktop, Instanbul is a great desktop recording tool which, unlike gtk-recordMyDesktop, uses GStreamer. You can install it through Synaptic or Terminal.

Click here to install or use the following command:

sudo apt-get install istanbul

Audio Recording & Editing

Jokosher is a simple yet powerful non-linear, multi-track audio editor. The interface, which was designed from the ground up, provides an integrated environment to create and record music, podcasts and more.

Click here to install or use the following command:

sudo apt-get install jokosher


If you have a webcam, you need Cheese. It’s a Photobooth-inspired application for taking pictures and videos from a webcam also based on the GStreamer back-end.

Click here to install or use the following command:

sudo apt-get install cheese

Multimedia Playback

Media Center

Moovida, formerly Elisa, is a beautiful media center which is perfect for setting up a Home Theater PC (HTPC) or TVPC like the Neuros Link and it uses the GStreamer multimedia framework to support playing almost any kind of file.

APT Line: ppa:moovida-packagers/ppa
Click here to install or use the following command:

sudo apt-get install moovida

Video Feeds

Miro, previously known as Democracy Player, is an Internet television application developed by a 501(c)(3) non-profit organization called the Participatory Culture Foundation whose mission is to “enable and support independent, non-corporate creativity and political engagement.”

APT Line: deb karmic/
Click here to install or use the following command:

sudo apt-get install miro

Media Player

I don’t feel strongly about this, but for those of you who are unsatisfied by Rythmbox, the default music manager for Ubuntu, you may want to try Banshee. It’s a media player and library for music and videos which has a number of cool features.

APT Line: ppa:banshee-team/ppa
Click here to install or use the following command:

sudo apt-get install banshee

Web Browsing

Google Chrome

Mozilla Firefox 3.5 brings some major improvements like HTML 5 support, but we all hate how bloated it is. If you want something faster and more standards-compliant, WebKit browsers are the way to go. Webkit is the layout engine that Epiphany and Google Chrome use to render pages faster than Gecko which is used by Firefox. Chromium is only available through the a PPA and must be installed through Synaptic or Terminal.

APT Line: ppa:chromium-daily/ppa
Click here to install or use the following command:

sudo apt-get install chromium-browser


If you prefer something that integrates more with GNOME, and is in fact the default web browser for it, try Epiphany. You may also add the Epiphany and WebKit PPAs to keep them up-to-date.

APT Line: ppa:webkit-team/epiphany
APT Line: ppa:webkit-team/ppa
Click here to install or use the following command:

sudo apt-get install epiphany-browser


Flash Cards

Digital flash cards are even more effective because they can accurately use spaced repetition to help you more efficiently retain information. There are actually two great programs i recommend you try and choose for yourself, Mnemosyne and Anki.

Click here to install or use the following command:

sudo apt-get install mnemosyne anki

Brainwave Entrainment

You read that correctly. You can synchronize your brainwaves to that of an external stimulus like sound, light, and even electromagnetic radiation in order to easily induce brain states like sleep for example. Think of it as assisted meditation which is effective at treating conditions like ADD, insomnia, and much more. Gnaural is brainwave entrainment software which generates binaural beats. It is no longer in the repositories and it doesn’t have a PPA, but 32-bit users can download and install the .deb from the website while 64-bit users like myself are forced to compile.

Brain Training

If you like puzzles, logic, and brain teasers, you’ll enjoy keeping your mind in shape with gbrainy.

Click here to install or use the following command:

sudo apt-get install gbrainy



What good are games when you’re stuck with the same versions for 6 months? PlayDeb is a repository of games which provides you with the latest and greatest that are either not at their newest version in the Ubuntu repos, or not included at all! Installing games is extremely convenient by searching through the website and installing games with just a click. You can add it to your sources automatically by installing the playdeb package, or manually.

APT Line: deb karmic-getdeb games

wget -O- | sudo apt-key add -

Yo Frankie!

This is a beautiful and important Free game— that is, Free software and Free content— which was created to show off what can be produced using Free software. It was made using Blender, mentioned above, as part of the Blender Institute’s first Open Game Project, and based off of the film, Big Buck Bunny, which was the foundation’s second Open Movie Project. Sadly, it isn’t included in the Ubuntu repos, but you can get it with PlayDeb.

Click here to install or use the following command:

sudo apt-get install yofrankie


For those of you who prefer fast-paced first-person shooters, Nexuiz is a very decent Free game every Linux gamer should try at least once. GameStop even held a Nexuiz “PC gaming challenge” in which interactive kiosks were set up in 10 different stores in 8 US cities and users were given 2 minutes to earn the high score for a $100 gift card by doing the most damage possible to their AI opponents.

Click here to install or use the following command:

sudo apt-get install nexuiz

Donating CPU Power

Distributed Computing

You can volunteer to participate in grid computing to donate your computer’s spare CPU power to charitable projects like protein folding. Berkeley Open Infrastructure for Network Computing (BOINC) is a great way to use your computer to give.

Click here to install or use the following command:

sudo apt-get install boinc-manager

Images and Publishing

Photo Management

Although Ubuntu does come with F-Spot, it does leave many users unsatisfied. If you find yourself among them, you may want to try a young competitor named Solang, which gained popularity during the mono wars (hopefully mostly over?) as being a mono-free alternative.

Click here to install or use the following command:

sudo apt-get install solang

Vector Graphics

Inkscape is a vector graphics editor, with capabilities similar to Illustrator, CorelDraw, or Xara X. It’s an excellent tool for publishing materials in the W3C standard Scalable Vector Graphics (SVG) file format.

APT Line: ppa:inkscape.testers/ppa
Click here to install or use the following command:

sudo apt-get install inkscape

3D Graphics

Not exclusive to still imagery, Blender is an amazing 3D imagery creation suite that has already been used to create films as part of the Open Movie Project.

Click here to install or use the following command:

sudo apt-get install blender

Desktop Publishing

Scribus is a desktop publishing (DTP) application designed for flexible layout and typesetting and the ability to prepare files for professional quality image setting equipment like writing small newspapers, brochures, newsletters, posters and books.

APT Line: ppa:scribus/ppa
Click here to install or use the following command:

sudo apt-get install scribus


Secured P2P

Gnunet framework for decentralized, secure, peer-to-peer networking for anonymous, censorship-resistant file-sharing. You may have heard of Freenet, but you probably haven’t seen how they compare.

APT Line: ppa:teamgnunet/ppa
Click here to install or use the following command:

sudo apt-get install gnunet-gtk

Direct Connect

A great way to share files for students in college networks is using direct connect; sadly, there is no DC client designed for GNOME, nor is there an available port of Shakespeer from Mac, so it seems like the best option is DC++

Click here to install or use the following command:

sudo apt-get install linuxdcpp


Although it isn’t free, Usenet downloads are crazy-fast and files show up there first. Possibly even more noteworthy, however, is that for whatever reason it remains unregulated by pirate hunters. Read this guide for more info, but install LottaNZB for your client instead— they’re working to replace HellaNZB with SABnzbd for their back-end.

APT Line: ppa:lottanzb/ppa
Click here to install or use the following command:

sudo apt-get install lottanzb
Although Miro can already handle torrent files, you probably want a dedicated BitTorrent client, and although Transmission can do the job, you might want something a little more comprehensive. I’m sure you’ll find that Deluge is a feature complete yet lightweight application.
APT Line: ppa:deluge-team/ppa
Click here to install or use the following command:
sudo apt-get install deluge

Time Managment

Alarm Clock

If you keep your computer on at all times and want to toss out your boring alarm clock, or even if not, Alarm Clock provides a lot of nifty scheduling and alert options.

Click here to install or use the following command:

sudo apt-get install alarm-clock

Time Tracking

The Hamster Time Tracker applet helps you track and analyze how much time you spend on different tasks and activities with a graphical overview to make you feel bad for all that time you waste. It can only be installed through Synaptic or Terminal.

Click here to install or use the following command:

sudo apt-get install hamster-applet


Empathy Instant Messenger

Horray! Empathy is now included with Ubuntu, but if you want the latest version with additional features like geolocation and audio/video chat for MSN, you’ll need to add the Telepathy PPA to your software sources.

APT Line: ppa:telepathy/ppa


Gwibber is a cute little microblogging client for those of you who frequently use sites like Twitter,, Jaiku, Facebook, Digg, and more.

APT Line: ppa:gwibber-team/ppa
Click here to install or use the following command:

sudo apt-get install gwibber

Security & Privacy

On-The-Fly Encryption

Many people use TrueCrypt believing that it’s FOSS, but although the source code is available, it’s development is kept secret and it isn’t considered Free Software by the FSF nor Open Source by the OSI. ScramDisk for Linux (SD4L) is a great OTFE alternative that also supports TrueCrypt containers. Unfortunately, it is not yet included in the default repos, and there isn’t a PPA either, but you can download a .deb to install from their website.

VPN Access

If you’d like to make sure all of your internet traffic is encrypted and anonymous, you can pass it through a proxy by using a Virtual Private Network service like IPREDator. We can’t kill the music and movie industries if they can make money just by suing all of us!

Click here to install or use the following command:

sudo apt-get install network-manager-pptp

Onion Routing

If you don’t wan’t to pay $5 a month for a VPN like IPREDator but still want to be able to use the web anonymously, you can try The Onion Router, more commonly referred to as TOR, but it is significantly slower and requires additional setup. Although it was in the Ubuntu repos, the version in there was dangerously out-of-date it’s just been removed, so you need to use their repository.

APT Line: deb karmic main
Click here to install or use the following command:

sudo apt-get install tor tor-geoipdb


If you feel the need to have a firewall, Firewall configuration is a graphical front-end for Uncomplicated firewall (ufw).

Click here to install or use the following command:

sudo apt-get install gufw


You generally don’t need antivirus with Linux, but if you’d like to play it safe, you can install the ClamTK Virus Scanner, a graphical front-end to ClamAV.

Click here to install or use the following command:

sudo apt-get install clamtk

System Utilities

LiveUSB Creator

Optical storage disks like CD’s are inconvenient and get scratched up, so why put your installer on a USB instead? UNetbootin allows you to do just that, using any Linux or BSD distribution.

Click here to install or use the following command:

sudo apt-get install unetbootin


I don’t have any strong feelings as to which backup utility you should use, but i have learned the hard way that you should always have a backup. Back In Time should do everything you need.

Click here to install or use the following command:

sudo apt-get install backintime-gnome

Partition Editor

You can partition you other storage drives, your external hard drive, you USB drive, your iPod, and basically any other writable storage drive you can plug into your computer using the GNOME Partition Editor. It does the trick on Ubuntu installation disks, and it can sure do the trick elsewhere.

Click here to install or use the following command:

sudo apt-get install gparted

Virtual Machine

If you want to be a good user and get testing on the next version of Ubuntu, that’s 10.04 LTS, the Lucid Lynx, but you want to do it safely, get VirtualBox. There’s version that is fully open source (vboxgtk), but you’ll likely want the proprietary features too. It’s installable via Synaptic or Terminal.

APT Line: deb karmic non-free
Click here to install or use the following command:

sudo apt-get install virtualbox-3.0

64-bit Specific

Flash Player

The 32-bit flash player runs terribly on 64-bit systems, and if you don’t want to use Gnash, Adobe has released the only 64-bit version of Flash Player 10 for Linux! It currently isn’t in the repositories because it’s still in alpha, but it’s so much more stable than even the final 32-bit version. To install it, download the .tar.gz file at the bottom of this page:

Next, extract the file to your home folder; then just enter this into a terminal window:

sudo cp /usr/lib/mozilla/plugins/

Windows Media Audio 9

I’ve looked and looked, and without the Fluendo GStreamer plugin there is no way for 64-bit Ubuntu to play WMA 9 files, and video files that use it will have no sound. You can purchase a copy from the Canonical Store, or download it illegally from The Pirate Bay:

Explore, Customize, Personalize!

Now it’s time to play around with all the new apps you have and make your desktop, well, yours. You can try experimenting with a cool panel-less desktop; you can experiment with all your new apps; you can try different themes and modify them in Appearance; you can set your preferred applications and explore all your system preferences. My desktop background comes is by David Revoy of Durian, now called Sintel, the Blender Foundation’s latest Open Movie Project.

Don’t for get to show off your shiny new Ubuntu installation to your friends, spread Ubuntu, and donate to your favorite projects!

Tùy biến giao diện Ubuntu

1. Tùy biến giao diện Metacity (GTK)

Sau khi cài, môi trường làm việc mặc định của Ubuntu là GNOME với chế độ quản lý cửa sổ Metacity (Metacity Desktop Management), chế độ này chỉ cho phép bạn thực hiện các thao tác như mở, đóng hay phóng to/thu nhỏ cửa sổ tương tự trong Windows XP.

Để đảm bảo tốc độ làm việc, giao diện mặc định ban đầu của Ubuntu khá đơn điệu. Nhưng bạn hoàn toàn có thể tùy biến dễ dàng các thành phần sau:

1.1. Các thanh panel

Giao diện GNOME có 2 thanh panel trên và dưới, trên mỗi thanh có các applet (ứng dụng nhỏ) với nhiều chức năng khác nhau. Muốn biết các applet này có chức năng gì bạn chỉ việc nhấn chuột phải vào panel rồi chọn Add to panel, tại bảng hiện ra bạn sẽ thấy đầy đủ tên các applet và mô tả chi tiết chức năng của chúng. Để thêm một applet vào panel, bạn chọn applet đó rồi bấm Add. Nếu muốn bỏ một applet đi, bạn nhấn chuột phải vào applet đó trên panel rồi chọn Remove from Panel. Nếu thấy 2 thanh panel là thừa và làm giảm không gian làm việc, bạn có thể bỏ bớt bằng cách nhấn chuột phải vào panel tương ứng và chọn Delete panel, sau đó thêm hay bớt các applet cần thiết để có một thanh panel phù hợp. Bên cạnh đó bạn cũng có thể thay đổi kích thước hay màu nền thanh panel bằng cách nhấn chuột phải vào thanh panel và chọn Properties. Thẻ General cho phép chọn kích thước của thanh panel tính theo pixel và chế độ hiển thị. Thẻ Background cho phép chọn nền panel theo theme của hệ thống, chọn chế độ một màu cho panel hay chọn một ảnh nhất định làm nền cho panel.

1.2. Các thành phần giao diện khác

Tất cả các thành phần này đều nằm trong một trình quản lí duy nhất là Appearance (truy xuất bằng cách vào menu System → Preferences → Appearance, hay truy xuất nhanh hơn bằng cách nhấn chuột phải vào desktop và chọn Change desktop background).

Tab Theme: cho phép bạn chọn lựa các theme đã cài đặt, để tùy chỉnh sâu hơn bạn chọn Customize …, tại cửa sổ hiện ra bạn có thể chọn từng yếu tố một như: nền các ứng dụng, màu sắc của các ứng dụng nếu theme đó hỗ trợ, khung cửa sổ các ứng dụng, hệ thống icon sử dụng, và cả hình dạng trỏ chuột (pointer).

Tab Background: cho phép bạn chọn lựa ảnh nền desktop, nếu muốn thêm ảnh bạn nhấn Add để thêm và muốn bỏ ảnh, bạn chọn ảnh rồi nhấn Remove.

Tab Fonts: cho phép bạn thay đổi font chữ hệ thống cũng như kích cỡ.

Tab Interface: cho phép chọn lựa các tùy chọn khác nhau về menu và Toolbar.

Tab Visual Effect: cho phép chọn lựa 3 chế độ cơ bản của giao diện, nếu card màn hình của bạn hỗ trợ tăng tốc 3D thì mặc định chế độ hiển thị sẽ là Normal (chế độ cho hiệu ứng khá đẹp mà không ảnh hưởng nhiều tới tài nguyên hệ thống) nếu máy của bạn không hỗ trợ 3D thì mặc định là None. Bạn có thể bật sang Extra nếu máy bạn có đủ khả năng.

Để cài một theme mới cho hệ thống, trước hết bạn cần có theme, rất nhiều theme đẹp được tập hợp tại site (nếu dùng giao diện GNOME) hoặc (nếu dùng KDE). Sau khi tải về các gói theme này (thường là định dạng nén .tar.gz hay .tar.bz2), bạn chỉ cần mở cửa sổ Appearance, chuyển sang Tab Theme rồi kéo thả gói theme vào và chọn Apply new theme ở cửa sổ hiện ra.

2. Các thành phần giao diện khác

Nếu hệ thống của bạn đủ mạnh và có hỗ trợ tăng tốc 3D, bạn có thể chạy một trình quản lí cửa sổ được tích hợp sẵn trong Ubuntu là Compiz, tuy nhiên nó chỉ được tích hợp ở dạng nhân mà thôi. Để quản lí Compiz bạn phải cài đặt CompizConfig Setting Manager, để có thêm các khung cửa sổ đẹp và trong suốt như Vista thì bạn cần cài thêm Emerald Theme Manager. Để cài đặt 2 trình quản lí này bạn chỉ cần mở Syanaptic (System -> Administration -> Synaptic Package Manager) rồi tìm các gói sau để cài: compizconfig-settings-manager emerald

2.1. Để kích hoạt Compiz: bạn nhấn chuột phải vào desktop, chọn Change desktop background, chuyển sang thẻ Visual Effects chọn chế độ là Normal để có một số hiệu ứng cơ bản vừa đảm bảo đẹp và không giảm tốc độ hệ thống, hay chọn Extra có những hiệu ứng đẹp nhất nhưng sẽ tiêu tốn nhiều tài nguyên hệ thống hơn. Tùy biến sâu hơn Compiz, bạn vào Menu System → Preferences → Compizconfig Setting Manager, trong cửa sổ hiện ra sẽ có rất nhiều các loại hiệu ứng khác nhau chia theo các chủ đề khác nhau. Về cơ bản gồm có các mục sau:

General Options: cho phép chọn lựa những thông số cơ bản như số lượng desktop ảo (workspace), font chữ, các lệnh cơ bản nếu bạn muốn thao tác bằng dòng lệnh với Compiz.

Accessibility: bao gồm các mục về độ sáng màn hình, phóng to thu nhỏ cửa sổ, chế độ tương phản hay chế độ lọc đơn sắc.

Desktop: cho phép chọn chế độ nhiều desktop, khi bạn chuyển qua lại giữa các desktop sẽ có hiệu ứng như xoay khối rubic (chế độ Desktop Cube), hay có thể chọn kiểu các desktop nối liền nhau như 1 bức tường (chế độ Desktop Wall).

Effect: là nơi chứa hầu hết mọi kiểu hiệu ứng của Compiz, bạn có thể tùy chọn các hiệu ứng như dùng chuột làm bút vẽ lửa lên màn hình, khi tắt hoặc mở cửa sổ sẽ bốc cháy, vỡ ra thành từng mảnh hay thậm chi sáng chói lên khi bạn đóng cửa sổ đó lại, hay hiệu ứng làm cho các cửa sổ trở nên “mềm dẻo”, …. Có rất nhiều điều thú vị ở mục này để bạn khám phá.

Extra: có những tùy chọn hiệu ứng đẹp mắt bổ sung như cho phép “xem trước” khi bạn rê chuột lên cửa sổ trên thanh tác vụ (giống như thumbnail view trong Vista). Hoặc bạn có thể chụp ảnh từng phần màn hình bằng cách giữ phím Super (phím Windows) rồi dùng chuột kéo để chọn vùng thích hợp.

Utility: cho bạn nhiều công cụ tùy biến như phóng to hay nhu nhỏ các chi tiết của ứng dụng.

Windows Management: chứa nhiều hiệu ứng rất đẹp như Shift Switcher cho phép chuyển đổi giữa các cửa sổ làm việc bằng hiệu ứng Flip 3D; Ring Switcher để chuyển đổi giữa các cửa sổ theo kiểu hình vòng tròn, các cửa sổ sẽ lần lượt quay trên một trục ảo giữa màn hìn, hoặc Scale – khi bạn di chuột đến góc màn hình, tất cả các cửa sổ sẽ được xếp gọn gàng lên màn hình chờ bạn lựa chọn…

Uncategorized: chứa những hiệu ứng mà bạn có thể cài thêm vào Compiz hay những hiệu ứng bổ sung không có trong các thẻ phân loại trên.

Chú ý khi chọn các hiệu ứng này bạn nên bấm chọn vào hiệu ứng xem phần “key binding” để biết phím tắt kích hoạt.

2.2. Sử dụng Emerald Theme Manager: để khởi động, bạn vào menu System → Preferences → Emerald Theme Manager, tại cửa sổ hiện ra bạn chọn mục Import để đưa theme mình yêu thích vào, nhấn chọn theme trong cửa sổ Emerald Theme Manager rồi nhấn close. Tiếp theo nhấn Alt+F2 rồi gõ vào lệnh sau: emerald –replace; ngay lập tức viền cửa sổ các ứng dụng sẽ chuyển sang đúng theme mà bạn thích. Chú ý có rất nhiều theme đẹp cho bạn chọn lựa trên site, các theme này khi tải về đều có dạng *.emerald.

Để emeral theme chạy mặc định mỗi khi khởi động, bạn làm như sau: vào menu System → Preferences → Session, tại cửa sổ hiện ra bạn chọn Add để thêm một lệnh chạy lúc khởi động, trong cửa sổ hộp thoại Add bạn gõ tên lệnh Emerald theme (hoặc tên nào tùy ý bạn) và phần command bạn gõ vào: emerald –replace. Từ nay Emerald theme sẽ khởi động mỗi khi bạn khởi động Ubuntu.

3. Làm đẹp desktop với Screenlet và Google sidebar

Bạn có thể tìm tải gói cài đặt Google Sidebar tại site, việc sử dụng đơn giản giống như Google Sidebar trên Windows. Bạn vào menu Applications → Accessories → Google Sidebar, nhấn vào dấu (+) trên thanh sidebar để thêm bớt các Gadget tùy thích.

Ngoài ra bạn có thể cài một phần mềm khác là Screenlets bằng lệnh: sudo apt-get install screenlets, để chạy ứng dụng này bạn vào menu System → Acessories → Screenlets. Sau đó chọn Gadget mà bạn thích rồi nhấn chọn gadget đó, để đưa gadget đến vị trí mong muốn bạn chỉ cần nhấn chuột lên gadget và kéo.

Từ khóa: hệ điều hành, Ubuntu

ID: O1003_0

Developing applications using the Eclipse C/C++ Development Toolkit

Creating a C++ application using the Standard Template Library and the CDT

Michael Galpin, Developer, Ludi Labs
Michael Galpin holds a degree in mathematics from the California Institute of Technology. He has been a Java developer since the late 1990s and is a software engineer for Vitria Technology, in Sunnyvale, CA.

Summary: When most people think “Eclipse,” they think “Java™ IDE.” Eclipse is much more. With the proper plug-ins, one can use Eclipse to work with PHP, Ruby, and Groovy, C, and C++. In this article, you get started with the the Eclipse C/C++ Development Toolkit (CDT). We build a simple application in C++ using the CDT and the C++ Standard Template Library (STL) to streamline the process and take advantage of some of the powerful feature

This article, which is a follow-up to “C/C++ development with the Eclipse Platform,” is intended for C++ developers who want to learn C++ development using the Eclipse CDT. A simple C++ application is developed in the article. The application makes use of the C++ STL. Readers should be familiar with the STL, as well as with basic object-oriented programming principles such as inheritance and polymorphism. A familiarity with Eclipse will be helpful, but is not required.

Before we start

You need to install the following:

We’re using the CDT, which is a plug-in to Eclipse, so of course you need Eclipse. The article uses Eclipse V3.2.
Java Runtime Environment
We’re building a C++ application, but we’re using Eclipse. Eclipse is a Java application itself, so it needs a Java Runtime Environment (JRE). The article uses Eclipse V3.2, which requires a JRE of V1.4 or higher. If you want to also use Eclipse for Java development, you’ll need a Java Development Kit (JDK).
Eclipse C/C++ Development Toolkit (CDT)
This article is about the CDT, so you’ll need it, of course. Read a 2003 developerWorks article titled “C/C++ Development with the Eclipse Platform.” for instructions on installing the CDT on early versions of Eclipse.
If you’re using Microsoft Windows®, you will find Cygwin — which provides a Linux®-like environment on Windows — helpful.
GNU C/C++ Development Tools
The CDT uses the standard GNU C/C++ tools for compiling your code, building your project, and debugging the applications. These tools are GNU Compiler Collection (GCC) for C++ (g++), make, and the GNU Project Debugger (GDB). If you’re a programmer using Linux or Mac OS X, there’s a pretty good chance these tools are installed on your machine. The article contains instructions for setting up these tools for Windows.

Back to top

The Eclipse CDT

The Eclipse CDT is an Eclipse plug-in that transforms Eclipse into a powerful C/C++ IDE. It was designed to bring many of the great features Eclipse enjoyed by Java developers to C/C++ developers, such as project management, integrated debugging, class wizards, automated builds, syntax coloring, and code completion. When Eclipse is used as a Java IDE, it leverages and integrates with the JDK. Similarly, the CDT leverages and integrates with standard C/C++ tools, such as g++, make, and GDB. This has lead to it becoming very popular on Linux, where those tools are readily available and used for most C++ development. The CDT can be set up on Windows to use the same tools. There is also an ongoing effort to get the CDT to work with Microsoft’s C++ tools to make it even more attractive to Windows C++ developers.

Back to top

Installing the CDT

We start by assuming you installed Eclipse and can run it. If not, consult Eclipse’s Web site for getting up and running. Let’s install the CDT. The CDT is an Eclipse plug-in, so it uses Eclipse’s Software Updates feature. Select Help > Software Updates > Find and Install.
Figure 1. Eclipse Software Updates
Eclipse Software Updates

Next, you’ll want to choose Search for new features to install.
Figure 2. Search for new features
Search for new features

If you’re using a newer version of Eclipse, the Callisto or Europa discovery sites should be included. (Editor’s note: Since this was written in April 2007, the Europa release was still in the planning stages. However, installing Europa is expected to be similar to Callisto.) Simply select it and click Finish.
Figure 3. Callisto Discovery Site
Callisto Discovery Site

Eclipse might ask you to choose from a list of mirror sites for the Callisto Discovery Site. Pick whatever one seems closest to you. You should see a list of plug-ins from the Callisto Discovery Site. You’ll want to select C and C++ Development and click Next.
Figure 4. Available Callisto plug-ins
Available Callisto plugins

You’ll be asked to accept the license for the CDT. Once you’ve done that, you can click Next. You’ll see a summary of what’s going to be downloaded and installed. Simply click Finish.
Figure 5. Download and installation summary
Download and installation summary

Eclipse’s Update Manager will then download the CDT plug-in from the mirror site you selected earlier. The CDT is about 11 MB total, so this could take a few minutes, depending on your Internet connection speed. Once everything is downloaded, you’ll be asked to confirm that you want to install the new features. Click Install All.
Figure 6. Confirm installation
Confirm installation

After you finish installing CDT, you’ll be asked to restart Eclipse. Go ahead and do that. Once Eclipse restarts, the CDT will be ready to go.

Back to top

Windows configuration

If you’re running Eclipse on Linux or Mac OS X, you’re ready to start using the CDT to develop a C++ application. If you’re on Windows, there might be a few more steps. As mentioned, CDT relies on the standard GNU C++ development tools: g++, make, and GDB. These are usually included on Linux or Mac OS X. They’re usually not included with Windows. But don’t worry. These tools can be easily installed on Windows. Perhaps the easiest way is to install Cygwin. Cygwin provides Linux-like environment on Windows (see Resources). When installing Cygwin, you’ll be asked to pick the packages you want to install. Make sure to go into the development section and select gcc: g++, make, and GDB. This will cause their prerequisites to be installed, too.

Once you’re done installing Cygwin, you’ll need to add g++, make, and GDB to your path. The easiest way to do this is to add Cygwin’s bin directory to your path, since that’s where g++, make, and GDB can be found. Once that’s done, restart Eclipse.

Back to top

Playing the lottery

At this point, we should be ready to start developing our application with CDT. Let’s pause to figure out what we want to develop. The sample application is a simple command-line program for generating lottery numbers. Many states have lotteries, and the rules vary quite a bit. We’ll allow the user to pick which state lottery he wants to generate numbers for. This will provide us a good way to use C++’s support for polymorphic behavior.

Back to top

Creating the project

Eclipse uses the concepts of perspectives to allow for various plug-ins to customize their commands and views. Eclipse starts off by default in the Java perspective. CDT includes its own perspective, so we’ll want to switch to that. To do that, select Window > Open Perspective > Other. You should see a list of perspectives available to you. Select the C/C++ perspective and click OK.
Figure 7. Select C/C++ perspective
Select C/C++ perspective

Eclipse should now look something like Figure 8.
Figure 8. The C/C++ perspective
The C/C++ perspective

Eclipse organizes your code into projects, so we’ll want to create a new project. Select File > New > Managed Make C++ Project.
Figure 9. New C++ project
New C++ project

You might have noticed there were several different options for the project. We wanted a C++ project. We selected a “Managed Make,” since that will allow Eclipse to create the make file for us. You could select a “Standard Make” flavor and write your own make file. We should now be in the New Project wizard, where we’ll name our project Lottery and click Finish.

This will create an empty project, which you should see in the C/C++ Projects window. Right-click on the project and select New > Source Folder. This will bring up the “New Source Folder” wizard, where we’ll name our folder src and click Finish.

Back to top

Basic lottery

We’re ready to start creating some code. We’ll start by creating the executable of our application. Right-click on the source folder we just created and selected New > Source File, as shown in Figure 10.

Let’s create an empty main method for now. This is just a placeholder; we’ll add more to this after we’ve created the rest of our project.

int main()
     return 0;

Save your project, and Eclipse will make it for you automatically. You should see some output in the console indicating that it compiled successfully.

We’re ready to create our first class. Right-click on the source folder we just created and select New > Class.
Figure 10. New class
New class

This should bring up the New Class wizard. We’ll give our class a namespace lotto, and we’ll call our class Lottery.
Figure 11. Lottery class
Lottery class

Eclipse will now create stubs for your class. CDT does a lot of nice things for you. It generates the appropriate compiler directives in the header file. It encourages best practices by generating separate interface (Lottery.h) and implementation (Lottery.cpp) files. It encourages another best practice by making your class’ destructor virtual. We can enter the source code for these classes as seen in Listings 1 and 2.
Listing 1. Lottery.h

#ifndef LOTTERY_H_
#define LOTTERY_H_
#include <string>
#include <sstream>
#include <cstdlib>
#include <time.h>
using namespace std;
namespace lotto

class Lottery
          int ticketSize, maxNum;
          int* generateNumbers();
     virtual ~Lottery();
     virtual string printTicket();


#endif /*LOTTERY_H_*/

Listing 2 shows the implementation file for the Lottery class.
Listing 2. Lottery.cpp

#include "Lottery.h"

namespace lotto

Lottery::Lottery(int size, int num)
     this->ticketSize = size;
     this->maxNum = num;


int* Lottery::generateNumbers()
     int* allNums = new int[this->maxNum +1];
     for (int i=0; i <= this->maxNum ; i++)
          allNums[i] = 0;
     int* nums = new int[this->ticketSize];
     for (int i=0; i < this->ticketSize; i++)
          int val = 1 + rand() % (this->maxNum);
          if (allNums[val])
               nums[i] = val;
               allNums[val] =1;
     return nums;

string Lottery::printTicket()
     ostringstream str;
     int* nums = this->generateNumbers();
     for (int i=0;i< this->ticketSize; i++)
          str << *nums << ' ';
     return str.str();


What’s this code doing? Well, our Lottery class has two attributes. The ticketSize attribute is the number of numbers on the lottery ticket. The maxNum is the maximum number on the ticket. Later, we’ll use the Florida state lottery as an example. There, you pick six numbers from 1 to 53, so ticketSize would be 6 and maxNum would be 53.

The generateNumbers method generates an array of numbers corresponding to the numbers on a lottery ticket. It uses the STL function rand() to generate numbers randomly. The allNums array is used to keep track of what numbers have been generated so far, so we can make sure we don’t get a duplicate number on our ticket. Finally, the printTicket() creates a string representation of our ticket.

When you save the files, Eclipse builds your project automatically. Again, if you save the project, it should be compiled and you should see compilation messages in the console, as shown in Listing 3.
Listing 3. Compiler output in console

**** Build of configuration Debug for project Lottery ****

make -k all 
Building file: ../src/Main.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/Main.d" -MT"src/Main.d" 
-o"src/Main.o" "../src/Main.cpp"
Finished building: ../src/Main.cpp
Building target: Lottery
Invoking: MacOS X C++ Linker
g++  -o "Lottery"  ./src/Lottery.o ./src/Main.o   
Finished building target: Lottery
Build complete for project Lottery

Back to top

MegaLottery class

You might have noticed that we made the printTicket() method virtual when it was declared in the header file. That will allow us to subclass Lottery and override this method. We wanted to do that because some states have a lottery with a “mega” number. This is a separately drawn number that any ticket must match in addition to the other numbers drawn. Let’s create a MegaLottery class for these states that will subclass Lottery.

Once again, right-click on our source folder and select New > Class, as we did earlier. This time in the New Class wizard, we’ll declare our new class in the same namespace, but call it MegaLottery.
Figure 12. MegaLottery class
MegaLottery class

To subclass Lottery, select the Add button next to the Base Classes section. This will bring up the Choose Base Class dialog. You can start typing the name of the class, and Eclipse will narrow the list of base class candidates quickly. You’ll want to select Lottery and click OK.
Figure 13. Choose base classes
Choose base classes

We can enter the code for MegaLottery, as shown in Listings 4 and 5.
Listing 4. MegaLottery.h


#include "Lottery.h"

using std::string;

namespace lotto

class MegaLottery : public lotto::Lottery
          int maxMegaNum;
     virtual ~MegaLottery();
     string printTicket();


#endif /*MEGALOTTERY_H_*/

Listing 5 shows the implementation file for the MegaLottery class.
Listing 5. MegaLottery.cpp

#include "MegaLottery.h"

using namespace std;

namespace lotto

MegaLottery::MegaLottery(int ticketSize, int maxNum, int maxMegaNum) : 
     this->maxMegaNum = maxMegaNum;


string MegaLottery::printTicket()
     ostringstream tick;
     tick << Lottery::printTicket() << " Mega: ";
     int mega = 1 + rand() % this->maxMegaNum;
     tick << mega;
     return tick.str();


The main difference between Lottery and MegaLottery is that MegaLottery has an extra attribute maxMegaNum. This is the max value that the mega number can take. It overrides the printTicket() method. It uses the base class to generate the first part of the ticket, then it generates the mega number and appends it to the string representation of the ticket.

We just need a way to create the various lotteries. We’ll use a class Factory Pattern to do this. We’ll do this by adding a LotteryFactory class. We want all Lotteries to come from the same factory, so we’ll make LotteryFactory a singleton. The code for it is in Listings 6 and 7.
Listing 6. #ifndef LOTTERYFACTORY_H_


#include "Lottery.h"

namespace lotto

class LotteryFactory
    enum State { California, Florida };
    static LotteryFactory* getInstance();
    Lottery* getLottery(State);



Listing 7 shows the implementation file for the LotteryFactory class.
Listing 7. LotteryFactory.cpp

#include "LotteryFactory.h"
#include "MegaLottery.h"

namespace lotto


Lottery* LotteryFactory::getLottery(State s)
    if (s == LotteryFactory::California)
        Lottery* lotto = new MegaLottery(5,47,27);
        return lotto;
        Lottery* lotto = new Lottery(6,53);
        return lotto;

LotteryFactory* LotteryFactory::getInstance()
    static LotteryFactory instance;
    return &instance;


The LotteryFactory has an enum of the different types of lotteries. We’ve only put in Florida and California in the example, but it shouldn’t be hard to add as many as you want. The LotteryFactory‘s constructor seeds the rand() function used by our lottery classes. We just need to implement our executable’s main method.
Listing 8. Main.cpp

#include <iostream>
#include "LotteryFactory.h"

using namespace lotto;
int main()
    LotteryFactory* factory = LotteryFactory::getInstance();
    cout << "What lottery do you want to play?" << endl;
    cout << "(1) California, (2) Florida" << endl;
    int cmd;
    scanf("%d", &cmd);
    Lottery* lotto = 0;
    switch (cmd)
        case 1 :
        lotto = factory->getLottery(LotteryFactory::California);
        case 2 :
        lotto = factory->getLottery(LotteryFactory::Florida);
        default :
        cout << "Sorry didn't understand that" << endl;
    cout << "Ticket: " << lotto->printTicket() << endl;
    delete lotto;
    return 0;

Back to top

Running the program

We’re ready to run our program. Select Run > Run.
Figure 14. Choose base classes
Choose base classes

Select C/C++ Local Application and click the New button.
Figure 15. New C/C++ run profile
New C/C++ run profile

This will bring up the Create run configuration interface for the Lottery project. You’ll need to select its executable by clicking the Search Project button.
Figure 16. Search project for executable
Search project for exectuable

You can select the binary that Eclipse created for you and click OK.
Figure 17. Search project for executable
Search project for exectuable

Just click Run, and the program should run in your console. The code below shows some sample output.

What lottery do you want to play?
(1) California, (2) Florida
Ticket: 12 28 24 15 35 22

Back to top

Debugging the program

Our program should run fine, but let’s take a look at debugging the application. First, create a breakpoint in our code. Pick a line and right-click next to it and select Toggle Breakpoint.
Figure 18. Create breakpoint
Create breakpoint

We need to create a debug configuration, much like we created a run configuration. Select Run > Debug.
Figure 19. Create debug configuration
Create debug configuration

This should bring up the Debug configuration. This is based on the Run configuration, and you shouldn’t need to change anything. Just click Debug.
Figure 20. Debug configuration
Debug configuration

Once the debugger starts, it will prompt you to switch to the Debugger perspective. Do so. Notice that in the configuration we set things to break automatically at the startup of our main method. Thus, the debugger should break immediately and you should see a screen something like Figure 21.
Figure 21. The debugger
The debugger

Back to top


We’ve built and debugged our lottery application. You can easily add more lottery schemes to it. Some of these could involve additional subclasses. CDT makes it easier than ever to create these classes and class hierarchies, and to run and debug the application to test it.


Get products and technologies

  • Learn about MinGW, the GNU C/C++ tools for Windows included with Cygwin.
  • Download Cygwin a Linux-like environment for Windows. It consists of two parts: A DLL that acts as a Linux API emulation layer providing substantial Linux API functionality and a collection of tools that provide a Linux look and feel.
  • The Eclipse C/C++ Development Toolkit (CDT) download information contains the latest information about the available versions of CDT.
  • Check out the latest Eclipse technology downloads at IBM alphaWorks.
  • Download IBM product evaluation versions, and get your hands on application development tools and middleware products from DB2®, Lotus®, Rational®, Tivoli®, and WebSphere®.
  • Innovate your next open source development project with IBM trial software, available for download or on DVD.


  • Doug Schaefer is the CDT’s lead developer. Check out Doug on the Eclipse CDT for the latest news on the CDT.
  • The Eclipse Platform newsgroups should be your first stop to discuss questions regarding Eclipse. (Selecting this will launch your default Usenet news reader application and open eclipse.platform.)
  • The Eclipse newsgroups has many resources for people interested in using and extending Eclipse.
  • Participate in developerWorks blogs and get involved in the developerWorks community.

About the author

Michael Galpin holds a degree in mathematics from the California Institute of Technology. He has been a Java developer since the late 1990s and is a software engineer for Vitria Technology, in Sunnyvale, CA.


Manipulating files in Linux

How to use the Linux command line as a file manager. Learn how to copy, move, and delete files under Linux with the cp, mv, and rm commands.

This tuXfile teaches you how to manipulate files in Linux. If you’d like to learn how to manipulate directories, take a look at the Manipulating directories in Linux tuXfile.

Author: Nana Långstedt < nana.langstedt at >
tuXfile created: 20 December 2001
Last modified: 22 September 2005

< Copying >

To copy files, you use the cp command. The following will copy file to file2. Note that if file2 doesn’t exist, it’ll be created, but if it exists, it’ll be overwritten:
$ cp file file2

There aren’t any undo commands in the Linux CLI, so accidentally overwriting an important file would probably make you pull your head off. The risk of doing so is smaller if you use the -i option (“interactive”) with cp. The following does the same as the above, but if file2 exists, you’ll be prompted before overwriting:

$ cp -i file file2
cp: overwrite `file2'? n

So it’s a good idea to use the -i option whenever you’re dealing with important files you don’t want to lose!

If you want to copy file into directory dir1:
$ cp file dir1

The following would do the same as the above, copy file into dir1, but under a different name:
$ cp file dir1/file2

You can also copy multiple files into one directory with a single command:
$ cp file1 file2 file3 dir1

Note that if the last argument isn’t a directory name, you’ll get an error message complaining about it.

< Moving and renaming >

The mv command can be used for moving or renaming files. To rename a file, you can use it like this:
$ mv file file2

If file2 doesn’t exist, it’ll be created, but if it exists, it’ll be overwritten. If you want to be prompted before overwriting files, you can use the -i option the same way as with cp:

$ mv -i file file2
mv: overwrite `file2'? y

To move the file into another directory:
$ mv file dir1

If you want to rename the file to file2 and move it into another directory, you probably already figured out the command:
$ mv file dir1/file2

< Removing files >

The rm command is used for removing files and directories. To remove a file:
$ rm file

If you use the -i option, you’ll be prompted before removing the file:
$ rm -i file

You can also delete more files at once:
rm file1 file2

Be careful with the rm command! As I already told you, Linux doesn’t have any undo commands, and it doesn’t put files into Trash where you can save them later. Once you’ve

< Creating directories >

Creating a new, empty directory is very easy. You use the mkdir command:
$ mkdir dir1

That’s it. It’s really that easy!

< Removing directories >

There are two commands you can use for removing directories. If the directory is empty, you can use rmdir:
$ rmdir dir1

You can use rmdir only if the directory is empty. If you want to remove a directory with all its contents, you can use rm with the -r option. The -r option tells rm to remove a directory recursively:
$ rm -r dir1

It goes without saying that you can cause a lot of trouble with rm -r if you’re not careful! In some cases it might be a good thing to use the -i option when deleting a directory with its contents so that you’d be prompted before each file in the directory gets deleted:
$ rm -ir dir1

< Copying and moving directories >

For copying and moving directories you can use the cp and mv commands just like you use them with files. Yeah, I know. If you’ve already tried to copy a directory with cp, you’ve probably noticed that cp just complains at you. Probably it says something like cp: omitting directory yadda yadda. You see, the cp command wants you to use the -r option if you want to copy a directory with its contents. The -r means “copy recursively”:
$ cp -r dir1 dir2

The above creates a directory named dir2 whose contents will be identical to dir1. However, if dir2 already exists, nothing will be overwritten: the directory dir1 will be copied into the dir2 directory under the name dir2/dir1.

When renaming directories, you use the mv command exactly the same way as with files:
$ mv dir1 dir2

When dealing with directories, mv works a bit like cp does. If dir2 doesn’t exist, the above will rename dir1 to dir2, but if dir2 exists, the directory dir1 will be moved into the dir2 directory under the name dir2/dir1.

cource :

Một số lệnh và phím tắt thường dùng trong Linux

Phím tắt

1. Trong terminal

* <Ctrl> + L: xoá toàn bộ màn hình, giống lệnh clear
* <Ctrl> + D: exit session, giống lệnh exit
* <Ctrl> + R: tìm một lệnh đã chạy trước đây, nhấn <Ctrl> + R sau đó bắt đầu gõ một phần của câu lệnh, hệ thống sẽ tự hoàn tất phần còn lại dựa trên các câu lệnh đã được thực hiện trước đó
* <Tab>: tự động hoàn tất câu lệnh
* <Shift> + <Insert>: dán (paste) nội dung đã copy vào terminal
* <Shift> + PageUp: cuộn màn hình lên trên một trang
* <Ctrl> + <Alt> + F2 (<Alt> + F2> nếu đang ở chế độ console): chuyển sang virtual terminal thứ 2, tương tự với F3, F4 …

2. Trong GNOME

* <Ctrl> + <Alt> + D: hiển thị desktop, giống <Windows> + D trong Windows
* <Ctrl> + <Alt> + <Left/Right>: chuyển sang workspace trước/kế tiếp
* <Ctrl> + W: đóng cửa sổ hiện thời
* <Ctrl> + Q: thoát khỏi chương trình hiện thời
* <Alt> + F1: Hiển thị main menu
* <Alt> + F2: Hiển thị hộp thoại chạy dòng lệnh, giống <Windows> + R trong Windows
* <Alt> + F5: Bỏ phóng to cửa sổ hiện thời
* <Alt> + F9: Thu nhỏ <minimize> cửa sổ hiện thời
* <Alt> + F10: Phóng to <maximize> cửa sổ hiện thời

3. Trong OpenOffice:

* <Ctrl> + <Shift> + B: chuyển font sang dạng subscript, giống <Ctrl> + ‘+’ trong MS Word
* <Ctrl> + <Shift> + P: chuyển font sang dạng supperscript, giống <Ctrl> + <Shift> + ‘+’ trong MS Word
* <Ctrl> + 1: Single line spacing
* <Ctrl> + 2: Double line spacing
* <Ctrl> + 5: 1.5 line spacing

Xem danh sách chi tiết các phím tắt của OpenOffice tại…shortcuts.html

4. Trong vi (vim)

Các phím sau đây được sử dụng trong chế độ nhập lệnh (không phải chế độ nhập văn bản). Để viết về vi thì cần một bài riêng, nên ở đây cheva chỉ nêu ra một số phím/lệnh chính, chú ý các phím/lệnh sau đây có phân biệt chữ hoa và chữ thường:
* G: tới cuối file
* #G: tới dòng thứ # (ví dụ 10G, 100G)
* H: tới đầu trang
* dd: xóa dòng hiện thời
* yy: copy dòng hiện thời
* p: dán xuống dòng dưới dòng hiện thời
* P: dán vào trước vị trí con trỏ
* /: bắt đầu tìm kiếm
* ^: tới đầu dòng
* $: tới cuối dòng
* %: tới dấu đóng (mở) ngoặc tương ứng
* %s/old_text/new_text/g: thay thế tất cả các old_text bằng new_text
* Ở chế độ nhập văn bản, gõ <Ctrl> + P để sử dụng auto text completion

Các câu lệnh hữu ích trong quá trình làm quen với Linux

1. chuyển stderr và stdout vào cùng một file, thêm đoạn sau vào cuối câu lệnh 2>&1 output.log
2. để ghi stdout của chương trình vào file bên cạnh việc in ra màn hình, thêm đoạn sau vào sau câu lệnh | tee output.log
3. truy cập x từ xa, dùng lệnh ssh -X
trên máy remote host cần có các nội dung sau trong file /etc/ssh/sshd_config

change: X11Fowrading to yes
change X11DisplayOffset 10
change X11Uselocalhost yes

4. tìm và thay thế xâu ký tự trong nhiều file (có dấu ; ở cuối) find ./ -type f -exec sed ‘s/string1/string2’ {} \;
5. thay thế tất cả các xâu OLD bằng xâu NEW trong vim :%s/OLD/NEW/g
6. theo dõi thời gian thực hiện của một câu lệnh (tùy chọn v yêu cầu hiện thị chi tiết) /usr/bin/time -v — <command to execute>
7. hiển thị các file có thể chạy được trong thư mục hiện thời bằng ls ls -F | grep \*
8. sửa file đầu tiên trong thư mục vi `ls | head -1`
9. tar -jxf file_name.tar.bz2 giải nén file tar dạng bz2, tar -zxf file_name.tar.gz giải nén file tar dạng gz
10. tar -jcf file_name.tar.bz2 file_to_archive nén file dạng bz2, tar -zcf file_name.tar.gz file_to_archive nén file dạng gz
11. which <command> hiển thị đường dẫn đầy đủ tới câu lệnh <command>
12. file <filename> xác định xem filename là kiểu file gì
13. md5sum kiểm tra mã md5 hash của một file, xâu ký tự
14. id hiển thị thông tin về người dùng và các nhóm của người dùng đó (chi tiết hơn whoami)
15. dùng su – username để impersonate một người dùng khác
16. dùng sudo su – để chuyển lên account root và có các setting dành cho root
17. df -h để kiểm tra dung lượng ổ đĩa cứng, dùng du -h để kiểm tra dung lượng của thư mục hiện thời và các thư mục con trong đó, dùng du -sh để chỉ hiện thị dung lượng của thư mục hiện thời (không hiện chi tiết về các thư mục con)
18. cat /proc/cpuinfo hiển thị thông tin về hệ thống (tốc độ, bộ nhớ, kiến trúc máy …)
19. free -m hiển thị thông tin về tình trạng sử dụng bộ nhớ trên máy theo megabytes
20. diff file1 file2 so sánh nội dung hai file
21. dùng ls -lh thay cho ls -l
22. cat file_name | wc -l đếm số dòng trong một file
23. uname -r xem phiên bản của Linux kernel
24. find . | xargs grep ‘string’ tìm các file có chữa chuỗi string trong thư mục hiện thời
25. watch <command> chạy và hiển thị kết quả của lệnh command sau mỗi 2s. Bấm Ctrl+C để kết thúc
26. w xem danh sách những người đang login vào hệ thống
27. lsof | grep <command> xem danh sách các file mà command đang truy cập