Archive for November, 2010

15 interesting facts about LInux and Kernel

On 14th March 1994, Linux kernel version 1.0.0 was humbly released for the world to tinker with.

1. A 21 year-old Finnish college student created the Linux kernel as a hobby. (Do you know him?)

2. An asteroid was named after the creator of the Linux kernel.

3. Thousands of developers/programmers scattered all around the world are continuously contributing to the development of the Linux kernel.

4. The Linux kernel’s official mascot is a penguin named Tux.

5. According to a study funded by the European Union, the estimated cost to redevelop the most recent kernel versions would be at $1.14 billion USD.

6. As of today, only 2% of the Linux kernel has been written by Linus Torvalds.

7. The Linux kernel is written in the version of the C programming language.

8. Linux is now one of the most widely ported operating system kernels, running on a diverse range of systems from handheld computers to mainframe servers.

9. Linux kernel 1.0.0 was released with 176,250 lines of code. The latest Linux kernel has over 10 million lines of code.

10. Microsoft Windows and the Linux kernel can run simultaneously in parallel on the same machine using a software called Cooperative Linux (coLinux).

11. At first, Torvalds wanted to call the kernel he developed Freax (a combination of “free”, “freak”, and the letter X to indicate that it is a Unix-like system), but his friend Ari Lemmke, who administered the FTP server where the kernel was first hosted for downloading, named Torvalds’ directory linux.

12. A guy name William Della Croce, Jr. trademarked the name Linux and eventually demanded royalties for its use. He later agreed to assign the trademark to Torvalds.

13. The Linux kernel can be found on more than 87% of systems on the world’s Top 500 supercomputers.

14. A “vanilla kernel” is not an ice cream flavor but an unmodified version of the Linux kernel.

15. The Linux Kernel is not in any way related to the army rank called ‘Colonel’. (hehe)

Cheers!

Advertisements

Install Linux on USB stick (Pen drive)

USB Pendrive Linux install from Linux

The Pendrivelinux team has put together a USB Pen Drive Linux package based purely on Debian Linux. The USB Linux package is currently available in .img format. Installation is simple and just requires copying the .img to a USB device and then creating a live-rw partition if you wish to store your changes. We think you will find this personalized USB Linux version easy to install, navigate and use.

Credits extend to the Debian-Live team for creating Live-Helper script used in this project. (Aicrom) Márcio Santos for the custom Penguin artwork, Theme-Graphics thanks to Carlos

This Pendrivelinux version is obsolete and no longer supported.

Basic Essentials:

  • 1GB or larger USB flash drive (512MB will work but isn’t recommended)
  • Pendrivelinux.img
  • Linux environment (Debian used in this example)

Obtaining and installing Pendrivelinux to USB:

  1. Insert a 1GB or larger USB flash pen drive
  2. Start your PC (booting from a Linux OS)
  3. Download the pendrivelinux.img
  4. Open a terminal and type sudo su
  5. From the terminal, change to the directory where you saved pendrivelinux.img
  6. Type fdisk -l and note which device is your USB device. Example:/dev/sdX (X represents your USB drive letter. Through the rest of this tutorial, replace X with your actual drive letter)
  7. Type dd if=pendrivelinux.img of=/dev/sdX

Optional – Create a second partition for saving changes:

  1. Type fdisk /dev/sdX
    1. Type n (makes a new partition)
    2. Type p (makes the new partition a primary partition)
    3. Type 2 (makes this the 2nd primary partition)
    4. Hit enter to accept the default first cylinder
    5. Hit enter again to accept the default last cylinder
    6. Type w (writes the new partition information to the USB drive)
  2. Type umount /dev/sdX1 and then remove and reinsert your USB drive
  3. Type mkfs.ext2 -b 4096 -L live-rw /dev/sdX2
  4. Reboot your computer and set boot priority to boot from the USB stick

You should now be booting into USB Pen Drive Linux from your USB drive!

Notes: You must boot by typing live persistent at the boot prompt if you wish to use the second partition to save or restore changes. Otherwise the system will boot in LIVE mode.

No root password has been set by default. To set a root password open a terminal and type sudo passwd root and then set the password you would like to use for root access.

The default username is user. Default user password is live

Key Board Shortcut (Linux)

< Virtual terminals >

Ctrl + Alt + F1
Switch to the first virtual terminal. In Linux, you can have several virtual terminals at the same time. The default is 6.

Ctrl + Alt + Fn
Switch to the nth virtual terminal. Because the number of virtual terminals is 6 by default, n = 1…6.

tty
Typing the tty command tells you what virtual terminal you’re currently working in.

Ctrl + Alt + F7
Switch to the GUI. If you have the X Window System running, it runs in the seventh virtual terminal by default in most Linux distros. If X isn’t running, this terminal is empty.
Note: in some distros, X runs in a different virtual terminal by default. For example, in Puppy Linux, it’s 3.

< X Window System >

Ctrl + Alt + +
Switch to the next resolution in the X Window System. This works if you’ve configured more than one resolution for your X server. Note that you must use the + in your numpad.

Ctrl + Alt + -
Switch to the previous X resolution. Use the – in your numpad.

MiddleMouseButton
Paste the highlighted text. You can highlight the text with your left mouse button (or with some other highlighting method, depending on the application you’re using), and then press the middle mouse button to paste. This is the traditional way of copying and pasting in the X Window System, but it may not work in some X applications.

If you have a two-button mouse, pressing both of the buttons at the same time has the same effect as pressing the middle one. If it doesn’t, you must enable 3-mouse-button emulation.

This works also in text terminals if you enable the gpm service.

Ctrl + Alt + Backspace
Kill the X server. Use this if X crashes and you can’t exit it normally. If you’ve configured your X Window System to start automatically at bootup, this restarts the server and throws you back to the graphical login screen.

< Command line – input >

Home or Ctrl + a
Move the cursor to the beginning of the current line.

End or Ctrl + e
Move the cursor to the end of the current line.

Alt + b
Move the cursor to the beginning of the current or previous word. Note that while this works in virtual terminals, it may not work in all graphical terminal emulators, because many graphical applications already use this as a menu shortcut by default.

Alt + f
Move the cursor to the end of the next word. Again, like with all shortcuts that use Alt as the modifier, this may not work in all graphical terminal emulators.

Tab
Autocomplete commands and file names. Type the first letter(s) of a command, directory or file name, press Tab and the rest is completed automatically! If there are more commands starting with the same letters, the shell completes as much as it can and beeps. If you then press Tab again, it shows you all the alternatives.

This shortcut is really helpful and saves a lot of typing! It even works at the lilo prompt and in some X applications.

Ctrl + u
Erase the current line.

Ctrl + k
Delete the line from the position of the cursor to the end of the line.

Ctrl + w
Delete the word before the cursor.

< Command line – output >

Shift + PageUp
Scroll terminal output up.

Shift + PageDown
Scroll terminal output down.

clear
The clear command clears all previously executed commands and their output from the current terminal.

Ctrl + l
Does exactly the same as typing the clear command.

reset
If you mess up your terminal, use the reset command. For example, if you try to cat a binary file, the terminal starts showing weird characters. Note that you may not be able to see the command when you’re typing it.

< Command line – history >

history
When you type the history command, you’ll see a list of the commands you executed previously.

ArrowUp or Ctrl + p
Scroll up in the history and edit the previously executed commands. To execute them, press Enter like you normally do.

ArrowDown or Ctrl + n
Scroll down in the history and edit the next commands.

Ctrl + r
Find the last command that contained the letters you’re typing. For example, if you want to find out the last action you did to a file called “file42.txt“, you’ll press Ctrl + r and start typing the file name. Or, if you want to find out the last parameters you gave to the “cp” command, you’ll press Ctrl + r and type in “cp“.

< Command line – misc >

Ctrl + c
Kill the current process.

Ctrl + z
Send the current process to background. This is useful if you have a program running, and you need the terminal for awhile but don’t want to exit the program completely. Then just send it to background with Ctrl+z, do whatever you want, and type the command fg to get the process back.

Ctrl + d
Log out from the current terminal. If you use this in a terminal emulator under X, this usually shuts down the terminal emulator after logging you out.

Ctrl + Alt + Del
Reboot the system. You can change this behavior by editing /etc/inittab if you want the system to shut down instead of rebooting.

Kernel compilation (2.6 version)

Compiling custom kernel has its own advantages and disadvantages. However, new Linux user / admin find it difficult to compile Linux kernel. Compiling kernel needs to understand few things and then just type couple of commands. This step by step howto covers compiling Linux kernel version 2.6.xx under RPM (Fedora ) GNU Linux. However, instructions remains the same for any other distribution except for yum/apt-get command.

Step # 1 Get Latest Linux kernel code

Visit http://kernel.org/ and download the latest source code. File name would be linux-x.y.z.tar.bz2, where x.y.z is actual version number. For example file inux-2.6.35.tar.bz2 represents 2.6.35 kernel version. Use wget command to download kernel source code:
$ cd /tmp
$ wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-x.y.z.tar.bz2

Note: Replace x.y.z with actual version number.

Step # 2 Extract tar (.tar.bz or .tar.bz2) file

Type the following command:
# tar -xjvf linux-2.6.35.tar.bz2 -C /usr/src
# cd /usr/src

Step # 3 Configure kernel

Before you configure kernel make sure you have development tools (gcc compilers and related tools) are installed on your system. If gcc compiler and tools are not installed then use apt-get command under Debian Linux to install development tools.
# apt-get install gcc  (ubuntu users)

# yum groupinstall 'Development Tools'  (fedora users)

Now you can start kernel configuration by typing any one of the command:

  • $ make menuconfig – Text based color menus, radiolists & dialogs. This option also useful on remote server if you wanna compile kernel remotely.
  • $ make xconfig – X windows (Qt) based configuration tool, works best under KDE desktop
  • $ make gconfig – X windows (Gtk) based configuration tool, works best under Gnome Dekstop.

For example make menuconfig command launches following screen:
$ make menuconfig

You have to select different options as per your need. Each configuration option has HELP button associated with it so select help button to get help.

Step # 4 Compile kernel

Start compiling to create a compressed kernel image, enter:
$ make
Start compiling to kernel modules:
$ make modules

Install kernel modules (become a root user, use su command):
$ su -
# make modules_install

Step # 5 Install kernel

So far we have compiled kernel and installed kernel modules. It is time to install kernel itself.
# make install

It will install three files into /boot directory as well as modification to your kernel grub configuration file:

  • System.map-2.6.35
  • config-2.6.35
  • vmlinuz-2.6.35

Step # 6: Create an initrd image

Type the following command at a shell prompt:
# cd /boot
# mkinitrd -o initrd.img-2.6.35 2.6.35

initrd images contains device driver which needed to load rest of the operating system later on. Not all computer requires initrd, but it is safe to create one.

Step # 7 Modify Grub configuration file – /boot/grub/menu.lst

(only for ubuntu users)

Open file using vi:
# vi /boot/grub/menu.lst

title           ubuntu (2.6.35.fc14.i686)
root            (hd0,0)
kernel          /boot/vmlinuz root=/dev/hdb1 ro
initrd          /boot/initrd.img-2.6.35
savedefault
boot

Remember to setup correct root=/dev/hdXX device. Save and close the file. If you think editing and writing all lines by hand is too much for you, try out update-grub command to update the lines for each kernel in /boot/grub/menu.lst file. Just type the command:
# update-grub
Neat. Huh?

Step # 8 : Reboot computer and boot into your new kernel

Just issue reboot command:
# reboot