Home » , , » Trying Out Linux

Trying Out Linux

Written By Sajib Barua on Friday, August 17, 2012 | 12:59 PM

previous Troubleshooting and Configuring Linux
You’re sitting in front of your PC about to turn it on. You know that the PC has Linux installed. (Maybe you did the installing yourself, but who’s keeping track?) You’re wondering what to expect when you turn it on and what you do afterward. Not to worry. If you’re using Linux for the first time, this chapter shows you how to log in, check out the graphical desk- tops, try out some cryptic Linux commands, and finally, shut down the PC.
If you try out the Ubuntu Live CD, all you have to do is boot from the Ubuntu Live CD (as explained in Chapter 2 of this minibook), and you can try it just like any other Linux distribution.
For those of you who already know something about Linux, flip through this chapter to see if anything looks new. You never know what you may not know!
Starting Linux
When you turn on the PC, it goes through the normal power-up sequence and loads the boot loader — GRUB or LILO, depending on your Linux distri- bution and what you select during installation. The boot loader (once known as the bootstrap loader) is a tiny computer program that loads the rest of the operating system from the hard drive into the computer’s memory. The entire process of starting a computer is called booting.

For Live CDs, the boot loader is typically ISOLINUX, a boot loader designed to work from an ISO 9660 CD-ROM.

The LILO and GRUB boot loaders display a graphical screen with the names of the operating systems that the boot loader can load. For example, if your PC has Windows and Linux, you see both names listed. You can then use the up- and down-arrow keys to select the operating system you want to use. If the PC is set up to load Linux by default, wait a few seconds, and the boot loader starts Linux. To be more precise, the boot loader loads the Linux kernel — the core of the Linux operating system — into the PC’s memory.

Other boot loaders, such as ISOLINUX, may display a text boot: prompt at which you can type boot commands to load specific operating systems and to pass options to that operating system.

While the Linux kernel starts, you see a long list of opening messages, often referred to as the boot messages. (You can see these messages at any time by typing the command dmesg in a terminal window.) These messages include the names of the devices that Linux detects. One of the first lines in the boot messages reads

Calibrating delay loop . . . 4997.12 BogoMIPS (lpj=2498560)

BogoMIPS is Linux jargon (explained in this chapter in a handy sidebar) for a measure of time. The number that precedes BogoMIPS depends on your PC’s processor speed, whether it’s an old 200 MHz Pentium or a new 4 GHz Pentium 4. The kernel uses the BogoMIPS measurement when it has to wait a small amount of time for some event to occur (such as getting a response back from a disk controller when it’s ready).

After the boot messages display, some Linux distributions, such as Fedora, switch to a graphical boot screen that shows information about the progress of system startup. When you boot some Linux distributions, such as Fedora and Xandros Desktop OS, for the first time after installation, you get a configuration program that guides you through some configuration steps, such as setting the date and time and adding user accounts. To complete such first-time configuration steps, all you have to do is enter the requested information.

After Linux boots, you typically get a graphical login screen. For some distributions, such as Knoppix, you get the desktop without having to log in as a user. On other Live CDs, you have to log in.

Figure 5-1 shows the Ubuntu desktop after I booted a PC from the Ubuntu Live CD. For some distributions, you might be logged in automatically. For others, a graphical login screen will appear asking you to authenticate with the username and password given during (or at any time after) the installation.

Every distribution utilizes the root username, which happens to be the superuser (the administrator account). Whether you install Linux yourself or someone installs it for you, you need to know the root password. Without that, you can’t do many of the tasks necessary to find out how Linux works.

The Ubuntu Live CD desktop

Figure 5-1: The Ubuntu Live CD desktop.

What are BogoMIPS and LPJ?

When Linux boots, you get a message that says Calibrating delay loop . . . 4997.12 BogoMIPS (lpj=2498560), with some number before the word BogoMIPS. BogoMIPS is one of those words that confounds new Linux users, but it’s just jargon with a simple meaning.

BogoMIPS is Linus’s invention (yes, the same Linus Torvalds who started Linux), and it means bogus MIPS. As you may know, MIPS is an acronym for millions of instructions per second — a measure of how fast your computer runs programs. Unfortunately, MIPS isn’t a very good measure of performance; the MIPS measurements of different types of computers are difficult to compare accurately. BogoMIPS is basically a way to measure the computer’s speed that’s independent of the exact processor type. Linux uses the BogoMIPS number to calibrate a delay loop, in which the computer keeps running some useless instructions until a specified amount of time passes. The reason for killing valuable processor time like this is to wait for some slowpoke device to get ready for work.

Oh . . . about LPJ — it’s a recent term that stands for loops per jiffy, and it’s another measure of time delay used by the kernel. The Linux kernel considers time in increments of jiffies, and a jiffy is defined as the time period that is equal to one second divided by the value of a kernel variable named HZ. In other words, HZ jiffies are in each second.

You shouldn’t normally log in as root. When you log in as root, you could accidentally damage your system because you can do anything when you’re root. Always log in as a normal user. When you need to perform any task as root, type su - in a terminal window and enter the root password.

In Ubuntu, you define only a normal user account; Ubuntu doesn’t give you the opportunity to define a root user account. Whenever you want to perform any tasks that require you to be root, you have to use the sudo command (an abbreviation for “superuser do”). The default password for root is the one you gave during the installation of the operating system.

To log in as user spiderman, for example, type spiderman in the first text field and press Enter. (Move the cursor to the login dialog box before you begin typing.) Then type spiderman’s password and press Enter. You then see the initial graphical user interface (GUI). What you get depends on your choice of GUI — GNOME or KDE. If someone made the choice for you, don’t worry — GNOME and KDE are both quite good and versatile.

Linux is basically UNIX, and UNIX just doesn’t feel like UNIX unless you can type cryptic commands in a text terminal. Although GNOME and KDE do a lot to bring us into the world of windows, icons, mouse, and pointer — affectionately known as WIMP — sometimes you’re stuck with nothing but a plain text screen with a prompt that looks something like this (when you log in as edulaney):

edulaney@linux:/etc>

You see the text screen most often when something is wrong with the X Window System, which is essentially the machinery that runs the windows and menus that you normally see. In those cases, you have to work with the shell and know some cryptic Linux commands.

You can prepare for unexpected encounters with the shell by trying some Linux commands in a terminal window while you’re in the GNOME or KDE GUI. After you get the hang of using the terminal, you might even keep a terminal window open so you can use one of those cryptic commands — simply because it’s faster than pointing and clicking. Those two-letter commands do pack some punch!

Starting the bash shell

Simply put, the shell is the Linux command interpreter — a program that reads what you type, interprets that text as a command, and does what the command is supposed to do.

Before you start playing with the shell, open a terminal window. In either GNOME or KDE, the panel typically includes an icon that looks like a monitor. When you click that icon, what appears is a window with a prompt, like the one shown in Figure 5-2. That’s a terminal window, and it works just like an old-fashioned terminal. A shell program is running and ready to accept any text that you type. You type text, press Enter, and something happens (depending on what you typed).

The terminal window awaits your input

Figure 5-2: The terminal window awaits your input.

If the GNOME or KDE panel on your desktop doesn’t seem to have an icon that starts a terminal or shell window, search through the Main menu hierarchy and you should be able to find an item labeled Console or Terminal. Choosing that item should then open a terminal window.

The prompt that you see depends on the shell that runs in that terminal window. The default Linux shell is bash (which stands for Bourne-Again SHell).

bash understands a host of standard Linux commands, which you can use to look at files, go from one directory to another, see what programs are running (and who else is logged in), and a whole lot more.

In addition to the Linux commands, bash can run any program stored in an executable file. bash can also execute shell scripts — text files that contain Linux commands.

Understanding shell commands

Because a shell interprets what you type, knowing how the shell figures out the text that you enter is important. All shell commands have this general format:

command option1 option2 . . . optionN

Such a single line of commands is commonly called a command line. On a command line, you enter a command followed by one or more optional parameters (or arguments). Such command-line options (or command-line arguments) help you specify what you want the command to do.

One basic rule is that you have to use a space or a tab to separate the command from the options. You also must separate options with a space or a tab. If you want to use an option that contains embedded spaces, you have to put that option within quotation marks. For example, to search for two words of text in the password file, I enter the following grep command. (grep is one of those cryptic commands used to search for text in files.)

grep “WWW daemon” /etc/passwd

When grep prints the line with those words, it looks like the following. (What you see on your system may differ from what I show.)

wwwrun:x:30:8:WWW daemon apache:/var/lib/wwwrun:/bin/false

If you created a user account in your name, go ahead and type the grep command with your name as an argument but remember to enclose the name in quotes.

Trying a few Linux commands

While you have the terminal window open, try a few Linux commands just for fun. I will guide you through some examples to give you a feel for what you can do at the shell prompt.

To see how long the Linux PC has been up since you last powered it up, type the following. (Note: I show the typed command in bold, followed by the output from that command.)

uptime
12:06:34 up 59 days, 16:23, 4 users, load average: 0.56, 0.55, 0.37

The part up 59 days, 16:23 tells you that this particular PC has been up for nearly two months. Hmmm . . . can Windows do that?

To see what version of Linux kernel your system is running, use the uname command like this:

uname –srv

This runs the uname command with three options: -s, -r, and -v (which can be combined as -srv, as this example shows). The -s option causes uname to print the name of the kernel, -r prints the kernel release number, and -v prints the kernel version number. The command generates the following output on one of my Linux systems:

Linux 2.6.31.5-127.fc12.i686 #1 SMP Sat Nov 7 21:41:45 EST 2009

In this case, the system is running Linux kernel version 2.6.31.

To read a file, use the more command. For example, type more /etc/passwd to read the /etc/passwd file. The resulting output looks similar to the following:

root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/bin/bash
daemon:x:2:2:Daemon:/sbin:/bin/bash
lp:x:4:7:Printing daemon:/var/spool/lpd:/bin/bash
mail:x:8:12:Mailer daemon:/var/spool/clientmqueue:/bin/false
news:x:9:13:News system:/etc/news:/bin/bash
uucp:x:10:14:Unix-to-Unix Copy system:/etc/uucp:/bin/bash
. . . lines deleted . . .

To see a list of all the programs currently running on the system, use the ps command, like this:

ps ax

The ps command takes many options, and you can provide these options without the usual dash prefix. This example uses the a and x options. The a option lists all processes that you’re running, and the x option displays the rest of the processes. The result is that ps ax prints a list of all processes running on the system, as shown in the following sample output of the ps ax command:

PID TTY STAT TIME COMMAND
1 ? S 0:01 init [5]
2 ? SN 0:00 [ksoftirqd/0]
3 ? S< 0:00 [events/0]
4 ? S< 0:00 [khelper]
9 ? S< 0:00 [kthread]
22 ? S< 0:00 [kblockd/0]
58 ? S 0:00 [kapmd]
79 ? S 0:00 [pdflush]
80 ? S 0:00 [pdflush]
82 ? S< 0:00 [aio/0]
. . . lines deleted . . .
5325 ? Ss 0:00 /opt/kde3/bin/kdm
5502 ? S 0:12 /usr/X11R6/bin/X -br -nolisten tcp :0 vt7 -auth /var/lib/xdm/
authdir/authfiles/A:0-p1AOrt
5503 ? S 0:00 -:0
6187 ? Ss 0:00 /sbin/portmap
6358 ? Ss 0:00 /bin/sh /usr/X11R6/bin/kde
6566 ? Ss 0:00 /usr/sbin/cupsd
6577 ? Ssl 0:00 /usr/sbin/nscd
. . . lines deleted . . .

Amazing how many programs can run on a system even when only you are logged in as a user, isn’t it?

As you can guess, you can do everything from a shell prompt, but it does take some getting used to.

Shutting Down

When you’re ready to shut down Linux, you must do so in an orderly manner. Even if you’re the sole user of a Linux PC, several other programs usually run in the background. Also, operating systems, such as Linux, try to optimize the way that they write data to the hard drive. Because hard drive access is relatively slow (compared with the time needed to access memory locations), data generally is held in memory and written to the hard drive in large chunks. Therefore, if you simply turn off the power, you run the risk that some files aren’t updated properly.

Any user (you don’t even have to be logged in) can shut down the system from the desktop or from the graphical login screen, although some distributions, such as Debian, prompt you for the root password. Choose Main Menu➪Log Out (or look for a Log Out option in the menus). A Log Out dialog box appears, such as the one shown in Figure 5-3, providing options for rebooting, halting the system, or simply logging out. To shut down the system, simply select Shutdown and click OK. The system then shuts down in an orderly manner.

The Log Out dialog box

Figure 5-3: The Log Out dialog box.

If the logout menu doesn’t have an option to shut down, first log out and then select Shutdown from the graphical login screen. You can also shut down a Linux computer from a terminal with the command init 0. This method is sometimes required if you are running the operating system within a virtual software manager such as VMWare.

While the system shuts down, you see messages about processes shutting down. You may be surprised at how many processes there are even when no one is explicitly running any programs on the system. If your system doesn’t automatically power off on shutdown, you can manually turn off the power.

Shutting down or rebooting the system may not require root access. This is why it’s important to make sure that physical access to the console is protected adequately so that anyone who wants to can’t simply walk up to the console and shut down your system.

You don’t always need to shut down when you’re finished with a session; instead, you may choose to simply log out. To log out of KDE, choose Main Menu➪Logout. You can also right-click an empty area of the desktop and choose Logout from the context menu that appears. To log out from GNOME, choose System➪Log Out. Click OK when a dialog box asks if you really want to log out. (In some GNOME desktop distributions, the menu option to log out is the second or third menu button from the left in the top panel.)

next Linux Desktops

Share this article :

0 comments:

Post a Comment

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. Linux - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger