333
CHAPTER 1 :-HISTORY AND DEVELOPMENT OF LINUX Lesson 1 :-A Brief History of Linux Lesson Objectives In this lesson, you will: Describe a kernel. Describe Linux's relationship to the GNU project and the general principles underlying the GNU General Public License. Introduction: Simply put, Linux is a computer operating system. As such, it controls the basic input and output functions of a computer, enabling it to perform such tasks as displaying information on a monitor, accepting input from a keyboard, and saving and retrieving files on storage devices (including hard disks, floppy disks, and network drives). In many respects, the Linux operating system is very similar to UNIX. Linux commands closely resemble those found on other UNIX-type operating systems, and many programs written for other operating systems run on Linux. What Makes Linux Different :-It would be an oversimplification to view Linux as simply another implementation of Unix, or even simply as a free or inexpensive UNIX clone. Although there is much about Linux from a technical perspective that makes it attractive to network administrators, programmers, and users, much of its attraction is not about the technical aspects of the product. Rather, it has to do with how Linux was developed, how it is distributed, how it is supported, and who drives its further development. To understand what makes Linux different, it is helpful to look at how the operating system evolved. TIP: you will see the name Unix written two way: UNIX and Unix. Unix. In many cases, the distinction is intentional. The former (all upper-case letters) is a trademark that identifies the operating system developed and marketed by AT&T�s Bell Labs. The latter (with lowercase letters) refers to any UNIX-like operating system�particularly those not developed by AT&T. The Free Software Movement :-In the early days of computing, many computer programmers felt that it was in their best interests to freely share new software and other computer technology that they developed with other programmers, computer administrators, and computer users. They also shared computer source code-the instructions used to build the software. Once a programmer possessed the source code to a piece of software, she or he could not only build a copy of the software, but also modify and improve it. Many programmers felt that by sharing their source code with others, the entire community of programmers and users would benefit from the collective competence of the community. This sort of openness and sharing led to rapid improvements in computer technology. Much of the technology behind the government-funded network that eventually became the Internet was developed in this manner. By the early 1980's, companies like AT&T, Microsoft, and IBM had begun practicing what many researchers, academics, and computer hobbyists considered to be restrictive licensing practices. Operating systems and utility programs produced by such companies 1

HISTORY AND DEVELOPMENT OF LINUX22

Embed Size (px)

Citation preview

Page 1: HISTORY AND DEVELOPMENT OF LINUX22

CHAPTER 1 :-HISTORY AND DEVELOPMENT OF LINUX

Lesson 1 :-A Brief History of Linux

Lesson Objectives

In this lesson, you will:

Describe a kernel. Describe Linux's relationship to the GNU project and the general principles underlying the GNU General Public

License.

Introduction: Simply put, Linux is a computer operating system. As such, it controls the basic input and output functions of a computer, enabling it to perform such tasks as displaying information on a monitor, accepting input from a keyboard, and saving and retrieving files on storage devices (including hard disks, floppy disks, and network drives). In many respects, the Linux operating system is very similar to UNIX. Linux commands closely resemble those found on other UNIX-type operating systems, and many programs written for other operating systems run on Linux.

What Makes Linux Different :-It would be an oversimplification to view Linux as simply another implementation of Unix, or even simply as a free or inexpensive UNIX clone. Although there is much about Linux from a technical perspective that makes it attractive to network administrators, programmers, and users, much of its attraction is not about the technical aspects of the product. Rather, it has to do with how Linux was developed, how it is distributed, how it is supported, and who drives its further development. To understand what makes Linux different, it is helpful to look at how the operating system evolved.TIP: you will see the name Unix written two way: UNIX and Unix. Unix. In many cases, the distinction is intentional. The former (all upper-case letters) is a trademark that identifies the operating system developed and marketed by AT&T�s Bell Labs. The latter (with lowercase letters) refers to any UNIX-like operating system�particularly those not developed by AT&T.

The Free Software Movement :-In the early days of computing, many computer programmers felt that it was in their best interests to freely share new software and other computer technology that they developed with other programmers, computer administrators, and computer users. They also shared computer source code-the instructions used to build the software. Once a programmer possessed the source code to a piece of software, she or he could not only build a copy of the software, but also modify and improve it. Many programmers felt that by sharing their source code with others, the entire community of programmers and users would benefit from the collective competence of the community.

This sort of openness and sharing led to rapid improvements in computer technology. Much of the technology behind the government-funded network that eventually became the Internet was developed in this manner.

By the early 1980's, companies like AT&T, Microsoft, and IBM had begun practicing what many researchers, academics, and computer hobbyists considered to be restrictive licensing practices. Operating systems and utility programs produced by such companies could not legally be copied freely by users, and users no longer had access to the source code. This made it difficult or impossible for users-even those who had purchased the software-to make their own customizations and improvements to it.

To many computer users today, these might seem like unreasonable expectations because we have become used to paying (sometimes large amounts of money) to have limited use of software. But for many programmers and computer users who had freely shared software during the early days of computing, the concept of closed source, proprietary software seemed oppressive and not in the best interests of the community.

Richard Stallman, who worked at MIT's Artificial Intelligence labs, was concerned about the increasing trend toward closed and proprietary software. In 1984, Stallman launched an initiative to produce a source of free and open software for the community of computer users. Stallman named the project using the recursive acronym GNU, which stands for GNU Not UNIX. (The "G" in GNU is pronounced.) Stallman's goal was to create a comprehensive computer operating system composed entirely of free software.

Stallman, a competent programmer, wrote much of the GNU software himself, including the GNU C compiler (gcc) and the emacs text editor. He also motivated other developers to contribute to the effort as well, founding the Free Software Foundation to help support the development effort.

1

Page 2: HISTORY AND DEVELOPMENT OF LINUX22

Copyleft and the GPL:-If source code were simply placed in the public domain, there wouldn't be any legal way to prevent another programmer from subtly modifying the source code and then copyrighting it as his or her own property. This, of course, would hamper the objectives of the Free Software Foundation. Stallman saw that the GNU project needed to have some sort of legal protection to ensure that open source software would stay open. Copyright law was designed to enforce private ownership, not public ownership.

Incredibly, Stallman figured out a way to use copyright law to effectively enforce public ownership, by creating a licensing agreement that came to be known as the GNU General Public License (or GPL for short). Stallman referred to the GPL as copyleft because it essentially described an arrangement that was the opposite of copyright.

The GPL states that the programmer holds the copyright to a specific piece of software. This prevents it from being considered in the public domain, where anyone can modify it and then copyright the modified version. However, the GPL then specifies a licensing arrangement under which the software can be freely used, modified, and copied by others. Anyone who modifies the code and distributes it to others must provide open source code that includes their modifications, making it freely available under the terms of the GPL. This ensures that all derivative works will remain open and free.

Under the GPL, software can be sold to pay for packaging, support, and other costs, but it must adhere to all of the restrictions of the license, including providing source code and having all derivative software remain under the GPL.

The Linux Kernel :-By 1991, the GNU project had succeeded in making many utilities available to users under the GPL. However, there still was not an operating system kernel.

That year, a 21-year-old student in Finland, at the University of Helsinki, developed a UNIX-like operating system for his own use. The operating system he had created was inspired by another UNIX-like system, called Minix.

The student, Linus Torvalds, posted his creation on the Internet, and put out requests on the USENET newsgroup comp.os.minix for other programmers to help him further develop it. At that point, Linux (not yet named) was at version 0.02, but it could already run such UNIX utilities as bash, gcc, gnu-sed, and so forth. The figure below is an extract from one of Torvald's postings.

Linus Torvalds' pitch on USENET for an early version of Linux.

The Linux kernel was not a complete system without all of the utilities, and the utilities were not a complete system without the kernel. When Torvalds agreed to release Linux under the GPL, the GNU project finally had a complete operating system.

Important additions to the GNU library, such as GNOME (an X11 windowing system), make Linux a comprehensive operating system that can compete with the features of commercial proprietary systems such as Windows NT, UNIX, and Macintosh.

To get a larger perspective on Linux, the following table shows the timeline for several distributions and puts it in the context of other non-Linux events.

2

Page 3: HISTORY AND DEVELOPMENT OF LINUX22

LINUX TIMELINE:

NON LINUX EVENT LINUX EVENT MUNBER OF LINUX USER

1981 MS-Dos 1.01984 Macintosh/System Finder1985 Microsoft Windows 1.01987 OS/21990 Microsoft Windows 3.01991 Linus Torvalds 21-year-old student in Finland,

at the University of Helsinki developed a UNIX-like operating system called LINUX .02

1992 Linux 1.0 released SuSE Founded TurboLinux Founded

1993 Windows NT Red Hat Founded Debian Project Began Slack first realesed

1,00,000

1994 Caldera Founded 5,00,0001995 Windows 95 Red Hat Linux 4.0 15,00,0001996 Windows NT 4.0 35,00,0001997 Red Hat Linux 5.2, Debian 1.3 75,00,0001998 Windows 98 Mandrake Soft founded, Deian 2.0 1,20,00,0001999 Red Hat Linux 6.0, SuSE 6.3 1,50,00,0002000 Windows 2000, Window ME Red Hat Linux 7.0 , Caldera OpenLinux

eDesktop 2.42,00,00,000

2001 Windows XP Linux Kernel 2.4, released SuSE 7.2, Debain 2.23r, Slackware 8.0, Caldera OpenLinux Server and Workstation 3.1

2,50,00,000

Red Hat and Other Distributions:-Early on, Linux and the GNU utilities were nothing like the packaged software provided with commercial systems. They were a hodgepodge that included the kernel source code and various collections of supporting utilities. Although Linux offered many benefits to users, even in its early days, it was very difficult for new Linux users to compile it, install it on a computer, and to configure it properly.

As Linux became more and more popular, the need for packaged versions of the operating system became evident. Several organizations stepped up to the task, developing installation programs, improving and adding to the documentation, and providing utility programs to make the operating system easier to configure and maintain. These organizations create distributions-complete sets of the operating system and supporting utilities, available from a single source.

Although some of the companies that create the distributions sell them for profit, they are also required by the GPL to make their distributions available to users for free, along with all the source code. For many users, paying for a packaged distribution is an attractive alternative to downloading the same product, because the packaged set includes technical support and printed documentation.

To get a copy of the distribution for free, users must log in to one of the company's FTP sites (or a mirror site) and download the software. Distributions available when this course was written include Red Hat, Caldera, Debian, SuSE, Mandrake, SlackWare, MkLinux (Macintosh), and many others.

Q1. List and describe the benefits of open source software.

Ans : Enables software to be customized, facilitates internal technical support, increases likelihood of bugs being detected because of increased numbers of programmers who can view code, and fosters community among users and a sense of shared responsibility for the software

Q2. List and describe the disadvantages of open source software.

3

Page 4: HISTORY AND DEVELOPMENT OF LINUX22

Ans : The misconception of some IT managers is that open source software is not as stable or as well supported as closed source software. Also, some features (such as documentation and simple installation programs) might be developed more slowly than for closed source software.

Comparing Linux Licensing Schemes:-While the GPL is the basic licensing scheme under which Linux is distributed, other licensing schemes are used for add on packages. Some of these include the:Licensing scheme:

GNU Library or Lesser Public License(LGPL) QT Public License(QPL) Apache Software License Mozilla public License 1.1(MPL 1.1)

Often, Linux is distributed under the GPL, but the packages are distributed under LGPL or MPL (or other licensing schemes). Therefore, you should be aware of the licensing used in each portion of the distribution you get. For example, the Mandrake distribution uses the GPL for Linux itself, Netscape Communicator and XV are redistributable but not open source, other packages are open source, and there are also commercial applications that can't be redistributed. Some packages run into licensing issues as well. For example, KDE uses the QT library. These are each distributed using different licenses. In order to distribute KDE, you must follow the QT licensing scheme.

Q1. What is a kernel?

Ans: It is the central core of the Linux (or UNIX) operating system that manages all of the computer's physical devices.

Q2. What is Linux's relationship to the GNU project and the general principles underlying the GNU General Public License?

Ans: Linux is distributed under the restrictions of the GNU General Public License, which was designed to ensure that free, high-quality software would remain available to academic institutions, research organizations, and virtually anyone who wants to use it. Linux provides a UNIX-like operating system kernel that, in conjunction with the GNU utilities, provides a complete, free operating system with source code that is accessible to everyone.

Lesson 2:- Benefits of Linux

Lesson Objectives

In this lesson, you will:

List some benefits of Linux. List some drawbacks of Linux.

Introduction:-Because of the large number of organizations working to make Linux a better system, its list of benefits increases daily. Some of these include:

Low Cost Easy Licensing Performance and stability Interconnectivity and interpretability.

Low Cost :-Considering that Linux can be legally obtained and used for free, the issue of cost would seem an easy call. Obviously, nothing is less expensive than free. However, most people involved in computer support would agree that any operating system is not without cost. In addition to the cost of licensing an operating system, there are other costs-such as the cost for maintenance and support. These can easily exceed the cost of the software itself. Furthermore, there can be hidden costs, such as having to upgrade memory and other hardware to support the operating system.

Many critics of Linux complain that finding independent Linux consultants is bound to be harder than finding consultants who are familiar with other operating systems. Even considering these factors, many users claim that the actual cost of Linux over time is comparable to, or even less than, other operating systems.

4

Page 5: HISTORY AND DEVELOPMENT OF LINUX22

Many hardware vendors still do not support Linux. However, because Linux's source code is open, and because there are many Linux enthusiasts who want to see the operating system succeed in the marketplace, one can simply post a request on the Internet. In some cases, some talented hobbyist programmer will heed your request, develop a driver to support your hardware, and post the driver on the Internet so that it is freely available for everyone to use.

In one case, a Linux user posted such a request on the Internet, and had a working driver sent to him within 24 hours. Such stories abound among Linux users.

Because of Linux's open source code and its large community of Linux users, many people view technical support as a big benefit. Furthermore, many companies now provide technical support at very reasonable prices, often for much less than the going price from the vendors of the major commercial operating systems. For organizations that need to develop custom software, the availability of Linux's source code is a big help, providing developers with information they need to push the system to the limit.

Easy Licensing :-Because of Linux's simple licensing terms, which include the ability to freely copy the software, IT administrators do not have to spend a lot of time monitoring the number of installations, tracking licenses, and performing other activities related to licensing. This is seen by many in the industry as a great advantage over other operating systems.

Performance and Stability:-Linux has gained a reputation for being extremely stable-much more so than many commercial operating systems. Users point to examples of servers that have been running continuously for more than a year without any downtime. In part, this is due to the fact that the Linux architecture was modeled after Unix, which is time-tested and itself quite stable.

Perhaps to a greater degree, Linux's stability is due to the fact that the Linux source code is freely available for anyone to examine. With all of the scrutiny provided by many different sets of eyes, few bugs go unfound.

As for performance, whether or not Linux has an advantage is less clear. There have been conflicting reports by various organizations regarding Linux's performance when compared against other systems, such as Microsoft Windows and Solaris. Linux seems to fare better or worse, depending on who conducts the comparison and how it is conducted.

One thing seems clear, however. Because Linux's source code is openly available, many different programmers have the opportunity to contribute suggestions for improving Linux's performance.

Interconnectivity and Interoperability :-From its earliest days as part of the GNU software repository, Linux has been associated with the Internet. Support for Internet protocols was added early in Linux's existence, and it continues to be a strong point of the operating system.

Other protocols have been added over time. Linux can now support a wide variety of proprietary networking protocols, including Apple's AppleTalk, IBM's SNA, Novell's IPX/SPX, and Microsoft's Server Message Block (SMB) protocol. Linux can access many different file formats, including Minix-1, XENIX, UNIX System V, CD-ROM, Microsoft FAT, VFAT, HPFS, and Macintosh HFS.

Drawbacks of Linux :-As with any operating system, Linux has drawbacks. Perhaps the greatest of them at this point is that, in some circles, Linux has an image problem. Many IT specialists are hesitant to put themselves in the position of having to support a system they believe was kludged together by a bunch of hobbyists. As there are more and more Linux success stories, Linux's image problem is diminishing.

A less emotional argument against Linux is its difficulty to install and configure. In early versions of Linux, this was a valid argument. In newer versions of Linux, particularly the slick commercial distributions like Red Hat and Caldera, this argument is less valid than before. As time progresses, installation will likely become even easier.

Q1. List potential disadvantages of aspects of Linux.

Ans: Limited number of mainstream applications (such as Microsoft Office) that are available and possible lack of comfort in believing that a single vendor can provide support.

5

Page 6: HISTORY AND DEVELOPMENT OF LINUX22

Comparing Linux to Other Operating Systems:- The major desktop operating systems such as the Microsoft Windows family, Macintosh, and OS/2 are all feeling the impact of Linux on the marketplace. These fee-based operating systems require a cash outlay, but Linux is free, so you can check it out without spending a lot of money.

As Linux has gained popularity, more and more applications are being written for the operating system. Originally, the lack of applications for the operating system held back its popularity. Now that Linux is so popular for a Web server, it is gaining corporate popularity, and therefore people are developing other applications for the operating system.

TCP/IP is the default protocol for Linux. This is the protocol required for accessing the Internet. Other operating systems support it, but it usually might not be the default protocol. Linux also has optional support for protocols supported by Windows and Macintosh such as WINS and AppleTalk.

Q1. List at least two functions that can be carried out on Linux systems and identify whether Windows and Macintoshes can do those same functions. Also, identify whether the functions require purchase of additional software?

Ans Web Server and Mail Server, both Windows and Macintosh can be Web and mail servers, and you need to purchase additional software.

Q2. List at least two features of Linux and compare the availability of those features in other operating systems?

Ans: It is free and it usually includes a full complement of applications including games, office productivity software, and server features. Other operating systems include only the operating system and the most rudimentary applications such as Calculator and Notepad.

Q3. What benefits of Linux do you see over other operating systems?

Ans It is free and it includes applications to perform most common tasks.

Customer Resources :-Even though you can download Linux for free, you might want to consider purchasing a commercial distribution. These usually include at least a period of support from the company. This can be very beneficial if you are new to the operating system.

You will also need to add money to your budget to train staff in supporting Linux. This might be formal classes, online classes, or just time in their schedules to play around with it to learn about it. You might also need to budget time for users to learn how to use it if it will become their desktop operating system. If they are going to use the same desktop operating system they were already using, this might not be an issue.

Some users might do well by purchasing books about Linux. This is usually a good source of information and often includes a Linux distribution on CD-ROM with the book. However, be aware that some of the books on the shelves contain releases other than the most current release of the software.

Q1. Identify the staffing resources you have added or will need to add to support a Linux solution in your company?

Ans Network administrator, server administrator, database administrator, and Web server administrator.

Q2. Identify the areas you would need to add to or modify in your budget to support a Linux solution in your company. Will these areas be more or less expensive than the current solution?

Ans Training, support contract with the Linux distributor. Areas where the budget might be lower include the operating system and application costs.

Q3. Identify the training that will be required for your company to support a Linux solution?

Ans Additional training for administrators who aren't familiar with Linux or UNIX. If users are also moving to Linux on the desktop, you will need to budget for training for them. If administrators and users are already familiar with UNIX, training should be minimal; otherwise, there might be more in-depth training required.

6

Page 7: HISTORY AND DEVELOPMENT OF LINUX22

Q1. What are some benefits of Linux?

Ans Low cost, easy licensing, good performance and stability, and the ability to support a wide variety of proprietary networking protocols.

Q2. What are some drawbacks of Linux?

Ans Few mainstream applications, limited support, and difficulty to install and configure.

Lesson3:-Acquiring and Using Linux

Lesson Objectives

In this lesson, you will:

Explain how to acquire Linux. List some uses for which Linux is well suited.

Introduction:- You can acquire Linux from many sources. You can buy various boxed Linux distributions directly from vendors' Web sites, online software distributors, and probably even from your local computer store. Linux is shipped on one or more CDs, so you'll need a CD-ROM drive to install it on your computer.

Alternatively, you can download the entire Linux distribution directly from an FTP site or a Web site. Most Linux distributions available for download are stored on FTP servers in a several-levels-deep directory structure, rather than as a single, large, compressed file. The complete set of files will take up a large amount of storage so you should be prepared for a big download. The best way to download Linux is to use a good FTP program that is able to automatically download a directory and all of the subdirectories it contains, and will make multiple attempts to download files in the event that there is a lapse in the communication channel.

Also, if you choose to use this route, you'll need to have a place to store the files. If the hard disk drive on your Linux computer is large enough, you can make a small partition on that drive (using MS-DOS, for example) to store the installation files.

You can also store the files on a network drive. If you have a CD-RW drive, you can burn your own installation CD(s) once you have downloaded the files.

Uses for Linux:- Like other operating systems, there are many different ways that Linux can be used. Linux has many features and capabilities that make it an excellent operating system for end users, but it can also function as a capable server operating system. Some of the many potential uses for Linux include:

TIP:-Linux can be used as both a desktop operating system (for end users) and a server operating system.

Potential uses of linux Web Site Server Domain name server, Router or Internet Gateway Database Server Software development Platform Parallel processing Learning Environment

7

Page 8: HISTORY AND DEVELOPMENT OF LINUX22

Uses for Linux.

Before you install Linux, you should determine the purpose for which the system will be used. You can customize it so that only the applications and services you require are installed. This can be critical in some environments so that if a hacker did get a hold of a system, there wouldn't be unused services that they could exploit. For example, if you are creating a database server, you might not need gateway services enabled on that system. Many distributions have pre-configured sets of programs or services that are installed as a set. You can further customize these or pick your own set of applications and services to install. The same advice goes for workstations; install only the applications you will be using. You can always install other applications or services later if you find that you need them.

TIP: You should determine what software and services should be installed before installing Linux. If possible, install only client applications on workstations and on servers, install only the server services for the task(s) to be carried out on that server.

Web Site Server:-By most accounts, Linux makes an excellent Web site server. Although other options are available, the most popular Web site software for Linux is Apache, a free application (of course) that is available through GNU, and is included with Linux distributions. Apache supports the most needed features in Web servers, including support for HTTP 1.1, image maps, proxy service, multithreading, many security features, CGI, and many others. Linux-based Web servers benefit from Linux's solid dependability and performance. Linux administrators benefit from a large community on the Internet that provides extensive and timely feedback on various issues including security and performance.

Domain Name Server, Router, or Internet Gateway:-In addition to being an Internet (or intranet) destination, Linux can also serve as a way to help users get to other destinations. Linux can function as a domain name server or Internet router (also known as a gateway). In fact, a single Linux computer could perform all of these functions at the same time.

Database Server:-Free database server software has been developed for Linux. Because of Linux's increasing acceptance by IT departments, many companies are porting their commercial database server applications to Linux, including Informix, Sybase, Oracle, InterBase, Ingres II, and others.

Software Development Platform:-Linux can provide a good platform for software developers. Not only is the system stable because of its GNU heritage, many development tools and utilities are freely available for Linux as well. Linux is well suited for development of Web pages and Web applications. The GIMP graphics editor, which is well suited for developing Web graphics, is included with Linux distributions. Various editing and development tools are also available for HTML, JavaScript, and Java.

Parallel Processing:-Linux has been used as the operating system in projects that use clusters of Linux computers to perform parallel processing. In this configuration, the computers work together to perform computations, with a collective processing capability that matches or exceeds that of supercomputers, at a lower cost than a supercomputer. (To view photographs of some example clusters, point your Web browser to http://yara.ecn.purdue.edu/~pplinux/Sites/.)

8

Page 9: HISTORY AND DEVELOPMENT OF LINUX22

Learning Environment:-For individuals wishing to learn Unix, Linux provides a low-cost way to set up a fully functional UNIX-like system on an inexpensive or older system. For schools on a tight budget, Linux provides an affordable way to equip a classroom with a modern operating system. Linux can run on a wide variety of computers, including Macintoshes, Sparc workstations, and IBM-compatible computers (the kind that can run Microsoft Windows) down to old computers with 80486 processors.

Linux runs most software written for Unix systems, such as SCO Unix 4.2 and System V Release 4 (SVR4). In addition to software written specifically for Linux or Unix, Linux can also run many programs written for Microsoft Windows or MS-DOS, using free emulation software.

Embedded Systems and Appliances:-The very nature of Linux lends itself to use within an appliance or embedded system. It has been used in a Linux wristwatch from IBM, in PDAs and cell phones, and TV set-top boxes. It has also been embedded in systems such as firewalls, robots, and telephony equipment to name just a few of its implementations.

Being free and open source, Linux can be modified to suit the needs of the embedded systems and appliance markets. Linux has a small footprint to begin with, and versions specifically designed for this market have been developed.

Q1. How can Linux be acquired?

Ans It can be purchased from vendors' Web sites, online software distributors, and local vendors, or it can be downloaded from an FTP site or a Web site.

Q2. What are some possible uses for which Linux is well suited?

Ans Web site server, database server, mail server, domain name server, router or Internet gateway, software development platform, parallel processing, and learning environment.

Lesson 4 Examining Linux Distributions

Lesson Objective

In this lesson, you will:

Define the LSB.

Introduction:-At last check, there were over 180 different Linux distributions. Even with all of these various versions of Linux, they are all very similar. This is because the kernel is the same for all of Linux. The kernel is the portion of Linux that interfaces directly with the hardware.

The Linux Standard Base (LSB) is an organization that is attempting to standardize Linux even more than it already is without being so restrictive as to limit what each distribution can offer. Their mission statement is:

The goal of the Linux Standard Base (LSB) is to develop and promote a set of standards that will increase compatibility among Linux distributions and enable software applications to run on any compliant Linux system. In addition, the LSB will help coordinate efforts to recruit software vendors to port and write products for Linux.

The LSB Web site also includes a test suite for testing Linux distributions against their standards. The test suite is still undergoing changes and updates, so most distributions currently don't pass all of the tests, but it gives you an idea of how close you are. You can then analyze the results to see if any of the failed tests make a difference to you.

POPULAR DISTRIBUTION OF LINUX:Caldera inc.

Coral Corporation The Debian Project

Linux for Power PC

9

Page 10: HISTORY AND DEVELOPMENT OF LINUX22

MandrakeSoft

TurboLinux inc

Red Hat Software

Slackware

SuSE GmbH

VA Linux

Comparing Distributions and their Packaging Solutions:-As similar as each of the Linux distributions are to each other, they each have their strengths and weaknesses as well. For example, Red Hat has worked hard on making the installation as painless as possible. Other distributions still require you to make a lot of manual choices and to know your equipment intimately in order to successfully install.

The software packaged with each distribution can make a huge difference in how Linux works for you. Although you can always download or purchase the missing components that you want, it is easier to use if the components have already been tested and compiled together to work with your distribution.

There are several methods of installing packages. Let's look at three of them.

The most manual method is to use the dselect utility. Those distributions based on Red Hat Linux use RPM (Red Hat Package Manager).

Those distributions based on Debian Linux use DEB Package Manager. Debian has created an advanced front-end interface to the dpkg package manager named APT. It provides the apt-get utility and APT dselect method provides a simpler, safer way to install and upgrade packages.

Q1. What is the LSB?

Ans The LSB, or Linux Standard Base, is an organization that is attempting to standardize Linux without being so restrictive as to limit what distributions can offer.

CHAPTER 2 SYSTEM ACCESS

Lesson1 Logging In and Using the Linux System

Lesson Objectives

In this lesson, you will:

Define the home directory. Define a shell.

Introduction:-UNIX operating systems and derivative systems such as Linux are designed to serve many users at the same time. On a multi-user system such as Linux, you can use a terminal to gain access to the system. In our case, our Linux system and our terminal are one and the same machine. You can also connect to a remote computer using communications links such as modems and local area networks (LANs).

Each user gains access to the system by specifying an account name or a login name, and by providing the appropriate password. Before you log in to the system, you will need several pieces of information. These include:

Name of the computer that u r accessing if there r several system to which u have access. The logging name for ur account

10

Page 11: HISTORY AND DEVELOPMENT OF LINUX22

The password assigned for ur logging name

When your system comes up, a login prompt similar to that shown in the figure below is displayed. After you enter your user login name, a password prompt is displayed. Enter your password, and you will be presented with your last login time and device and a shell prompt.

The Linux login prompt.

The Shell Prompt:-When you have successfully logged in, you are placed in your home directory and a prompt is displayed. The prompt is displayed on the screen by the shell, a program that interprets each command line you type. The shell accepts your commands, interprets what you type, and sees that your commands are carried out by the kernel. The shell prompt means that the shell is waiting for you to type a command.

TIP: You can change what is displayed when you log in. You can also configure your system to immediately launch X Windows upon login.

If you are logged in as root, the default shell prompt is a pound sign (#). Regular users see a dollar sign prompt ($).

Accessing a Command Prompt:- Some Linux systems are configured so that you boot directly to a graphical interface. If this is the case on your system, you can still get to a command prompt. To do this:

Accessing a Command Prompt

From within the Environment, CRTL+ALT+BACKSPACE to exit or from the main menu, choose Logout, then choose the logout option and click on OK.

If u return the Graphical login, Click on Shutdown and choose Console mode, if u have returned to the text Windows press CRTL+C to access the login Prompt.

If u login prompt isn’t display press Enter or CRTL+C

If you are still returned to a GUI login screen, choose Session->Failsafe, and then at the GUI login, log in as root. Open a terminal window, and then enter init 3. This will restart your session in command prompt mode. To permanently change to command prompt mode, edit the inittab file.

SHELL:-The shell is the component that interacts directly with the user, functioning as the command interpreter for the Linux system. The shell accepts user commands and makes sure that the kernel carries them out. The shell also contains an interpretive programming language.

11

Page 12: HISTORY AND DEVELOPMENT OF LINUX22

Linux user shells.

There are many different shells, but some commonly used shells are described in the following table:

SHELL

Shell Open With Description Bash bash This is the default Linux Shell. It is located in the /(Backlash) bin/bash directory. It provides

the flexibility of the C Shell in a bourn Shell type environment. Bash stands for Bourn again shell. The default Prompt is $(sign)

Bourne sh This is the original Unix Shell developed by Steve Bourne at Bell Labs & is availably on all Linux System. The default Prompt is $(sign)

C Shell csh This was developed by BILL JOY at BERKELY & was designed to support C language development environment. It is also designes for more interactive use, providing several ways to reduce the amount by typing needed to complete a job. It includes command editing, history and aliasing. The default prompt is $(sign).

Korn ksh This Shell is a combination of the C and Bourne shells. It uses the features of the C Shell But the syntax of the Bourne Shell.

TIP: If you are logged in as root, the default shell prompt will be #.

You can have several shells open at once with different processes or programs running in each shell. You can use the ps command to display the processes in the process table started from your login shell. The process table is a system-wide table containing entries for all of the processes started by any of the users on the system. Use the ps command to see how many shells you have open.

You can determine which shell is established at login by entering echo $SHELL. $SHELL is the environmental variable name holding the name of your shell. The echo command prints what follows the command to the screen. For example, by default, Linux is set to the bash shell, so the results of entering echo $SHELL would be /bin/bash.

Q1. What is the home directory?

Ans: The home directory is the directory you are placed in by default when you log in. This directory holds the files that define how your login session is configured as well as your personal files.

Q2. What is the shell?

Ans: The shell is the Linux component that interacts directly with the user, functioning as the command interpreter for the operating system.

12

Page 13: HISTORY AND DEVELOPMENT OF LINUX22

Lesson 2 Entering Commands

Lesson Objectives

In this lesson, you will:

Explain the importance of case when using Linux commands. Define an argument.

Introduction:-At the Linux shell command prompt, you can enter commands. The shell provides a command-line, or text-based, user interface. This means that you use the keyboard to enter a command that appears on the screen as text. The shell responds by performing a specific action that is associated with that command. The shell also responds to some commands by displaying a message to indicate the progress or outcome of the command.

Linux is case-sensitive, so you must enter commands in the case required. Most commands are written in lower case, but some commands (especially those associated with X Windows) use mixed case or all upper case.

TIP: UNIX and Linux are case sensitive, so if your command is not working, make sure you are using the correct case.

Instructions are issued by entering commands at the console prompt. All commands typed to the shell have a similar format. A command line consists of a sequence of words, each separated by one or more spaces. The first word is the command itself, which is the name of the utility or user program to be executed, and which tells the shell what to do. In some cases, the command is all you need to enter; however, usually you also need to give the command additional information. The remaining words are command options and arguments. An option controls how the command is to be performed. An argument, usually a filename or directory name, indicates on which files the command will operate.

The generic format for UNIX commands is:

command -option argument

For example, the command cal can be used by itself to display the current month's calendar. Options for the cal command include -m (to display Monday as the first day of the week), -j (to display Julian dates), or -y (to display the current year's calendar). You can also specify arguments for this command, such as month or year, or both.

Command Syntax:-Many UNIX reference manuals summarize how commands can be used and provide syntax statements. Syntax statements show various options that can be used with commands and the sequence in which those options should appear. These can be displayed using the man, or manual page, command.

Basic Linux Commands:-Now that you know a little about how Linux commands are structured, you are probably anxious to find out what some of those commands might be! The following table lists some of the basic commands you'll be using in your Linux life.

Command Options Arguments Description

cal -m, -j, -y month, year Displays a calendar.

clear     This command takes no options or arguments; it clears the screen.

date -u -date'datestring' Without any options or arguments, it displays the current date and time. The -u option shows UTC time. The -date'datestring' argument displays the date based on a datestring, such as two days ago.

ls -ls, -l, -la, -R, -F

file or directory Lists the contents of a directory. When used with the proper options, it also displays rights information and whether the entry is a file or directory.

who -q, am i   Displays a list of who is logged in. The -q option overrides all other options,

13

Page 14: HISTORY AND DEVELOPMENT OF LINUX22

displaying only the number of users logged in. The am i option lists only information about your own login account.

TIP: The clear command is like the DOS cls command.

Issuing More Than One Command: -You can issue more than one command before pressing Enter. Place a semicolon (;) between the commands and they will be issued one after the other.

Piping Commands:-You can send or redirect the results of one command to another command. Pipes are used to combine Linux tools on a single command line, enabling you to use the output of one command as the input to another. The pipe symbol is a vertical bar (|), which you type between two commands. For example, ls|more enables you to look at a large directory listing one screen at a time.

History and Tab-Completion Features:_So far, the commands you have entered are short and succinct. However, filenames, paths to files, and combining commands can result in quite long strings to enter. Two features you might find useful in entering commands are the history feature and the tab-completion feature.

The History Feature:-Sometimes, commands can become quite long. What if you mis-entered the command and had to type the whole thing in again? You can use the history feature to access previously entered commands. The commands you have entered are stored in the history file. The location of the history file is defined in the HISTFILE environmental variable. By default, this is .bash history in your home directory. The following table describes how to use the history feature.

Press or Enter To

Up Arrow Move back through the commands to the History file.

!! Run the last command in History

!# Run command Number from history file

!string Run most recent command from history file containing String.

The Tab-Completion Feature:-Some commands have long names containing version number information or other weird spellings or capitalization. This can make it difficult to correctly enter the commands the first try. You can use the tab-completion feature to enter the command. To do this, enter the first few characters of the command, and then press Tab. If there is only one match, the rest of the filename is displayed. On some distributions, if there are multiple files that might match, they are all displayed; however, most distributions complete the command to the last common character, and then beep. If you press the next letter of the filename you want, and press Tab again, Linux will complete the rest of the filename. If it still can't differentiate between the commands, it will beep again, and you will need to enter additional characters.

Q1. Is Linux case-sensitive?

Ans UNIX and Linux are case-sensitive, so commands must be entered in the case required.

Q2. What is an argument?

Ans An argument, usually a filename or directory name, indicates on which files the command will operate.

Lesson 3 Getting Help

Lesson Objectives

14

Page 15: HISTORY AND DEVELOPMENT OF LINUX22

In this lesson, you will:

Explain what the man command does. Define a LUG.

Introduction:-You can find the command syntax for all of the commands on your system by using the command man. The man command prints the UNIX reference manual page specified by the argument. For example, to get help on the cal command, enter man cal.

If a man entry is longer than one screen of information, press the Spacebar to scroll the information forward one full screen; to move forward one line at a time, press the Enter key. To exit from the description, type q.

The man command uses many different options. To see all of them, enter man man. A couple of popular options are -f and -k.

To display a one-line description of the command specified in the argument, enter man -f argument, where argument is the command you are getting help on. To display one-line summaries of all of the commands whose man pages contain the keyword in the argument, enter man -k argument.

Additional Help Systems:-Linux includes other help systems besides the man pages. This includes the --help option, which can be used with many commands to display a quick summary of the usage of the command.

HOWTO documents might be installed on your system. These documents can be viewed with a text editor or piped through more or less. These are usually installed under the /usr/share/doc directory. The html version of the files can be displayed in any Web browser, including the text-based Lynx browser. The text files can be viewed through any text editor or by using the display commands such as cat, more, or less. Many HOWTOs can be found on most systems.

Linux HOWTOs are documents that describe, in detail, a certain aspect of configuring or using Linux. HOWTOs are comprehensive documents, much like an FAQ, but generally not in question-and-answer format. However, many HOWTOs contain an FAQ section at the end. There are several HOWTO formats available: plain text, PostScript, PDF, and HTML. In addition to the HOWTOs, there is a multitude of mini-HOWTOs on short, specific subjects.

Texinfo might also be available on your system. This can be viewed through the emacs editor. Commands are listed with an asterisk before them; placing the cursor on the word and pressing the Enter key accesses the link to the command description. These are also referred to as info pages and can be displayed using the info command.

Enter info followed by the command name you want information about. This displays online documentation built from the texinfo input.

Other Help Sources:-Other help sources include Web sites devoted to specific distributions, to Linux in general, from periodicals and other sites. Another good source of information is Linux User Groups or LUGs. These can be virtual, based on the Web, or there might be a group of people that meet in your neighborhood. The virtual ones sometimes take the form of a list server with a question and answer database or a newsgroup.

In addition, there are always traditional resources such as books, training classes, and other users. These can often be combined with other resources such as using the Web and online sources to round out your Linux education.

Getting Help with Info Pages:To display the info pages, enter info with or without options and arguments. By itself, info will display the help file for how to work with info. Entering info topic will display the info page for the specified topic. The command info --help displays a brief help description.

When the info page is displayed, any text with an asterisk (*) in front of it is a link. Move your cursor (using the arrow keys) to the text, and then press the Enter key to access the linked info page. To return to the previous document, press u; press d to return to the top. Press q to exit back to the command prompt.

Q1. What does the man command do?

15

Page 16: HISTORY AND DEVELOPMENT OF LINUX22

Ans The man command prints the UNIX reference manual page specified by the argument.

Q2. What is a LUG?Ans LUG stands for Linux User Groups. It is a group of people who get together either electronically or physically to share information about Linux and related topics.

Lesson4 Obtaining Information About Your System

Lesson Objectives

In this lesson, you will:

Explain how to open a second shell in Linux. Explain how to log out of Linux.

Introduction:-There are a number of commands you can use to determine your user name, your system name, and the device name of the terminal you are using. Generally, you will know the status of all of these components. But, if you are using a different terminal, sharing your terminal with others, or working remotely over a network, you might attempt to access your files only to find them missing or replaced by a directory structure belonging to another user. This is when you need to identify some signposts on your system roadmap, and determine what you need to do to get back to normal operating status. TIP:If you are getting help with a problem on your system, you will probably be asked to run this command at some point to get information about your system. This information can be useful in helping to track down the solution to problems.

The uname Command:-By default, uname displays the system name, or the particular implementation of the operating system. The following table lists some of the options.

USER COMMANDSUMANE OPTION DISPLAYS-n The node name of ur system. The node name differ from the

system computer name if the computer is a server on a network-r The operating system release number.-v The version release number-m The type of CPU the computer uses-p The type of computer u r using-a All of the above information at onceOpening and Closing Additional Shells:-You can have several shells open at the same time. You can run different processes in different shells so that you can have multiple processes running.

To open a second bash shell, enter bash at the command prompt. To open a C shell, enter csh. To close the shell, either enter exit or press Ctrl+D.

Logging Out:-When you are finished using your system, you should log out. This prevents unauthorized users from walking up to your system and entering commands.

There are several ways to accomplish this on your Linux system. You can enter exit, logout, or press Ctrl+D.

If you enter exit, you remove the shell from which you issue the command. If you press Ctrl+D, you send an end-of-file character to the shell from which it is issued, terminating that particular shell. For our purposes, they both do the same thing-they close the shell. If you issue either of these commands from your login shell, it will log you out.

If you are in your login shell, you can also enter logout. The other two logout methods will close whatever shell you have open and return you to the parent shell. The logout command works only in the login shell.

Virtual Terminals

16

Page 17: HISTORY AND DEVELOPMENT OF LINUX22

Note: Linux, being a multi-user system, accepts multiple terminals for access. However, it is unlikely that you will have multiple terminals connected to your system. Linux has virtual terminals to allow you to log in on multiple consoles using the same keyboard and monitor for each session.

You can log in to your system multiple times through virtual terminals. Each of these terminals is identified as a different tty device to the system. To access the first virtual terminal, press Alt+F1, the second Alt+F2, and so on. This can be extremely handy in that if you have a process that will take a long time to complete running on one terminal, you can log in on another terminal to continue working. You can log in as the same user or as a different user.

The tty Command:-The tty command enables you to display the device name or filename of your terminal, and the path to the directory where the file is stored. Generally, devices are stored in the /dev directory. The device number of the computer can help you to determine its physical location. This command is useful for determining if you have somehow opened an additional virtual terminal (either on purpose or accidentally), and to determine which virtual terminal you are using.

Q1. How do you open a second shell in Linux?Ans: To open a second bash shell, enter bash at the command prompt. To open a C shell, enter csh.Q2. How do you log out of Linux?Ans: There are several ways to log out of the Linux system. You can enter exit, logout, or press Ctrl+D.

Lesson 5 Logging In and Using Remote Linux Systems

Lesson Objectives

In this lesson, you will:

Explain a remote login. Define telnet.

Introduction:-Your server supports TCP/IP networking and has an assigned IP address and hostname. If your server is on a network, you may also have a domain name. The fully qualified domain name (FQDN) consists of the combined hostname and domain name of your server. For example, if your hostname is vagus and your domain name is logicept.com, the FQDN of your server is vagus.logicept.com. The FQDN is often used to access a system from another network. You may also use the IP address to access a system remotely.

Remote Logins:-To log in to a remote system, you used to have to use rlogin, which sent user name and password information as clear text. This could easily be picked up on the network and used by unauthorized persons. However, on some systems, this might be the only way to connect if other utilities haven't been installed. There is a set of remote console utilities that go with rlogin including rcp (remote copy), rsh (remote shell), and rsysinfo (remote system information).

A more secure remote login method was required. The secure shell remote login was developed to meet this need. The login command is ssh. The secure remote copy command is scp. When you are using a secure shell, you need to use the scp command to perform secure remote copy.

Secure shell uses TCP/IP connections. Secure shell uses public key encryption rather than sending clear text. The first time you log in to the remote server, public key information is exchanged and you are prompted whether to continue. After you enter yes, you are prompted for the user's password to finish logging in.

You need to have an account on each remote server that you log in to. Each user is set up separately. It can be cumbersome to remember all of the user name and password combinations for each system. Directory Services are available to enable a single login for access to all resources on the network to which you have permission to access.

Using Telnet:-Another remote connection method is the use of telnet. This is another insecure method of connecting to remote systems, and one of the most basic. You need to know a user name and password on the remote system in order to connect to it. You can also use telnet from a remote system to log in to your own system. This way, you can access files, check email, and run programs located on your system. The communication is not encrypted (as it is in secure shell connections), so be aware of this as you access information on remote systems; other users, including hackers, can gather private information such as user IDs and passwords. However, sometimes you might need to use telnet.

17

Page 18: HISTORY AND DEVELOPMENT OF LINUX22

Using FTP:-Before the advent of the World Wide Web (WWW) and its underlying protocol, HTTP, FTP was the primary means of transferring files across the Internet. There are many command-line and graphical FTP clients available for a wide variety of systems.

The get and put Commands

To download a file, use the get command. To upload a file, use the put command. To download multiple files, you can use the mget command, and to upload multiple files, you can use the mput command.

Binary and ASCII File Transfer

The FTP protocol defaults to ASCII file transfers, which may result in file corruption if a binary file is transferred in this mode. Because of this, you should always set the file type to binary prior to transferring all non-text files. This can be most easily accomplished via the binary command, and set back to ASCII with the ascii command.

Authenticated FTP Access:-Sometimes, FTP serves are set up so that they require you to log in using a valid user name and password in order to upload or download files. This is configured through the ftpaccess file.

FTP Security Concerns

FTP, like a lot of older services, was developed for open file transfer environments; therefore, security was never a great concern in its development. Basic security features such as support for major authentication protocols, encrypted data transmission, and security structures are lacking in the protocol. Be aware of these limitations if you implement FTP, and if you need server security, implement something such as ssh.

Follow the steps below to learn how to use FTP server and remote systems. Log into your system. Enter ftp ftp.redhat.com to connect to the redhat.com FTP server anonymously.

When prompted for a user name, enter anonymous.

When prompted for a password, enter your email address. You can enter anything as long as the format is [email protected].

Enter cd /pub/redhat/linux/updates/7.0/en/os/i386.

Enter ls to view the files and directories available via this FTP server. You can change directories using the cd command. Record the name of a file in the directory. You will download this file in a minute.

Enter binary to set the download to binary mode. This will keep the file in machine code rather than transferring it as ASCII.

Enter getfilename where filename is the filename you recorded above. This will download a file from the server. Similarly, put filename will upload a file from the local system to the server (if the server directory allows write access).

Enter quit to end your FTP session.

Enter ftp nameofyourserver to connect to the FTP server.

Enter the user and password when prompted.

Upload the file you downloaded in the previous step from your home directory using the put command. (HINT: Enter put filename.) Because you are authenticated to the server and have read/write

18

Page 19: HISTORY AND DEVELOPMENT OF LINUX22

permissions to your home directory, you should also be able to upload files. Remember to switch to binary mode if the file you are uploading is not a text file.

Access the files as you would an anonymous FTP server and check that you can download files. You can download the same file again.

Verify that the files transferred properly. You can use the ls command to list the files in the FTP directory and in your local home directory.

Enter exit to disconnect from the FTP server.

Q1. What is remote login?

Ans: Remote login is a method of logging in to another Linux or UNIX system using commands such as rlogin or ssh.

2. What is telnet?

Ans Telnet is the Internet protocol standard for remote login.

CHAPTER 3 Starting and Stopping Linux

Lesson 1 Shutting Down a Linux System

Lesson Objectives

In this lesson, you will:

Define a runlevel. Describe the command to immediately shut down your Linux system.

Introduction:-You must take specific steps before turning off a Linux system. Otherwise, if you just press the power switch, there is a good chance you will corrupt your filesystem. Filesystems are synchronized during shutdown, and if this is not allowed to happen, that is when problems can occur.

The shutdown Command:-The shutdown command is used to gracefully take your system down. The command is located in the /sbin directory. It warns all users that the system is going down and no one can log in after the command is issued.TIP:If you are the only user on your system, you can also use the halt or reboot commands. However, it is recommended that you get in the habit of using shutdown so that when you are on a multi-user system, you can warn others that you are bringing the system down.Init Runlevels:-As the init man page says, "Init is the parent of all processes." It creates processes at system boot time from a script in the /etc/inittab file. Init is used to set the runlevel of your system. The runlevel specifies which group of processes can exist. The following table describes the processes that can run at each init level. You can change the init level by using telinit.

INIT LEVELS INIT LEVEL DESCRIPTION 0 Halt the system1 Single User mode2 Multi-user mode, without NTFS3 Full multi-user mode4 Not used5 Used for X11 (XWINDOW)6 Reboots the systemS or s Single user mode; it doesn’t require any etc/inittab file

19

Page 20: HISTORY AND DEVELOPMENT OF LINUX22

Restarting the System:-When you need to restart your Linux system, you should use the shutdown command with the appropriate options. The syntax of the shutdown command is shutdown [-t seconds] [-options] time [warning message]. The -t option specifies how many seconds to wait before changing to another runlevel. The options parameters are listed in the following table. OPTION PARAMETEROPTION USED TO-k Send wring message to everyone, but doesn’t really shutdown

-r Reboot the system during shutdown, Upon reboot, If u are using the Boot manager to load various operating system, u can switch to another operating system come back up into Linux

-h Halt the system after shutdown. At this point u can turn off the power-n Perform the shutdown and not have shutdown call init.It is recommended that u do not use this option-f Skip the filesystem check on reboot-F Force the filesystem check on reboot-c Cancel a shutdown in progress. This option does not use the time parameter, But can use the warning message

option

The time parameter of the shutdown command specifies when to perform the shutdown. This option is required. You can specify an absolute time (hh:mm); specify how many minutes to wait before shutdown (+m); or specify that shutdown occur immediately (now).

The warning message is text that is sent to all users. It might include messages such as "You must save all files right now because the system is going down for maintenance in 5 minutes."

Halting the System:-When you are done using your Linux system, you can either leave it up and running and just log out, or you can power it down. But before you can power it down, remember to perform the appropriate shutdown commands.Q1.What is a runlevel?Ans: A runlevel is a setting that specifies which group of processes runs on your system.Q2. What is the command to shut down your Linux system immediately?Ans: shutdown -r now

Lesson 2 Booting a Linux System

Lesson Objectives

In this lesson, you will:

Define LILO. List the name of the configuration file used by LILO.

Introduction:-When Linux was installed on your system, another operating system might already have been installed. To have the option of accessing this operating system or Linux, during Linux installation you can install the LILO boot loader software. LILO stands for Linux Loader. By default, it is installed in the master boot sector of your hard disk. It enables you to boot to either DOS/Windows or Linux. You can also configure it to boot to other environments.

LILO is a versatile boot loader for Linux. It does not depend on a specific file system. It can boot Linux kernel images from floppy disks and hard disks, and can even boot other operating systems. One of up to sixteen different images can be selected at boot time. Various parameters, such as the root device, can be set independently for each kernel. LILO can even be used as the master boot record. The master boot record is the first sector of your hard disk. The computer's BIOS looks at the master boot record for instructions on how to load an operating system. If you just had Windows 95 or DOS installed, it would contain instructions to load only that one operating system. As stated above, LILO you the versatility to load more then one operating system. You can configure LILO by manually editing the lilo.conf file.

LILO:-Settings for LILO are saved in the /etc/lilo.conf file. When you boot your system, LILO uses the information in this file to determine how to boot your system.

20

Page 21: HISTORY AND DEVELOPMENT OF LINUX22

The figure below contains a sample lilo.conf file. The table following the figure describes each component of the file. Lines 1 through 5 in the figure specify global options; lines 6 through 10 specify options for the Linux image; and lines 11 through 13 specify options for loading DOS.

A sample lilo.conf file.

TIP:You can also install LILO to boot from a floppy disk.

Line Number

Description

1 Specifies that LILO uses the master boot record on the first hard drive in the system (/dev/hda).

2 Specifies the default map file.

3 Installs the default file as the new boot sector.

4 Enters the boot prompt without any keystrokes.

5 Specifies wait time for you to choose an image to load (measured in tenths of a second). If no choice is made, the first image listed in the file is automatically loaded.

6 Indicates the file containing the Linux kernel boot image.

7 Used to refer to and load image specified in line 6.

8 Specifies the device to be mounted as root.

9 Initializes the RAM disk.

10 Mounts the system as read only; then after the filesystem check is completed during boot, remounts the filesystem as read-write.

11 Specifies a non-Linux operating system to be booted.

12 Defines the label by which this operating system is to be called to boot.

13 Specifies the device containing the partition table for the operating system being booted.

21

Page 22: HISTORY AND DEVELOPMENT OF LINUX22

Configuring LILO:-You can configure how LILO works with the lilo Linux command. Issuing the command without any options writes the changes to the master boot record. Some of the lilo command options are described in the following table. For details on the rest of the options, refer to the LILO man pages.

LILO Command Option:

OPTION DESCRIPTION-R Set the default command line for the next reboot. (Use changes from the Linux booting by default to DOS

Booting).This is a One-Time only setting that reset after u reboot.-t Test, But Don’t write a new boot sector or map file.-v Increase Verbosity(Show more detailed messages).LILO version

TIP: Combine the -t and -v options to determine what LILO is set to do.

You can also directly edit the /etc/lilo.conf file. You can:

Specify the default boot image by using the default variable. Add the following line to the file to specify that the system will boot to DOS:

Default= DOS

Change the delay time before the system boots using the default boot image using the delay variable. This value is expressed in deciseconds, so the value 50 would be 5 seconds.

Rename the labels by which boot images are referred to. For example, dos is assigned as the label for the DOS or Windows side of the system, so you might want to change this label to Windows 2000 if that is what is installed on your system.

Follow the step bellow to learn about LILO options

1. Power up your system.2. When the LILO prompt appears, press the Tab key, and then press Ctrl+X. This will

display a list of all labels defined in the lilo.conf file.

3. At the LILO boot prompt, select linux.

4. Log in as root.

5. Enter cat/etc/lilo.conf to display the contents of the lilo.conf file.

6. Identify what each line in your lilo.conf file does.

7. Enter lilo -t -v to determine what LILO will do the next time you reboot.

Booting to the DOS/Windows Environment:-When you perform a Linux installation, and you already have DOS or Windows installed, most distributions prompt you to install LILO. LILO adds the option to boot to either Linux or DOS. Linux will be the default unless you change it.

To boot to DOS, select dos from the LILO boot menu. If, instead of a list of environments to boot to, you are presented with a lilo prompt, press the Tab key or Spacebar to display the list of labels for the operating systems to which you can boot, and then enter the label to which you want to boot.

TIP:Some distributions list DOS and some list Windows. These both refer to the Microsoft side of your system.

22

Page 23: HISTORY AND DEVELOPMENT OF LINUX22

Booting to the Linux Environment: - Red Hat Linux uses the System V init boot process. The kernel runs init at startup and so init is the first process (with a process ID of 1). This makes it the parent process of all other running processes on the system. When Linux boots, it goes through the following steps:

Booting to Linux

Follow the steps below to learn how to boot to the DOS and Linux environments.1. Enter shutdown -r now to reboot your system.2. At the LILO boot prompt, select dos, and then press the Enter key. If the Windows

Log In dialog box is displayed, press the Esc key to skip by it. On some systems, this might be labeled windows or something else besides dos; if so, select or enter the name shown. This time, you are specifying that the system should boot to the DOS/Windows environment.

3. Choose Start >Shutdown. Select Restart, and then click on OK to restart your� system.

4. At the LILO boot prompt, select linux.

Messages displayed during startup are written to the system log /var/log/messages. It lists the status of each process that is started.

Q1. What is LILO?Ans: Linux Loader. It is used to specify the operating system environment to boot to.Q2. What is the name of the configuration file used by LILO?Ans: /etc/lilo.conf

Lesson 3 Other Boot Methods

Lesson Objectives

In this lesson, you will:

Define a loadlin bootloader. Describe the key difference between loadlin and LILO.

Overview:-The loadlin bootloader provides an alternative to LILO for users with hardware configurations incompatible with LILO. Loadlin is also popular among users whose primary operating system is DOS/Windows. Loadlin, like LILO, loads the Linux kernel into memory and begins the system boot process. Unlike LILO, Loadlin is a DOS application program that requires

23

Page 24: HISTORY AND DEVELOPMENT OF LINUX22

that the user first boot into DOS (or Windows) to run Linux. Loadlin starts a "logical reload" of your system, causing DOS to be completely overlaid with the Linux operating system. Loadlin is fairly simple to install and configure on a DOS or Windows system.

A rescue disk was created during the installation process that can be used to boot the system in the event that the system kernel becomes unbootable. The kernel may become unbootable due to changes in hardware or problems in the recompiling or configuration of the kernel or kernel modules.

Third party programs such as System Commander can also be used as a boot manager. This utility also enables you to control which environment you boot into similar to how LILO or loadlin do.

Boot Methods

Q1. List some alternative boot methods for booting your Linux system.

Ans: System Commander, LILO, loadlin, and a rescue disk.

Q2. Have you used any of these methods to boot your system? If so, why did you choose it and how does it work for you?

Ans: Answers will vary.

Q3. Have you used any other boot loaders with Linux? If so, what are they?

Ans : Answers will vary.

Lesson Wrap-up

Q1. What is a loadlin bootloader?

Ans: It is an alternative bootloader to the LILO bootloader.

Q2. What is a key difference between loadlin and LILO?

Ans : Unlike LILO, loadlin is a DOS application that requires the user to first boot into DOS to run Linux. It then starts a logical reload of the system to be overlaid with the Linux operating system.

CHAPTER 4 USER ACCOUNT

Lesson 1 Creating Additional User Accounts

Creating Additional User Accounts

Lesson Objectives

In this lesson, you will:

List some ways to add a new user. Explain if root and regular users can add new users to the system.

24

Page 25: HISTORY AND DEVELOPMENT OF LINUX22

Introduction:-There are times when you will have to be root (such as when adding users to the system). Reserve your use of the root account for those times when you must be root, do what you need to do, and then log out. The rest of the time, for safety's sake, log in as a regular user. You should log in as this other user to do most of your work.

Just because you are using your Linux system as a workstation doesn't mean that you shouldn't have other user accounts. If multiple people are using this system, they should each have their own user account. This allows you to track what they each do, and to more easily provide separate space for their files.

The Role of root:-Every UNIX or Linux system has at least one system administrator whose job it is to maintain the system and make it available to its users. This user is root. You can also create other accounts for other users to help the root user carry out system administration duties. System administrators are also responsible for adding new users to the system and for setting up their initial environment.

The /etc/passwd and /etc/shadow Files:-When you add a new user, the information about that user is saved in the /etc/passwd file. Always make a backup copy of this file before editing it!

The figure below contains an example of this file. Notice that a colon separates each field of a record. Each field is always present even if it is empty.

FIELDS/etc/passwd Field DescriptionUsername This is the name under which the user will log in. In general, limit these to eight alphanumeric characters.Password The password assign to the user is store in encrypted from in the file.User Id A unique number assigned to each user. Linux tracks users by User ID rather than user nameGroup ID A unique number assigned to each group. User can member of one or more groups.Full Name The real name of the user. For Example, the user name might be gsandler and the full name would be

Gail SandlerHome Directory Default directory where u r placed when u log inLogin Shell The default Shell that is started when u log in.When you install some distributions, shadow passwords are automatically enabled. Shadow passwords is a feature which moves the encrypted passwords from the /etc/passwd file to the /etc/shadow file. The password field in the passwd file is then replaced with an x.

25

Page 26: HISTORY AND DEVELOPMENT OF LINUX22

A sample /etc/shadow file.Adding a New User:-You can add new users several ways. You can edit the password file; however, this is not recommended because if you accidentally leave something out or mess up existing users, you might trash your system. If things get messed up bad enough, nobody can log in - not even root! In this case, you would most likely have to re-install your system.

It is recommended that you use the useradd command (adduser is a script file that performs the same things as the useradd command). When you enter useradd at the command prompt, you are prompted for information about the user. You can also use linuxconf (or lisa, yast, or other distribution specific interfaces) to add users. This is a form-based command in which you enter values in fields to define the user.

Assigning a Password:-When you create a new user, you should immediately set a password for this user. This will help prevent unauthorized access to your system. To set the password, enter the command passwd username, where username is the name of the user for whom you are setting the password. The same command is used to change your password. (If you are changing your own password, you don't have to specify a user name following the passwd command.)

TIP: Only the root user can use the user name option of the passwd command. Everyone else can set only his or her own password.

TIP: The useradd and adduser commands are interchangeable.

Adding Users with the linuxconf Command:- The linuxconf command is a form-based utility. Through it, you can configure networking, user accounts, filesystems, and boot mode. You can also control features including control panel, control files and systems, logs, date, and time.

The linuxconf command can be run as a command line utility or in the X Window environment. It works the same way in either utility, except that you can use the mouse to expand and collapse categories and to select buttons in the GUI version. In the text version, you have to move around using the arrow keys and the Tab key. Press the Spacebar or the Enter key to select buttons.

Other Form-Based Administration Utilities:-Not all distributions include linuxconf as an administration utility. You can add linuxconf to the distributions, but in most cases, you will also need to add many other supporting (or dependent) programs before you can install it. Many distributions have developed their own specific administration utilities. Let's look at two of these.

26

Page 27: HISTORY AND DEVELOPMENT OF LINUX22

LISA

The Caldera distributions of OpenLinux include a utility named LISA (Linux Installation and System Administration). This includes options for most system administration activities you will encounter. You can see the main menu in the following figure. You can use this to configure network parameters, manage users and groups, analyze the system, and manage packages on the system.

The LISA main menu.

Now that you've seen linuxconf and LISA, let's look at YaST. YaST is the default configuration tool for SuSE.

YaST

The SuSE distribution of Linux includes a utility named YaST (Yet another Setup Tool). As with LISA and other administration tools, you can configure and maintain your Linux installation, manage packages, and perform system administration. The YaST main menu is shown in the following figure. YaST 2 is the current version of this utility.

The YaST main menu.

27

Page 28: HISTORY AND DEVELOPMENT OF LINUX22

TurboUserCfg:-TurboLinux includes separate "turbo" utilities for several administrative functions, whereas linuxconf, YaST, and LISA include several administrative tools in the one utility. One such example is the command turbousercfg, which is used to configure users and groups on your system. It provides an interface to the /etc/passwd file or /etc/groups file.

Comparing Regular and Root Users:-Regular users cannot carry out all commands. By default, root has privileges to all things on the system, but other users don't. For example, regular users can't add new users to the system.

The su Command:-For most of your work, you should be logged in as a regular user, and then just log in as root when you need to do something as root. You do not need to first log out before logging in as root. The su (substitute user) command doesn't change the current directory or open a login shell by default. You can't run all the commands that you might need to run as root if you use the su command by itself without options. In these cases you can use the su - root command to temporarily open a login shell as the root user (you will be prompted for the root password), do what you need to do, and then return to your regular user's shell. You can do this with regular users also.

TIPS:There is a space between su and the � and between the � and the username. su -, su-l, and su --login will also work. The root user is assumed if no user is specified. See man su or info su for more detailed information on the su command.

Managing the /etc/skel Files:-When a user is created, all of the files in the/etc/skel directory are copied to the new user's home directory. These are the skeleton files skeleton files or skel files for the account. By having default files with certain settings, you can configure everyone's environment to be the same. This will make troubleshooting easier if things are consistent among users. Users might change their settings, but at least they started out the same!

By default, the hidden files for configuring a user's environment are stored in this directory. These include .bash_profile, .bashrc, .screenrc, and others.

If there are other files that you would like to be included in new users' accounts, you can add those files to this directory. The files will then be copied to new users' home directories when new users are created.

Q1. What are some ways to add a new user?

Ans: Use the useradd or adduser command, use linuxconf, or edit the /etc/passwdfile.

Q2. Can root and regular users add new users to the system?

Ans Regular users cannot carry out all commands. By default, root has privileges to all things on the system, but other users don't. For example, regular users can't add new users to the system. Root can.

Lesson 2 Creating Groups

Creating Groups

Lesson Objectives

In this lesson, you will:

Define a group. Explain what command is used to create a group.

Introduction:-A group is much like a container of sorts. Groups are designed to collect and hold user accounts that have similar needs for easier system administration. For example, if an HR employee had seven co-workers who also needed to modify sensitive employee information, then it would be a long and difficult task to issue the level of permissions and rights they need to each of them individually. To reduce the workload, it would make more sense for the system administrator to create a group named HR or something similar. The next task would be to put all eight HR employees into this group. Now, when permissions or rights need to be granted on the server, the system admin can just assign them to the HR group. The users, by virtue of their membership in the HR group, would inherit all of the rights and permissions assigned to the HR group. The reduced workload doesn't just end there. Think of a situation where an employee gets hired or leaves the company. In either case, the system admin

28

Page 29: HISTORY AND DEVELOPMENT OF LINUX22

would simply have to add to or remove from the group only the user account in question. In the latter case, removing the user likewise removes the inheritance of the rights and permissions from the group. Note however, that the other group members retain their rights and permissions; the user loses them only because he or she is removed from the group. Adding a new employee to the group also saves time because the user would then inherit the rights and permissions, saving the system admin from having to create those attributes for the user. A good example of this is getting a job. When you are hired you may be eligible for the benefits that the company offers. It would be reasonable to say that you inherit those benefits by virtue of your affiliation with the company group. If you were to leave the company you also, in turn, leave the group and thus, lose the benefits you once inherited. The rest of the employees of the company retain their status unaffected by your change. Managing Groups:-Another important concept to master in Linux is group creation and management. Like user accounts, group information is stored inside of an ASCII-based text file known as the /etc/group file. The following illustration details a sample /etc/group file. Like the other files for user management, the group file contains various fields for attribute definition. The following table details the different fields and their usages.Different Fields and UsagesCOLOMN & FIELD USAGES

Group Name Name of groupPassword Not used anymoreGID Group identifier, similar to VID but for groupsMembers Group members separated by commas

Sample /etc/group file.

Groups, like users, are represented to the system by a unique identifier known simply as the GID or group identifier. Under Linux, users can be a member of one primary group and multiple supplemental groups at any given time. As with users, the group file can be directly edited to add groups. Again, this action is not recommended. The tool groupadd is often used for group additions to the operating system. Conversely, to delete a group from the system, you would use the groupdel command. To add a new group to the system with a name of print_users and a GID of 700, you would type groupadd -g 700 print_users at a command line. To add members to the group, you can edit the group file directly or use the useradd or the usermod command.

Q1. What is a group?Ans: A group consists of several users who need the same access to the system or a directory on the system. The group is then administered as a single entity and all of the users receive the access given to the group.Q2. What command is used to create a group?Ans: groupadd

Lesson 3 Managing Users

Lesson Objectives

In this lesson, you will:

List some commands that can be used to display information about logged in users.

29

Page 30: HISTORY AND DEVELOPMENT OF LINUX22

Describe which commands can be used to remove a user from the system.

Introduction:- There are times when you'll need to know who is logged in to your system, who you are logged in as, and information about your login session. This section introduces you to several commands that can be used to gather this information.MANAGING USER:

COMMAND FUNCTION EXAMPLE

id Display user id and group id information [frank@localhost frank]$ idUid=501(frank) gid=501(frank) groups=501(frank)

finger Display login Name, real Name. terminal name, write status, idle time, office location and phone number

[root@localhost /root]# finger –s rootLogin Name Tty Idle Login time office root root tty1 * jul 31 12:52

who List all users currently on the system. [jfox@localhost jfox]$ whoFrank tty1 jul 31 13:35Jfox tty2 jul 31 13:49

who am i List information about the user issuing the command [jfox@localhost jfox]$ who am iLocalhost.localdomain!jfox tty2 Aug 1 15:02

whoami List your user name [jfox@localhost jfox]$ whoamijfox

The id Command:-The id command is used to display user ID and group ID information. Entering the command with no options displays information for the user you are currently logged in as. You can also specify a user name as an option to display ID information for another user. The finger Command:-The finger command is used to display information about users including login name, real name, terminal name, write status, idle time, login time, office location, and office phone number. Some of these fields might be blank if no information was included when the user was created. You can also view information for another user by entering finger username.

The who and whoami Commands:-The who command lists all of the users currently on the system. Add the -i option to see how long the users have been idle. A dot indicates that the user was active within the last minute, old indicates that the user has been inactive for over 24 hours, and anything between 2 minutes and 23 hours, 59 minutes shows the length of time they've been idle.

The am i option displays the information only for the user who runs the command. The output is preceded by the hostname.

The whoami command shows just your user name. This is all one word as opposed to the who command with the am i option discussed already.

TIP:You can use any letters in place of �am� and �i� as long as they aren�t options defined for the who command. For example, who asdf oi or who d d is the same as who am i.

Modifying User Accounts:-Modifying user accounts includes changing a user's name, default groups, user id numbers (UID), and passwords. You can use the usermod command or use your system's administration utilities.

USER ACCOUNT PROPERTIES

OPTION MODIFIES THE-c comment User’s comment field in the passwd file-d homedir User’s login and home directory -e expirationdate Day the User’s account is to be disable-f inactivedays Number of day after a password expires until the account permanently disabled. To disable the

account as soon as the password expires enter, the value is 0; to this disable feature, enter the value-1

30

Page 31: HISTORY AND DEVELOPMENT OF LINUX22

-g initialgroups User’s initial login groups, which must be an existing groups.-G group List the other groups that the user is also the member of. Separate group names with a comma and

no whitespace. The groups must also exist in order for the user to be added to the group(s). -l loginname User name for the specified user.-p passwd The encrypted password.-s shell User’s Login shell, A blank in this option specifies to use the default login shell.

-u uid User’s User ID number, which must be a unique number-L Password by locking it. An exclamation mark is added to the beginning of the encrypted password

which disables the password.-U Password by unlocking it. The exclamation mark is removed from the password.

TIP:Combine the -d option with the -m option to move the contents of the current directory to the new home directory.

TIP:If the user is currently a member of a group that isn�t listed, the user will be removed from the group. So, if you want to keep the existing groups and add another group, you�ll need to specify the existing groups as well as the new group(s).

In order to change the name of a user, the user must be logged out. If the UID is being changed, make sure the user isn't executing any processes.

Changing User Passwords:-It is a good idea to have users regularly change their passwords. This can be done through the passwd utility or through your system's administration utilities such as linuxconf, LISA, or YaST.

Removing Users:-Eventually, you might need to remove one of the users from your system. This can be done using the userdel username command. You can also do it through linuxconf.

Temporarily Suspending User Access

If you need to prevent login through an account, but don't want or need to delete it, you can edit the /etc/shadow file and replace the existing encrypted password with an asterisk. Be sure not to delete the colons on either side of the password. Then, to re-activate the account, remove the asterisk and assign a new password to the user account.

Q1. What are some commands that can be used to display information about logged in users?

Ans Commands include id, finger, who, whoami, and who options such as am i.

Q2. What commands can be used to remove a user from the system?

Ans Users can be removed with the userdel username command or by using linuxconf.

Lesson 4 Managing Groups

Lesson Objective

In this lesson, you will:

List the commands for managing groups.

31

Page 32: HISTORY AND DEVELOPMENT OF LINUX22

Introduction:-Groups are useful for performing actions on multiple users at once. For example, if you want all of the users in the Accounting department to have access to a particular directory and application, you can give the appropriate permissions to the group rather than to each individual user. As employees move into and out of the department, you will need to modify group membership. Let's look at how this is done.

The groupmod command is the default method for modifying a group. The syntax is groupmod groupname. You can also use the administration utilities linuxconf, turbousercfg, lisa, or yast.

Deleting Groups:Sometimes you create groups that are related to a specific project. When the project is over you would probably want to remove the group from the system. You can't delete the primary group of any user. To delete the group, you need to first change the user's primary group or delete the user. You should also check files to make sure no files are left with the deleted group's GID. Let's see how you would delete a group.

Q1. What are the commands for managing groups?

Ans The commands include groupmod to modify group name or GID number, groupdel to delete a group, and the administration utilities linuxconf, lisa, or yast.

CHAPTER 5 Introductions to the Filesystem

Lesson 1 Filesystem Navigation

Lesson Objectives

In this lesson, you will:

Explain what the parent directory is. Identify the command that enables you to traverse the directory structure.

Introduction:The Linux filesystem provides a logical method for organizing, storing, retrieving, manipulating, and managing information. This hierarchical filesystem enables you to group files together into directories. An important simplifying feature of the Linux system is that it views directories, ordinary files, devices such as printers and disk drives, and your keyboard and terminal screen all in the same way-they are all seen as files. The filesystem hides details of the underlying hardware from you; for example, you do not need to know which drive a file is on to work with it. This permits the same commands to work for ordinary files and for physical devices.Using Pathnames:A path specifies a location in the filesystem. It begins with the root, the directory at the top of the directory tree, and ends with the directory or file you want to access. The root directory is represented by the slash character (/). You can refer to a particular file by providing a path to the specific directory that contains the file. If, for example, the directory john contains a subdirectory junk, which contains the file myjunk, then you would use the pathname to refer to the file: /john/junk/myjunk. Notice that it uses the slash character (/) to separate items in the path. The slash that precedes john represents the root directory, from which the path to myjunk begins.The Home Directory:-Your home directory is where you are placed when you log in. In many shells, including the Korn, C Shell, and Bash, the tilde character (~) represents your home directory. This is a convenient shorthand for specifying pathnames. If you are using the Bourne Shell, $HOME is used instead of ~ to represent your home directory.

The Current Working Directory:-Your location is referred to as your current working directory. For example, when you log in you are placed in your home directory. At this time, your current working directory is the same as your home directory.

The current working directory can be listed in shorthand with a period (.). You can use the period whenever you need to refer to the current working directory.

The pwd command stands for print working directory. It prints out your current working directory relative to the root directory. The pwd command prints out a full pathname.

32

Page 33: HISTORY AND DEVELOPMENT OF LINUX22

Parent Directory:-The parent directory is one level above your current working directory. All directories except the root directory (/) have a parent directory.

The parent directory can be listed with two periods (..) in file listings. You can use this double-period notation when you need to refer to the parent directory.

Changing the Current Directory:-There are times when you need to move out of your home directory and into another directory in the filesystem. You use the cd command to change directories.

The cd command enables you to traverse the directory structure. There are several ways to specify the pathname you wish to make your working directory:

cd without a pathname takes you to your home directory, regardless of your current directory.

cd pathname takes you to the pathname specified. The pathname can be the full pathname (from the root down to the specified directory) or partial pathname (starting from your current working directory).

cd ~/pathname takes you to the specified directory, relative to your home directory. (Remember to replace ~ with $HOME if necessary.)

TIP:-Full pathnames always start with a slash while partial pathnames never start with a slash.

A SUMMARY OF DIRECTORY NOTATION

NOTATION REPRESENTS

. Current Directory

.. Parent Directory

~ Home Directory

/ Root or Top of Directory StructureListing Directory Contents:-There are two commands that can be used to list directory contents-the dir and ls commands. The dir command has been added to Linux and is not a standard UNIX command. The ls command comes from the UNIX tradition and is the command you'll explore in this course.

The ls command lists the files in a directory. This command takes several options and arguments. There are too many to cover all of them, so we'll work with some of the most common ones. To see all of the options, use man ls.

Results of the ls command.

The ls -F command lists directories with a slash (/) appended to the end of the directory name. If no argument is specified, it operates on all of the files and directories in your current working directory.

33

Page 34: HISTORY AND DEVELOPMENT OF LINUX22

Results of the ls -F command.

The ls -l command provides a long-format listing for the files and directories specified. The long format lists parameters dealing with permissions, the size of the file, and the date of creation or last modification.

Results of the ls -l command.

The ls -R command recursively lists subdirectories. The names of any subdirectories and the contents of those subdirectories are listed. By default, the listing begins with the directory from which the command is issued. If an argument is given, then the recursive listing starts from the specified directory.

Results of the ls -R command.

The ls -ld command is a long directory listing of the directory itself, not its contents.

Results of the ls -ld command.

34

Page 35: HISTORY AND DEVELOPMENT OF LINUX22

The ls -la command prints out regular files and the hidden files in your directory. Hidden files begin with a period (.) and typically refer to system files that are used to control your environment. The . and .. files are also listed. The current directory is represented by the . notation and the parent directory is represented by the .. notation.

Results of the ls -la command.

Many of the options can be combined to get various kinds of listings. Some (such as the -d option with the -a option) can't be combined with other options because they just wouldn't make sense, so Linux does what it thinks makes sense.

The ls command takes a directory or filename as the argument. This is optional; if it is not specified, the ls command works on the current directory. You can use full or partial pathnames.

Follow the steps below to learn how to list directory contents.

Log in as root. Change directory to the root of the filesystem. Enter ls to display the contents of this directory. Enter ls -F and observe the results. The contents of the

directory that are directories are followed by a slash. Enter ls -l and observe the results. A long listing of the directory contents including the permissions,

owner, file size, creation or modification date, and filename are displayed. Enter ls -R and observe the results. The contents of the current directory and all of the directories

below it are displayed. Press Ctrl+C after awhile to stop the command. You're listing every file on the system because this command was issued from the top of the filesystem, so it might take several minutes for the command to complete.

Enter ls -ld and observe the results. This displays information for the directory you are in and not for the contents of the directory. Unless you go to a directory above your current directory, this is the only way to display information about the directory itself.

Enter ls -la and observe the results. All of the hidden files are displayed in this long listing. You can also enter just ls -a and list just the filenames. Enter ls -R /etc to get a directory listing of the /etc directory rather than the current directory. You can specify a pathname with the ls command.

Use the ls -laRF /home command to display a long recursive listing of all files from the /home directory down, which also shows which entities are directories. This command should produce a long listing including hidden (dot) files in all user home directories.

Shell Metacharacters:You can also use wildcards or metacharacters in file and path names. Some common shell metacharacters are defined in the following table.

35

Page 36: HISTORY AND DEVELOPMENT OF LINUX22

Shell Metacharacters

Shell Metacharacters Description* (asterisk) Matches any number of character (or no characters at all) in a filename. The * is not limited to a

single character. For example, ls *st* .c lists any filenames in ur current working directory that begin with any number of characters, followed by st and ending with .c characters.

? (question mark) Matches on any single character in a filename. For example, ls ny?l lists all filenames that begin with “ny” and end with “1” and have any single character in the third position. Another example is ls ??? which lists all filenames three characters in length.

[] (set) Matches on any single character found within the brackets. For example, ls nyp [15] lists all filename that begin with nyp and end with 1 or 5.

[-] (range) Matches on any single character that is within the range specified within the brackets. For example, ls nyp [l-5] lists all filenames that begin with nyp and end with 1,2,3,4, or 5.

The touch Command:-The touch command is used to change the access or modification times of the files listed as arguments to the command. If the file does not exist, an empty file is created. This is being introduced here so that you can quickly create some files to work with in your directory structure.

1. Write the command that would list all files beginning with Jan and ending with 98 or 99.Ans: ls Jan9[89]2. Write the command that would list all files that begin with any three characters and end with 98 or 99.Ans ls ???9[89]3. Write the command that would list all files that contain 2001 somewhere in the filename.Ans: ls *2001*4. Write the command that would list all files in any subdirectories under /home that contain mktg.Ans: ls -R /home/*/*mktg*

Q1. What is the parent directory?Ans:- The parent directory is one level above the current working directory. All directories except the root directory have a parent directory.Q2. What is the command that enables you to traverse the directory structure?Ans:- The cd command enables you to traverse the directory structure.

Lesson 2 Managing the Filesystem

Lesson Objectives

In this lesson, you will:

Explain how to make a filesystem available to users. Identify the command used to make directories and subdirectories.

Introduction:-To make a filesystem available, you need to mount it. This includes having access to hard drives, floppy drives, and CD-ROM drives. Use the mount device mountpoint command to mount the filesystem. The directory at which a filesystem is attached to the directory tree is the mount point.

Files in all directories across the Linux system are part of one tree that begins at the slash (/). The files can be spread across many devices. The mount command attaches the filesystem found on these various devices to the one tree.

Most devices are identified by a filename. For example, /dev/hda is the name of the first hard drive, /dev/hda1 is the name of the first partition on the first hard drive, and /dev/fd0 is the name of the first floppy disk drive.

Notice that these disk drive filenames have two-letter abbreviations-a floppy drive is denoted by fd, and a hard drive by hd. Other letter combinations can designate such pieces of hardware as SCSI disks, SCSI tape drives, SCSI CD-ROM drives, the monitor physically connected to your Linux system, and other consoles (sd, st, scd, console, and tty, respectively).

36

Page 37: HISTORY AND DEVELOPMENT OF LINUX22

To see what filesystems are currently mounted, enter mount with no options or arguments. It will display a list that includes the device, mount point, type, and whether it is set for read write or read only.

Automating Filesystem Mounting:-You can use the /etc/fstab file to list the filesystem to be mounted when Linux boots and unmounts when the system is shut down. The figure below shows a sample fstab file.

TIP:The filename fstab stands for filesystem table.

A sample /etc/fstab file.

A tab separates each of the columns in the fstab file. The following table explains the fields in the file.

FIELDS IN THE FILE

FIELD INDENTIFIES

1 The device to be mounted

2 The mount point for the filesystem

3 The filesystem type.(common types includes exy2, msdos, iso9660, nfs and swap

4 The mount options for the filesystem. This is a comma separated list of option

5 How often to backup the system using the dump command

6 The order that the filesystem are checked to the boot time. The root filesystem should be checked first, so that should be, all other should be 2. If no value is present, the filesystem is not checked at boot time. Swap partition and partition with removable disk drive, such floppy disk and CD-ROM driver should are set to 0 so that they aren’t checked at boot time.

Mounting DOS Filesystems:-You can also mount DOS-based floppy and hard disks. Use the mount -t option and specify the filesystem type as msdos. You will also need to create a directory in the /mnt directory for each device you'll be mounting. For example, it is common to have CD-ROM, floppy, and C directories. To mount a DOS floppy filesystem, enter mount -t msdos /dev/fd0 /mnt/floppy. This mounts it as a read-only device. Add the option -o rw to the command to make the mounted DOS filesystem read-write.

TIP:If a directory is not already created in the /mnt directory for the device you�re mounting, use the mkdir command to create a directory for it.

Unmounting Filesystems:-The umount command is used to unmount filesystems. You might want to do this so that you can check a filesystem, unmount filesystems to fix network problems, or unmount then mount a different floppy disk or CD-ROM disk.

37

Page 38: HISTORY AND DEVELOPMENT OF LINUX22

If you are currently using a directory on a mounted filesystem or if it is your current working directory, you can't unmount it. You'll have to wait until you are done using it or, if you are just sitting in that directory, move to another directory on another filesystem before you can unmount it.

Follow the steps below to learn how to mount and unmount filesystems.

Log in as root. By default, only root can mount filesystems. To enable other users to mount filesystems, you have to modify the /etc/fstab file to indicate that users can mount a particular filesystem.

Enter mount to see what filesystems are currently mounted. Insert a CD in your CD-ROM drive, and then enter mount /dev/cdrom. If this doesn't work, cd to

the /mnt directory and create a cdrom subdirectory; then try mounting it again. Some systems mount auto-mount CDs automatically. These are sometimes mounted at the /cdrom mount point rather than the /mnt/cdrom mount point.

Enter mount to verify that the CD-ROM is mounted. Insert a floppy disk into your floppy disk drive, and then enter mount /dev/fd0. On most distributions,

this is sufficient information to mount a Linux-formatted floppy. You might need to specify the mount point in some cases. To do this, enter mount /dev/fd0 /mnt/floppy.

Verify that the floppy disk is mounted using the mount command. Enter umount /dev/cdrom to unmount the CD. Verify that it was unmounted. Log out, and then log in as yourname. Remember, you should be root only when necessary, so now

that you're done mounting and unmounting filesystems, you can go back to being your regular user.

Creating Directories:-While working in Linux, you will create data files. You will also use files that have been created by others. One of the ways you can simplify this complex environment is to develop an organized structure.

Creating directories and subdirectories with names that are indicative of their contents is one of the best ways to organize your directory structure. To create directories and subdirectories, use the mkdir dirname command. The directory name can be any legal Linux filename. You can use a path with the directory name to create a directory in a location other than your current working directory. If you attempt to create a directory in a location belonging to another user, you might encounter problems (you might not have permission to do this). You can create multiple directories with one mkdir command. For example:

mkdir dir1 dir2 dir3

You can also create a directory in a location other than your current working directory. If you do this, you'll need to specify the full or partial path based on where you are and where you want the directory to be created. So, if you are currently in your home directory, /home/jfox, and you want to create the directory project1 under /test/projects, you'll need to specify the full path:

mkdir /test/projects/project1

However, if you want to create a directory right below your current directory, just enter the partial pathname. If your current directory is /home/jfox, to create the directory temp under it, enter:

mkdir tempCopying Files and Directories:-The cp command enables you to produce an exact duplicate of a file in your current working directory in another location on the system. The original file remains intact.

When you are editing or modifying files, it is a good practice to create and work on a duplicate file. If you have problems editing or somehow corrupt the contents of the copy file in an unrecoverable manner, you still have the original file.

SIMPLE COPY

38

Page 39: HISTORY AND DEVELOPMENT OF LINUX22

Syntax of the cp Command:-The syntax of the cp command is cp -option source destination. Two frequently used options are -r and -i.

The -r option specifies that the copy is recursive. This enables you to copy directories and their contents (including subdirectories). The destination must be a directory. The -i option specifies that the copy is interactive. If you are about to overwrite a file, it prompts you to answer yes or no.

RECURSIVE COPY

39

Page 40: HISTORY AND DEVELOPMENT OF LINUX22

The source can be a file or directory. If it is a directory, you must use the -r option. The source can be in the current working directory, or you can use a path to designate another location.

The destination can be your current directory, or you can include a path to designate another location. If the source and destination are within the same directory, you must use a new name. If the source and destination are located in different directories, you can use the same or a different name. If the destination already exists, the file being copied will overwrite it. This is why it is good to use the -i option.

Using cp with Directory Notations:-You can use the directory notations for the current, parent, and home directories with the source and destinations. When copying files, you can use the tilde (~) to refer to your home directory and the period (.) to refer to your current working directory. For example, cp ~/mytown/myfile . indicates that the path for your source should begin at your home directory, and the dot designates your current directory as the destination. Similarly, the ~ can be used to refer to the home directory in a path for your destination.

The parent directory notation (..) can also be used in the source and destination. For example, cp myfile1 .. copies the file myfile1 up one level.

The current directory notation (.) is used mainly as the destination, and refers to your current location. For example, cp ~/myfile1 . copies myfile1 to your current location. Similarly, cp ~/myfile1 ../mynewfile copies myfile1 from your home directory to the parent directory of your current location and renames it mynewfile. Doing a recursive copy from the root or any large directory requires a great deal of time and disk space.

Moving and Renaming Files and Directories:-The mv command enables you to move a file or directory to a new location. When re-organizing or restructuring your filesystem, you might want to move individual files, or even entire directories and their contents.SIMPLECOPY

The mv Command:-The syntax for the mv command is mv -option source destination. The most common option for the mv command is -i, the interactive option. This prompts you to answer yes or no when you are about to overwrite an existing file.

The source can be one or more files or a directory. If your source specifies multiple files, the destination must be a directory. There is no recursive option with the mv command; mv is recursive by itself. If you specify a directory to be moved, its contents, including subdirectories, will be moved with it.

40

Page 41: HISTORY AND DEVELOPMENT OF LINUX22

RECURCIVE COPY

The destination can be your current directory, or can include a path to another location. The mv command won't move a file or directory onto itself. If the source and destination are within the same directory, you must use a new name. If the source and destination are located in different directories, you may use the same or a different name.

If you are moving a file and the destination is a new filename, it will be created. If you are moving a file and the destination is an existing file, the old file will be removed first and the new file will replace it. If you use the interactive option, you will be prompted first.

If you are moving a directory and the new directory doesn't exist, it will be created. If an existing directory is the destination, the source will be placed into the existing directory as a subdirectory with its original name.

You can use current, parent, and home directory notation for the source and destination paths.

There is no rename command, so you can use the cp or mv command, specifying a new name as the destination.

Removing Directories:-The rmdir command can be used to remove empty directories. If you attempt to remove a directory that is not empty, you will receive an error message informing you that the particular directory isn't empty. The rmdir command won't delete files.SIMPLE REMOVE

41

Page 42: HISTORY AND DEVELOPMENT OF LINUX22

Removing Files and Directories:-The rm command is used to delete files. The syntax for this command is rm option file. You must specify a filename or directory name (either specifically or using metacharacters).

Two common options for this command are -i (interactive) and -r (recursive). It is strongly recommended that you use the -i option so that you are prompted as to whether or not a file is to be deleted. When you issue rm -i filename the remove command deletes only files. Directories aren't deleted; you have to use the -r option to delete directories.

42

Page 43: HISTORY AND DEVELOPMENT OF LINUX22

When you use rm -r, you can delete directories; if you try to delete directories without the -r option, the message "is a directory" is displayed. The rm -r command is useful for deleting directories that aren't empty because this command will delete all files recursively below the directory you specify.

Note: The rm and rm-r commands are absolute, and files and directories cannot be recovered once they are deleted. It is a good practice to always use the -i option.

Q1. How do you make a filesystem available to users?

Ans: Use the mount command to mount the filesystem.

Q2. What command do you use to make directories and subdirectories?

You use the mkdir command to make directories and subdirectories.

Lesson 3Performing Filesystem Maintenance

Lesson Objectives

In this lesson, you will:

Identify the two commands used to prepare a Linux formatted floppy disk for use. List the information that the filesystem keeps track of in the form of metadata.

43

Page 44: HISTORY AND DEVELOPMENT OF LINUX22

Introduction:-During installation, the installation process created several filesystems on your hard drive. You can create additional filesystems after installation if you have free drive space. This can be from additional drives added to your system or from repartitioning your existing drive (for example, removing Windows from your system and using that space for an additional Linux filesystem.)

Creating a Filesystem on a Disk:If you want to use Linux-formatted floppy disks on your system, you'll need to create a filesystem on the disk as well. You should low-level format the disk with the fdformat command before laying down the filesystem on the disk.

You can set the device type using the setfdprm command so that you don't have to specify the capacity in the device name when formatting the disk. See the setfdprm man page for more information on using this option.

Follow the steps below to learn how to format disks.

Log in as root. Enter man fdformat. Read through the man page, and then close it by pressing q. You would use the

/dev/fd0H720 device if you have a high-density 720 KB disk and autodetection that is not enabled. Insert a blank disk in the floppy drive on your Linux system. Be sure that you don't want anything on

the disk, because everything will be erased after you format it. Enter fdformat /dev/fd0H1440. If you are using a drive other than the first (in DOS terms, A) floppy

disk drive or are not using a 3.5" high-density floppy disk, replace the fd0H1440 with the appropriate devicename and capacity. Refer to the man page again if necessary.

Using the mkfs Command:-You create the filesystem using the mkfs command. You can specify several different filesystems when formatting the disk under Linux. These filesystems are listed in the following table.

TIP:The mkfs command formats the disk, and is similar to formatting a disk under DOS.

FILE SYSTEM

FileSystem Type For Accessing

ext2 Extended filesystem which is most comman Linux filesystem.

romfs Ramdisk read-only filesystem.

NFS Network filesystem for accessing remote files on the network.

msdos DOS-FAT filesystem

ncpfs Novell NetWare server.

When you create a filesystem, the directory lost+found is created. This system directory is where lost files are placed when they are found. Files usually come from improperly shutting down the system or from disk errors. When the system is rebooted, files and directories without a directory entry are re-attached to the inode table and placed in the lost+found directory.

Managing Filesystems with fsck:-Linux has problems about having power just shut off, such as when you turn off the power switch, press the reset button, or lose power. Disk reads and writes are buffered in memory and written to disk at regular intervals. If this information hasn't been written to disk, you might lose the information and the filesystem might be corrupted. Let's examine why Linux is written to work this way.

To increase system performance, disk writes aren't written until absolutely required. If multiple read requests are for the same disk block, they can be served directly from RAM; this also improves performance. The update utility flushes the dirty buffers back to disk at regular intervals. This helps prevent data loss or corruption if power is lost or the system crashes. To make sure

44

Page 45: HISTORY AND DEVELOPMENT OF LINUX22

that everything has been written to disk, the shutdown command synchronizes disk buffers with the filesystem and cleanly exits any running processes.

The downside to this performance increase is that the information that hasn't been written to disk can be lost if power is suddenly taken from the system. For those users who came from the Microsoft world and are used to using Ctrl+Alt+Delete to reboot their systems, most Linux systems are written to capture that keystroke sequence and perform an orderly shutdown.

In the event that you do want to check the filesystem (or must check it), the fsck command is used to check and repair filesystems. If there are no problems, the number of files, blocks used, and blocks free are listed. If there are problems, you are prompted by the system whether to perform each correction. An exit code is given at the end. The code is the sum of all the conditions that apply and the values are displayed in the following table.

Value Description

0 No errors were found.

1 Filesystem errors were found and corrected.

2 You should reboot the system.

4 Errors were found, but haven't been corrected.

8 An operational error occurred while running fsck.

16 A usage or syntax error occurred.

128 fsck detected a shared library error.

Journaling:-All filesystems need to maintain information about the data stored on the disk. The files contain data. The information the filesystem keeps track of is referred to as metadata. This metadata includes information such as:

METADATA INFORMATION

File creation date

File last modification date

User ownership

Group ownership

Permission

File size

File location on the drive or partition

In a traditional filesystem, if a system crashes as metadata is being written, a file, directory, or even the entire partition can be corrupted. Journaling helps alleviate this problem.

Before a journaled filesystem changes metadata, it adds a journal entry to indicate it is about to make a change. The change is made, and then the journal entry is marked as completed or is deleted (depending on how journaling is implemented on your filesystem). If the system crashes before the first journal entry is made, the original data is retained (but your changes you just

45

Page 46: HISTORY AND DEVELOPMENT OF LINUX22

made are lost). If it crashes during the disk write, the journal entry is still there, indicating that you were about to save changes. When the system comes back up, the journal entry is read and the file write is either completed or the file is rolled back to its previous state (thus losing your changes, but not corrupting the file so that you lose everything either). Which of these happens depends on the journaled filesystem implemented on your system. In any case, journaling saved your partition from being corrupted.

A journaled filesystem works well with small files and small drives. With the growth of file sizes and of drives, performance has suffered. Some of the reasons for poor performance include:

filesystem recovery time after a power failure or improper shutdown bitmap method of keeping track of the filesystem

wasted space and fragmentation

Journaling filesystems help alleviate some of these performance problems. A journaled filesystem keeps track of the state of the drive in a journal file. This enables the system to check just the journal file after a power loss or improper shutdown rather than needing to scan the entire drive. They also use drive space more efficiently. Data can be read and written faster for a wide range of file sizes. A feature that will save you (the system administrator) time is that it offers dynamic space allocation. You don't need to guess what size a partition should be when you create it (then if you guessed wrong, you had to back up all of the data and recreate a partition to meet your needs). Journaled filesystems can also span drives as a single logical volume.

Two popular journaled filesystems are ext3 and reiserfs. Ext3 is a journaling filesystem developed by Stephen Tweedie from Red Hat. Reiserfs was developed by Hans Reiser.

The ext3 Filesystem:-The ext3 filesystem is a layer that sits on top of the traditional ext2 filesystem. However, ext3 keeps a journal file of disk activity so that recovery from an improper shutdown is much quicker than that of ext2 alone. This tieback to ext2 results in some of the limitations of the older system. It doesn't implement all of the features of a pure journaling filesystem. On the other hand, a benefit of this implementation is that ext3 partitions do not have a file structure different from ext2, so returning to the old system (by choice or if the journal file becomes corrupted) is very simple.

Michael K. Johnson of Red Hat listed the following reasons for implementing ext3:

Reason for implementing ext3

Availability: - U can quickly recover from a system interruption rather than enduring e2fsck filesystem check.

Data integrity: - Journaling makes data corruption less likely.

Speed: - “Despite writing some data more than once, ext3 is often faster(higher throughput) than ext2 because ext3’s journaling optimizes hard drive head motion,” he wrote. Easy transaction: - since u don’t need to reformat, there is no need to do a long, tedious and error-prone backup, reformat, restore operation in order to experience the advantages of ext3.

To configure your system for ext3 filesystems, follow these steps:

1. Patch the kernel to 2.2.19 or higher, then download and apply the patches ext3-0.0.7a.tar.bz2 and e2fsprogs-1.21-WP-0601.tar.bz2 (see the Web site at www.linuxgazette.com/issue68/dellomodarme.html for more complete instructions on how to do this).

2. Decide whether to make a new ext3 filesystem or upgrade an existing ext2 filesystem to ext3.

o mke2fs -j /dev/hdxx will create a new ext3 partition with a hidden journal. (Replace hdxx with the device where the ext3 partition will be created.)

o tune2fs -j /dev/hdxx will upgrade the specified existing ext2 filesystem to ext3. If the filesystem is mounted when

46

Page 47: HISTORY AND DEVELOPMENT OF LINUX22

you do this, the file .journal is created at the top of the filesystem. If it was unmounted, a hidden system inode is used for the journal.

3. Enter mount -t ext3 /dev/hdxx /mnt_pt (where mnt_pt is your mount point) to mount the filesystem.

The reiserfs Filesystem:-The Reiserfs filesystem treats a partition like it was one big database. A balanced tree structure is used to store directories, files, and file metadata. Files and the related metadata can be stored near each other, so they can be read quickly because the drive's read heads don't need to move around to pick up the metadata and the data. This helps speed access.

In a traditional filesystem, the default block size is usually something between 512 bytes and 4096 bytes. If you had 512 byte blocks, each 50 byte file would require its own block and a 513 byte file would require two blocks; the rest of the block can't be used and is wasted space. Reiserfs do not use blocks to save data, so there is less wasted space. The files can be placed close together, so it not only conserves disk space, but it also helps speed access.

To configure your system for Resierfs:

1. Patch the kernel to 2.2.19 or higher.2. Download and install the reiserfs 2.2.19 patch. If you are using kernel 2.4, also

download and install the patch reiserfsprogs-3.x.0j.tar.gz (see the Web site at www.linuxgazette.com/issue68/dellomodarme.html for more complete instructions on how to do this).

3. Enter mkreiserfs /dev/hdxx to create a new reiserfs filesystem.

4. Enter mount -t reiserfs /dev/hdxx /mnt_pt to mount the filesystem.

1. What is the minimum kernel version for using ext3 or reiserfs filesystem?

Ans: 2.2.19

2. Can ext3 or reiserfs upgrade existing filesystems to a journaled filesystem?

Ans: ext3 can, but reiserfs can't. To get a reiserfs filesystem, you have to create it from scratch.

3. List some of the benefits of using a journaled filesystem.

Ans: Answers might include: High availability, data integrity, and speed of access.

4. After configuring your system for ext3 support, how do you create and access an ext3 filesystem?

Ans: To create a new ext3 filesystem, enter mke2fs -j /dev/device_name. To upgrade an existing ext2 filesystem to ext3, enter tune2fs -j /dev/device_name. Then, mount the filesystem using mount -t ext3 /dev/device_name /mnt_pt.

5. After configuring your system for reiserfs support, how do you create and access a reiserfs filesystem?Ans: Enter mkreiserfs /dev/device_name, then mount it using the command mount -t reiserfs /dev/device_name /mnt_pt.

Knowledge

1. What are the two commands used to prepare a Linux formatted floppy disk for use?

Ans: First, use fdformat to low-level format the floppy disk, then use the mkfs command to format the disk as the default Linux filesystem type, ext2.

47

Page 48: HISTORY AND DEVELOPMENT OF LINUX22

2. What information does the filesystem keep track of in the form of metadata?

Ans: The file creation date, file last modification date, user ownership, group ownership, permissions, file size, and the file location on the drive or partition.

Lesson 4 Locating Files

Lesson Objective

In this lesson, you will:

Determine the differences between the find and locate commands.

Introduction:-When you log in, the paths searched to locate commands are established. If the file you want to access is not in the path, you will need to specify the relative or full path to the file. If you don't know where the file is located in the filesystem, Linux includes several commands with which you can try to find the file.

Using the find Command to Locate Files:-The find command enables you to search a specific location for files and directories that adhere to some search criteria. If you have misplaced a file in a large directory structure, or if you have forgotten the exact name of the file but remember a portion of the name, you can use the find command to search your entire directory structure for the file!

The syntax of the find command is find search_locations search_criteria actions. One or more search paths can be designated; directory notations can be used as the search path. One or more criteria can be used to specify the conditions of a file or directory. If the find command is successful in its search, you can perform one or more actions upon the files found.

Format of the find commandfind search_location search_criteria actionsThe find command will recursively search the directory structure, including any subdirectories and their contents, beginning with the search location you enter. If you use more than one search criterion, the file or directory must meet all of the conditions you specify before it will be reported to you. There are many conditions you can use as the search criteria. Some of the more useful conditions include a search by the options shown in the following table.SEARCH BY OPTIONOPTION TO SEARCH BY DESCRIPTION-name file or directory name The pattern used for the name can be the entire name, or you can enclose the pattern

in double quotes and use metacharacters to difine a portion of the name.-type file, directory or other

typeThe most common arguments for the-type option are d for directory, f for file. This is often combined with the-name option.

-user ownership The argument for this option is a user name.-group group membership The argument for this option is a group name.

You can use these conditions in combination, or you can use a notation to find a file by using the not or exception to the conditions. For example, you can search for every file that does not match a user name. The notation for not is \! and is placed before the search criteria.

When the system finds a listing that meets your criteria, there are three options or actions that can be performed, and they are outlined in the following table.

Option Action Performed

-print Print the location to the screen.

-exec Execute a command.

-ok Execute a command interactively.

48

Page 49: HISTORY AND DEVELOPMENT OF LINUX22

Using the find command to locate files in a large directory structure, or even in the entire Linux filesystem, provides an excellent opportunity to implement the techniques learned throughout this course.

TIP: -print is the default action and doesn’t need to be specified in the command when using Red Hat Linux 7.0. On some versions of UNIX, if you don’t specify any action, the command executes, but nothing is displayed on the screen, so you’ll have to include the -print option in the command on those systems.

Finding Files Based on Usage:-Locating files by their usage is a way you can use the find command to maintain an updated, efficient, and secure filesystem. Some of the ways that the find command can assist with these tasks are by locating files that:

haven't been accessed or modified within a specific time period; have been accessed or modified without your knowledge;

have been modified by you within a specific time, but whose names you can't recall; and

should be identified as files to be backed up.

To locate files that have been accessed within a certain time period, use the -atime option, followed by the time in days. For example, find . -atime 2 -print lists the files accessed two days ago. Accessed files are those that have been read or changed, or directories that have been worked on (for example, listed or changed into). The following table describes how to use the -atime option.

THE –atime OPTION-atime Number List File Accessedexact number(for example –atime7) That exact number of days ago(for example, 7 day ago). +number(for example, -atime+7) Accessed more than that number of day ago(for example more than 7 days ago)-number(for example, -atime-7) Accessed within that number of day(for example, within the past 7 days)+number-atime-number(for example, -atime+7-atime-14)

Between that range of day(for example,between 7 & 14 days ago

To locate files that have been modified within a certain time period, use the -mtime option, followed by the time in days. For example, find . -mtime 2 -print lists the files modified two days ago. Modified files are those that have been altered in some way, such as by editing, moving, or renaming.

Performing an Action with Files You Find

After you have designated a search path and established search criteria, you need to specify an action to take concerning the files that have been found. If no action is specified, the find command will perform its job and then finish with no indication that it was successful.

The most common option used with the find command is the -print option, which you have been using so far. The -print option displays on the screen the locations of listings that meet your criteria.

If you want to have a command executed once your files are located, use the -exec, or execute, option. With the execute option, almost any command can be specified to operate on the files located with the find command.

To include the -exec option, the command syntax is:

find search_location search_criteria -exec command {} \; .

The -exec option must be followed by a space and then the command you want to use, such as ls, rm, cp, and so on. Following the command, you need a space and double curly braces, {}. The braces are followed by the \; characters. The braces represent the location for the arguments, and the escaped semicolon represents the end of the statement.

49

Page 50: HISTORY AND DEVELOPMENT OF LINUX22

If you're using a command that might somehow cause a problem, such as the rm command, you should use the -ok option in place of -exec. The -ok option is an interactive option that prompts you for a yes before performing an action.

The syntax for using the -ok option is the same as for the -exec option (just substitute -ok for -exec). When you use this format, for each object found you'll be prompted to confirm execution on the located object.

There are many additional conditions and options available with the find command. Once you understand the basics of using the find command, you might want to do more research and develop combinations of options to assist you with specific tasks.

The Locate Command:-The locate command is another command that you can use to find files. It builds and uses a database to quickly locate files throughout the filesystem. The syntax is much simpler than the find command, but you can't do as much with it. It just lists the location of the file; there are no options such as exec or ok to enable you to act on the results of the locate command.

To use this command, you must build a database using the slocate command. You can specify from where the database begins (usually from /). You can also build other databases from other starting points, and then specify the database to be used with the locate command when you run it.

Updating the Slocate Database

The slocate database (secure locate) is a secure way to index and quickly search for files on your system. Users won't see any of the files to which they don't have access. To update the slocate database for the entire system, use the locate -u command. This creates a slocate database starting at / (the top of the directory structure).

To create a slocate database starting at a particular directory, use the locate -U command. The database is replaced each time you run the command.

1. Compare the find and locate commands.

Ans: Find is a more complex command that enables you to act on the results of your query. Locate just prints out where the requested file is located in the filesystem.

CHAPTER 6 Working with Linux Permissions

Lesson1Understanding Permissions

Lesson Objectives

In this lesson, you will:

Identify the command used to view the permissions for a file. Identify the command used to view the permissions for a directory.

Introduction:-Because Linux is a multi-user system, there is a series of permissions associated with all files and directories. The owner of the files and directories has the ability to set and change these permissions, thus maintaining a certain level of security. There are three types of permissions, as shown in the following table.PERMISSION TYPESPermision For File, You Can For Directories, You Canr(read) View file content. See what is in the directory.w(write) Modifies contents. Create and delete directory contents.x(execute) Run the file(if it is an executable program and is

combined with read).Move into the directory. When combined with read, u can also see a long listing of the content of the directory.

Viewing Permissions:-The ls -l command gives you a long list of the files and directories in your current working directory. The results of the command are shown in the following figure.

50

Page 51: HISTORY AND DEVELOPMENT OF LINUX22

Results of the ls -l command.

Let's examine these results.

Column Description

0 The first column (known as column 0) indicates whether it is a file (-) or a directory (d).

1-3 User (owner) permissions. The user for whom these permissions are valid is listed in column 11.

4-6 Group permissions. The group for whom these permissions are valid is listed in column 12.

7-9 Other users' permissions. Any other user besides the specified user and group receive these permissions.

10 This column indicates the number of links. Files generally have a link count of 1. For directories, the link count is the number of directories under it plus two: one for the directory itself and one for the parent. (Links are similar to Windows 95/98 shortcuts-they point to the location where the file exists, and allow you to access and see the file.)

11 Shows the owner of the file or directory.

12 Shows the group to which the owner of the file belongs. All members of this group have the permission listed in columns 4-6. (The administrator adds users to a group so that all of those users can be assigned permissions by assigning permissions to the group rather than each individual user.)

13 Lists the size (in bytes) for the file or directory.

14 Shows the date and time the file was created or last modified.

15 The file or directory name.

Use the command ls -ld directoryname to get a long list of the specified directory. This gives a long list of only the specified directory, not the contents of the directory.

1. What is the command used to view permissions for a file?

Ans: The ls -l command

2. What is the command used to view the permissions for a directory?

Ans: The ls -ld command.

Lesson 2 Changing File and Directory Permissions

Lesson Objectives

In this lesson, you will:

51

Page 52: HISTORY AND DEVELOPMENT OF LINUX22

Explain how you change permissions using characters. Explain how you change permissions using numbers.

Introduction:-The chmod command enables you to modify the default permissions for a file or directory. Only the owner of the file or the system administrator can change the permissions for a file or directory. There are two ways to change permissions: by using combinations of characters and by using numbersChanging Permissions Using the Character Method:The syntax of the chmod command when using the character method of changing permissions is chmod [ugo][+-][rwx] file. The u refers to user permissions, the g to group permissions, and the o to other permissions. Use the plus sign (+) to add the read, write, or execute permissions individually or in any combination. Use the minus sign (-) to remove permissions. If you don't specify u, g, or o, the default is everyoneChanging Directory Permissions Using the Character Method:-You need to have specific permissions to see the contents of a directory or to change into a directory. You can see the permissions on a directory by entering ls -ld.

You need to have at least read permission to view the contents of a directory. However, it is not enough permissions to do a long listing of the directory. You require both the read and the execute permission to change into a directory or do a long listing of the directory. In order to create a subdirectory within a directory, you also need the write permission.

Changing Permissions Using the Number Method:-Each permission (r,w,x) has an associated number as shown in the following table. Combining these numbers, you can specify permissions by using a three-digit number where each digit corresponds to user, group, and others, respectively. The resulting number is an octal representation of the permissions for user, group, and others. The syntax for the number method of changing permissions is chmod number file.PERMISSION

Permission Number Value

r 4

w 2

x 2

Let's look at an example, chmod 640 testfile. The following table analyzes the numbers in this command.

Number Permissions For Assigns

6 user read and write (4+2)

4 group read (4)

0 others none whatsoever

1. How do you change permissions using characters?

Ans: Specify who permissions are being changed for (u, g, o), whether to add or delete permissions (+ or -), and the permissions being added or deleted (r, w, x).

2. How do you change permissions by using numbers?

Ans: Specify the number corresponding to the permissions to be assigned to the file or directory for user, group, and others.

Lesson 3 Changing Default Permissions and Ownership

Lesson Objectives

In this lesson, you will:

52

Page 53: HISTORY AND DEVELOPMENT OF LINUX22

Explain how you change the default permissions for newly created files and directories. Determine how you can recursively change ownership through a directory structure.

Introduction:-Linux automatically gives the user who created a file ownership of that file, and assigns the file to its creator's group. It also assigns default permissions of rw-rw-rw- (666) to newly created files, and rwxrwxrwx (777) to newly created directories.

Using umask to Set Permissions:-For security reasons, you will probably want to change the default permissions on newly created files and directories. It is tedious to change permissions every time a new file or directory is created. You can use the umask command to automatically alter the default permissions on newly created files and directories.

The syntax of the command is umask number. This is similar to the chmod command. However, the numbers specify which permissions to clear from the default settings.

The Effect of umask on Files:-By default, newly created files are assigned rw-rw-rw- permissions. By entering umask 022, permissions assigned to any files created until the system is restarted will be as shown in the following table. Any newly created files will now have rw-r- -r- - (644) permissions assigned.

umask on file

Number Clears

0 Nothing from the users’ default permissions, leaving rw-.

2 Write permission from the groups, leaving just r--.

2 Write permission from others, leaving just r--.

The Effect of umask on Directories:-By default, newly created directories are assigned rwxrwxrwx permissions. By entering umask 022, permissions for any directories created from now until the system is restarted will be as shown in the following table. Any newly created directories will now have rwxr-xr-x (755) permissions assigned. umask on Directories

Number Clears

0 Nothing from the users’ default permissions, leaving rwx.

2 Write permission from the group, leaving just r-x.

2 Write permission from others, leaving just r-x.

Changing Ownership:-There are times when the current owner of a file needs to be changed to another user. This is done with the chown command. It can be used to change the owner, the group, or both on a file or directory. The following table describes how to use this command.Using the Chown CommandCommand Descripionchown usernmae filename Changes owner but not the group.chown username.grouoname filename Changes owner and the group.chown username.filename Changes owner and group. Group will be changed the specifies user's login

group.chown. Groupname filename Change the group but not the owner. This is the same as using the chgrp

commands.

You can combine the chown command with the -R option to recursively change ownership through a directory structure. You can also use metacharacters to change groups of files at once.

53

Page 54: HISTORY AND DEVELOPMENT OF LINUX22

The chgrp command is used to change the group ownership of a file or directory. The syntax of the command is chgrp group file where group is the GID of the group that will own the specified file.

1. How can you change the default permissions for newly created files and directories?Ans: Use the umask command and the corresponding numbers for the permissions to be cleared.2. How can you recursively change ownership through a directory structure?Ans: Combine the chown command with the -R option.

Lesson 4 Setting Daemon and Process Permissions

Lesson Objective

In this lesson, you will:

Explain why you might want to create a file listing all of the files with suid and sgid set.

Introduction:-The suid (set user ID) and sgid (set group ID) concept is that a program (not a script) is set so that it is run as the owner or group set for the program, not the person running the program. For example, say you have a program with suid set, and its owner is root. Anyone running that program runs the program with the permissions of the owner rather than their own permissions. The passwd command is a good example of this. The file /etc/passwd is writable by root, and readable by everyone. The passwd program has suid turned on. Therefore, anyone can run the program and change their password. Because the program is running as the user root, not the actual user, the etc/passwd file can be written to. The same concept is true of sgid. Instead of the program running with the permissions and authority of the group associated with the person calling the program, the program is run with the permissions and authority of the group that is associated with the program.

You can use the find command to locate programs that have suid or sgid turned on. The command is find / -perm -200 -o -perm -400 -print. If you log in as root and run this command when you first load a system and save the output to a file (which only you have access to), in the future you can run the command and compare its output to this list of suid and sgid files. This will let you know if anyone has been accessing suid and sgid settings and you can verify that only the files that should have these permissions do.

Setting suid and sgid

The set user ID and set group ID commands are powerful tools that enable users to perform tasks without the other problems that could arise with the user having the actual permissions of that group or user. However, these can be dangerous tools, too. If you change the permissions on a file to be either suid or sgid, keep in mind the following:

Use the lowest permissions needed to accomplish a task. If possible, don't give a file with a suid or sgid of root. A user with less privileges often can be configured to perform the task.

Watch for back doors. If a user runs a program with the suid set to root, then the user retains root as the effective user ID when the user goes through the back door. The following can be used as back doors:

o Programs that enable you to shell out.

o Programs with multiple entrances and exits.

The suid and sgid permissions are added using the chmod command. The command chmod u+s file sets the suid for the specified file and the command chmod g+s file sets the sgid for the specified file. These can be set only on executable files. The permissions would be:

-rwsr--r-- if suid was set on a file. -rwxr-sr-- if sgid was set on a file.

54

Page 55: HISTORY AND DEVELOPMENT OF LINUX22

-rwsrwsr-- if both sgid and suid are set on a file.

To set the suid and sgid using the numeric chmod method, you need to add another number. 2 sets suid and 4 sets sgid. To set both, combine these for 6. Examples are:

chmod 2700 filename would set suid chmod 4774 filename would set sgid

chmod 6776 filename would set both suid and sgid

1. On which types of files can you set sgid and suid?

Ans: On executable files.

2. What is the file with the following permissions set for? -rwsr--r—

Ans: SUID.

3. How would you set the executable file runme to both suid and sgid?

Ans: You could enter chmod 6770 runme or use the character method to set it.

1. Why might you want to create a file listing all of the files with suid and sgid set?

Ans: So you can later compare it and make sure no hackers have tampered with your settings.

Lesson 4 Evaluating System Security

Lesson Objective

In this lesson, you will:

List some of the issues you need to consider in evaluating system security.

Introduction:-System security is an important topic in today's business world. The value of the data stored on systems is often worth more than the software and hardware combined. Therefore, it is important to safeguard the physical equipment as well as the software and data contained on the equipment.

Passwords

The first line of defense against stealing information is implementing secure passwords. Passwords are required for accessing your user account. You can also set up boot time passwords for your hardware.

Passwords should be secure themselves. This is done by using a combination of letters, numbers, and special characters. The passwords should be changed on a regular basis so if the passwords were compromised, there would be less chance of someone getting in. Make sure that users do not write down their passwords and post them somewhere where unauthorized people might see them.

Physical Environment Security

Physical security of your network equipment is as important as securing the files on the network. After all, if your server walks out the door, you still won't be able to access the files!

55

Page 56: HISTORY AND DEVELOPMENT OF LINUX22

You should take the following steps to help ensure the security of your network equipment:

Limit access to server room and backup tapes. Ensure that physical locks exist on doors.

Establish anti-theft devices for hardware (lock server racks).

While hackers wreak havoc on systems, viruses and Denial of Service (DoS) attacks penetrate firewalls; with all of the other security risks that exist and that you have to battle, don't forget about protecting your physical network components.

In addition to being sure that systems remain secure, you also need to make sure components within systems aren't stolen. This includes components such as CPUs, RAM, drives, and expansion cards.

1. List some ways to ensure password security is as secure as possible.

Ans: Answers might include: Using passwords composed of letters, numbers, and special characters; requiring frequent password changes; making sure passwords aren't posted somewhere that unauthorized people might find them.

2. What physical precautions can you take to protect your systems?

Ans: Lock them up, limit access to servers and tapes, and use anti-theft devices to secure equipment.

Security Risks:-You should assess the security risks related to your computers. Some factors to consider are: Location Sensitive data

Filesystem permissions

Removal of or disabling unused accounts

Audit system services and programs

Keeping Up to Date

It is important that you keep up to date on the most recent information regarding security. This can be done by monitoring news groups, forums, Web sites, trade magazines, and other resources. This can be very time consuming. One resource you might want to consider using is the Web site Linux Security - The Community's Center For Security at www.linuxsecurity.com. This site contains current news stories related to security, feature articles on security concerns, and multiple resources including documentation, security sources, forums, firewalls, host security, cryptography, network security, intrusion detection, organizations and events, server security, vendors and products, projects, among others.

1. In what ways can the location of equipment affect security?

Ans: Equipment near exits can more easily be removed from the building without someone catching the thief.

2. How can you protect sensitive data?

Ans: You can perform backups and keep a set of tapes offsite.

3. What should you do with unused accounts?

Ans: You should remove or disable accounts when they are no longer needed, such as when an employee leaves the company.

1. What are some of the issues you need to consider in evaluating system security?

56

Page 57: HISTORY AND DEVELOPMENT OF LINUX22

Ans: Using good passwords, having appropriate physical environments to run computers in, locating the equipment in appropriate areas, securing sensitive data, setting filesystem permissions, removing or disabling unused accounts, and auditing system services and programs

CHAPTER 7 Creating and Viewing Files

Lesson 1 Using the vi Editor

Lesson Objectives

In this lesson, you will:

Identify the two primary modes in the vi program. Explain how you save a file and exit vi.

Introduction:-The vi editor is included with most versions of UNIX and Linux. Its primary use has been for developing computer programs. However, because of its availability with the system, and because it can become a letter-quality word processor, it has been widely used for purposes other than programming. With the vi editor, you can create files, called shell scripts, to assist you with your work in Linux. Creating a New File:-The command to enter the vi editor is vi. When you enter the command and don't specify a filename, you enter the vi program and work with an unnamed file.

There are two primary modes in the vi program: the command mode and the input mode. In command mode, you save, edit, search and replace, and generally perform tasks that aren't directly related to inputting text into your file. In input mode, you type, or enter text, into your vi file. In general, you won't be able to perform the operations that are available in the command mode while you are in the input mode.

Changing Modes:-Two of the input modes are the insert and append modes. The following chart describes the insert (i) and append (a) modes for entering text in the vi file.

Insert(i) and Appened(a) modes

Type TOi Enter insert mode and input text to the left of the cursor.a Enter append mode and input text to the right of the cursor. I Enter insert mode and input text at the beginning of the line.A Enter append mode and input text at the end of the lineEsc Leave input mode and return to the command mode.

TIP: You can also use the Insert key to enter input mode. Press it once and you are in insert mode; press it again and you are in replace (or overtype) mode.

Saving Your File:-Saving the file is a command-mode operation. To save the vi file, type :w filename. This is the write command. When you create a new file, you need to name the file before it is saved. You can use any valid Linux filename. The contents of your vi file are saved in a file with the new filename.Undo:-It is easy to forget you are in input mode; try to issue a command mode command and you'll end up with stray characters in your text! Don't worry-you can undo this mistake. Return to command mode by pressing Esc, and then type u to undo the change. Only the most recent change is undone. To undo more changes, keep typing u. Only changes written since the file was written to disk are undone. Leaving the vi Editor:-To leave the vi editor, enter :q. This is the quit command. It lets you leave the editor only if you have saved your file. If the file hasn't been saved, a message is displayed to indicate this.

To leave the editor and not save your file, enter :q!. This command overrides the error message and enables you to exit without saving any changes since your last save. (All changes will be lost if you use :q!.)

57

Page 58: HISTORY AND DEVELOPMENT OF LINUX22

Using vi to Edit a File :The vi command followed by a filename will put you in the vi editor with the contents of the named file. The command mode enables you to move around in a document and to perform command-line edits. The following table describes the movement keys in the command mode.

Type Result

g Move left one character.

j Move down one line.

k Move up one line.

l Move right one character.

^ Move to the beginning of the current line.

$ Move to the end of the current line.

:1 Move to the first line in your file.

:$ Move to the last line in your file.

:number Move to the line specified. (For example :15 takes you to the beginning of line 15.)

w Move to the next word.

b Move to the previous word.

e Move to the end of the current word or to the end of the next word if you are already at the end of the word.

[Ctrl]U Move up one-half screen.

[Ctrl]D Move down one-half screen.

[Ctrl]F Move down one full screen.

[Ctrl]B Move up one full screen.

You can combine the line, word, and character movement keys with a number to specify how many lines, words, or characters to move at once. For example, 6w moves you forward six words. You can also use the arrow keys to move around. Home and End move to the beginning and end of the current line. Page Up and Page Down move to the next and the previous screen.

Learn more about moving around a document by following the steps below.

Enter vi sales. This opens the existing sales file in the vi editor. Move around in the file using the j, k, l, and h keys. The j key moves you down one row, k moves you up

one row, l moves you right one character, and h moves you left one character.

Move word by word using the w, e, and b keys. The w key moves you one word forward, e moves to the end of the words, and b moves you back one word.

Try combining the character and word movement keys with a number to move several characters or words at a time. For example, 3j moves you down 3 lines and 5w moves you over 5 words.

Move to the last line of the file using :$ and to the beginning of the file using :1. Enter :15 to move to line 15.

Type $ to move to the end of the current line, and then type ^ to move to the beginning of the current line.

Entering New Lines of Text:-Use the open mode to enter input mode and place the cursor at the beginning of a new line ready to insert text. The following table shows the two open mode options.

58

Page 59: HISTORY AND DEVELOPMENT OF LINUX22

Two Open Mode OptionType Resulto Opens a new line below file current line.O Opens a new line above the current line.

TIP: Input mode is any mode where you can input text such as insert or append modes.

Replacing Existing Text:- Unless you are a super typist, you'll probably make some typos and need to edit your existing text. Even if you are a super typist, you might need to change information in your documents. The vi editor includes commands that enable you to replace a single character, many characters, a word, and other options as described in the following table.

Vi Editor CommandsType Resultr Replaces a single character.R Replaces characters until u press the Esc key to return to command modecw or ce Deletes the portion of the word, from the insertion point to the end of the word and puts u in insert mode to make

the desired changes.cb Deletes the portion of the word, from the insertion point to the beginning of the word and puts u in insert mode

to make the desired changes.c$ or U Deletes the rest of the line, from the insertion point of the end of the line and puts u in insert mode to make the

desired changes.

TIP: Don�t confuse u (undo) with U (delete the rest of the line)!

Except for the r command, you'll need to press Esc to return to command mode after any of these commands.

Copying and Deleting commands

Type* Resultx Deletes one character at a time.yy Places a copy of the current line into the buffer.dd Deletes the current line and places a copy of the it into the buffer.p Inserts the copied or deleted lines into the file below the line the insertion point is on.P Inserts the copied or deleted line into the file above the line the insertion point on.*Any of these commands can be preceded by a number to specify how many lines or characters to perform the command on

Setting the Number Option:-In large files, it might be useful to refer to the line number of a particular entry. The vi program has a line-number option, :set number. The number option places line numbers in front of each line in the file. It will be set only until you quit from vi. The next time you start vi, you'll need to set the option again if you want to use it. To turn off line numbers, enter :set nonumber.Searching for a Pattern:-You might need to find specific entries in a file. This can be time-consuming and potentially inaccurate, especially in large files. The /pattern command enables you to find a specific pattern or entry in files. It finds the first occurrence of the pattern following your current cursor position. To search for the next occurrence of the pattern, type the letter n. To continue to search for additional occurrences, continue to type n.

59

Page 60: HISTORY AND DEVELOPMENT OF LINUX22

Searching and Replacing Text in viRepeating a Command:-In addition to being able to specify how many times a command is performed when you issue the command (such as 3dd to delete three lines), you can repeat the last command issued. This is useful if you want to repeat the command elsewhere in your document. The dot command (.) repeats the last editing change you made. It is a convenient shortcut for repeating a single editing change several times.

Follow the steps below to learn how to search within a file Open the file sales in the vi editor (vi sales). Enter :set number to turn on line numbering. This is useful in large files so you can get an idea of where

you are in the file.

Enter :3 to move to line three of the file.

The vi search is case-sensitive, so entering talbot couldn't find Talbot entries in the file. Type / to enter the search mode, and then enter Talbot to specify the search pattern. Notice that the cursor jumps to the first entry containing the pattern Talbot after the cursor.

Type n several times to take you to the rest of the Talbot entries. Notice that it wraps around to the top of the document.

Enter /Burt to search for this pattern. After you locate the pattern, you can perform any vi command on the entry.

Type dd to delete the Burt entry.

Type n to move to the next Burt entry, and then type . (a single period) to repeat the delete command. Repeat this step until all Burt entries have been deleted.

Search and Replace:-To substitute pattern1 with pattern2 on the line your cursor is on, use the :s /pattern1/pattern2 command. The s stands for substitute; pattern1 is the pattern to search for and will be replaced; pattern2 is the pattern that will replace pattern1.

Search and Substitute for a Range

To search for a pattern over a range of lines and replace it with a substitute pattern, use the :linenumber1,linenumber2 s /pattern1/pattern2 command. Let's examine what this command does in the following example, :5,25s/January/01. For lines 5 through 25, substitute 01 for January. If there is more than one occurrence of pattern1 on a line, only the first occurrence will be replaced.

Global Search and Replace

60

Page 61: HISTORY AND DEVELOPMENT OF LINUX22

To search for all occurrences of pattern1 on all lines in the file, use the :1,$s /pattern1/pattern2/ g command. This will search from line 1 to the end of the file (represented by the $) for pattern1 and replace it with pattern2. The g at the end of the command stands for global, and means to replace every occurrence of pattern1, including more than one occurrence per line.

TIP: To replace more than one occurrence per line, use the /g option on substitution commands.

Interactive Search and Replace

Add the option c to the end of the global search and replace to make it interactive. You'll be prompted for a yes or no response when replacing the occurrences of pattern1. At the bottom of the screen, you'll be prompted to reply y or n for each replacement. The default, or just pressing [Enter], is the same as entering n.

1. What are the two primary modes in the vi program?

Ans: The command mode and the input mode.

2. How do you save a file and exit vi?

Ans: Type :wq

Lesson 2 Using Other Editors

Lesson Objectives

In this lesson, you will:

Explain the two ways you can specify the filename for a new file. Identify the command used to save a file in emacs.

Introduction:-Richard Stallman, founder of the Free Software Foundation and the GNU project, created the emacs editor. It is a free editor, included with most every Linux distribution. It has also been ported to many different operating systems including Microsoft Windows.

TIP: There is a great tutorial available in emacs showing how to use it. Press Ctrl+H to access the tutorial.

Creating a New File:-The command to enter the emacs editor is emacs. You can specify the filename for a new file in two ways:

Specifing a FilenmaeWhen u enter emacs. For, example, u would enter the command emacs new file to create a file named newfile.When u save the text the emacs buffer. For example if u start the emacs withwithout the specifing filename, you’ll be promoted for a filename with u enter this command to save the file.

All editing is done in a buffer. This buffer information is written to disk only when you save the file.

Follow the steps below to learn how to create a file using emacs. Enter emacs to begin the emacs program. The help system is displayed in the file buffer. Briefly read through the help system. When you start emacs without specifying a filename, this

information is displayed.

Press Ctrl+X and then Ctrl+F to search for a file to edit. The prompt Find file: ~/ is displayed. The ~/ represents your home directory (the current directory in this case).

Enter newfile. Because this file doesn't exist, a new file will be created (notice the (New file) designation at the bottom of the screen).

61

Page 62: HISTORY AND DEVELOPMENT OF LINUX22

Enter This is my first emacs file. I will use it to learn how to use the emacs editor on my Linux workstation. Observe how the text wrapped. It wrapped just like most other text editors, but added a backslash (\) to the end of the line to indicate that it wrapped.

Use the arrow keys to move the cursor to the beginning of the second sentence. Press Enter to insert a carriage return and move the rest of the text to the next line. Notice that the continuation character (\) is no longer displayed because the text isn't wrapped.

Now, save the file by pressing Ctrl+X and then Ctrl+S.

Press Ctrl+X and then Ctrl+C to exit the editor and return to the command prompt.

Enter ls -l to verify that mynewfile was created.

Clear the screen, and then enter cat mynewfile to view the contents of the file.

Editing an Existing File:-To open an existing file, you can either: Opening an Existing FileEnter emacs file name from the command prompt.Enter emacs at the commandprompt, press CTRL+S, CTRL+S and enter the filename to open.

You can use the arrow, Home, End, Page Up, and Page Down keys to move the cursor around your text. On some systems, these don't work, so you'll need to use the built-in emacs cursor movement methods shown in the following table.

Press To Move the Cursor

[Ctrl]F One character to the right.

[Ctrl]B One character to the left.

[Ctrl]N To the same position in the next line.

[Ctrl]P To the same position in the previous line.

[Ctrl]A To the beginning of the current line.

[Ctrl]E To the end of the current line.

[Ctrl]V Forward one screen.

[Alt]F To the next word.

[Alt]B To the previous word.

[Alt]A To the beginning of the sentence.

[Alt]E To the end of the sentence.

[Alt]V Back one screen.

[Alt][Shift]< To the beginning of the document.

[Alt][Shift]> To the end of the document.

To undo the previous edits, press Ctrl+X and then U. Repeat this command until you have undone all you want to undo. You can also reload the file from disk if you want to revert to the saved version of the file. This will cause you to lose all changes made, but in some cases, this is what you want or need to do if the file gets really messed up! To revert to the saved version, press Ctrl+X, Ctrl+R, and then enter the filename.

62

Page 63: HISTORY AND DEVELOPMENT OF LINUX22

Learn more about using emacs by following the steps below.

Open a file in the emacs buffer using the emacs file command. (Replace file with the file that you want to open.)

Move around in the file using the arrow, Page Up, Page Down, Home, and End keys. Notice how each of these keys acts on the document.

Now, let's try using the cursor movement keys from the table above this task. If your keyboard movement keys don't work, this is the way you'll have to move around in emacs documents.

Exit emacs without saving any changes you might have made. (Press Ctrl+X and then Ctrl+C; then if changes were made, specify not to save the changes.)

Searching for Text:-The emacs editor allows you to search for a pattern in the file. You can also replace the pattern when you find it if you want.

You can search forward and backward through the file for the specified search string. Press Ctrl+S to search forward; Ctrl+R to search backward. To end searching, press Ctrl+G or Enter.

Replacing Existing Text:-To search and replace text, press Alt+X, and then type replace-string. At the Replace-string prompt, enter the string to search for, and then press Enter. At the Replace-string With prompt, enter the replacement text.

You can also just enter part of the command name, such as repl, and then press Tab. It will finish entering the command for you, or if there is more than one command beginning with those letters, it will present you with a list of commands to choose from.

The emacs editor searches from the cursor location to the end of the file, so if you want to search and replace in the entire file, start from the top of the document.

The pico Editor:-Another simple text editor available on most systems is the pico editor. This editor has limited advanced capabilities, but is very useful for those times when you just need to create a short text file.

The pico editor.

The basic commands are listed at the bottom of the pico editor window. The ^ indicates the Ctrl key should be pressed along with the letter key indicated.

Follow the steps below to learn how to use the pico editor.

Enter pico to start the pico editor.

63

Page 64: HISTORY AND DEVELOPMENT OF LINUX22

Observe the commands at the bottom of the window. These are the basic commands you can carry out in the pico editor. The ^ indicates the Ctrl key.

Enter some text, and then try out the commands listed at the bottom of the window.

Save the file as mypicofile.txt (Ctrl+O).

Exit the editor (Ctrl+X).

1. What are two ways you can specify the filename for a new file in emacs?

Ans: When you enter emacs and when you save the text in the emacs buffer.

2. How do you save a file in emacs?

Ans: Press Ctrl+X and then Ctrl+S.

Lesson 3 Examining File Contents

Lesson Objective

In this lesson, you will:

List the ways of viewing the contents of a file and describe how the command displays the file.

Overview:-Linux provides a host of commands with which to examine files. Some of the commands that you'll use most often are explored in the following table.

Common CommandCommand Syntax Descriptioncat cat file Displays the contents of the file or files listedin the command argumentfile file filename Display the file type such as directory or ASCII text. If the file type is ASCII text, u can use

the commands in the table to view the contents.head head filename Display the first 10 lines of the file by default. Use the number option(for example, -20) to

display a different number lines.less less filename Display the contents of a file, one screen at a time. Press [spacebar] to move forward a full

scree and [enter] to move one line at a time.more more filename Dislay the content of a file, one screen at a time. Press [spacebar] to move forward afull

screen, and {enter] to move one line at a time or B to move backword through the file. tail tail filename Displays the last 10 linesof a file by default. Use the –number option(for example, -20) to

display a different number of lineswc wc –option

filenameWithout any option, displays the number of lines,words and characters in a file. The -c option display the number of character –l the number of lines and the –w the number of words in the file.

TIP: Check out the man page on less for additional movement keys.

TIP: For all of the commands in this table, you can specify multiple filenames for the command argument.

1. List at least three ways of viewing the contents of a file and describe how the command displays the file.

64

Page 65: HISTORY AND DEVELOPMENT OF LINUX22

Ans: The cat command displays the entire file at once. The more command displays the file one screen at a time. The less command displays the file one screen at a time and enables you to move forward and backward through the file. The head command displays the first few lines of the file. The tail command displays the last few lines of the file.

Lesson 4 Redirection

Lesson Objectives

In this lesson, you will:

Identify the symbols for redirecting standard input, standard output, and standard error. Identify the command that is used with the redirection command to send output from the keyboard to a new or existing

file.

Introduction:-Most Linux commands require input and produce output. The shell is responsible for setting up the defaults that a command can use for receiving input or sending output. These include:

Receving and Sending DefaultsStanard input is the source for command input. By default, this is the keyboard.Standard output is the destination for command output. By, default this is the screen.Standard error is the destination for the error message. If a command produces error, the error are sent to standard error, which , by default, is the screen. The shell enables you to define, in a variety of ways, the source of a command's input or the destination of a command's output. Most of the time, you will use the less than symbol (<) for input redirection and the greater than symbol (>) for output redirection.

Input Redirection:-The input redirection symbol (<) tells the shell to redefine standard input as something other than the keyboard; usually a file. There aren't too many examples where this is used. You might use it when you have a document that you want to email to someone or when the contents of an existing file are being redirected into another command for processing.

Output Redirection:-The output redirection symbol (>) tells the shell to redefine standard output as a file instead of the screen. For example, ls >list causes the shell to send the output of the ls command to the file list. If the file doesn't exist, the shell creates it. If it does exist, the shell initializes the file, preparing it to receive the output of the command.

Warning: It is easy to overwrite a file when you use output redirection. In the example, cat test > test, the first thing the shell does is initialize or delete the contents of the file test. It then writes the output of test (which is now empty) to the file test. Because test is empty, the results of this command would be an empty file named test. A very useful feature called noclobber helps prevent accidentally overwriting a file. To set noclobber, type set -o noclobber; to turn it off, enter set +o noclobber.

Standard Error Redirection:-The standard error redirection symbol (2>) tells the shell to redefine standard error as a file rather than the screen. The command ls nofile 2> errorfile causes the shell to send any error messages resulting from the ls nofile command to the file errorfile, rather than to the screen. If no error messages are generated, then an empty file is created.

Using Output Redirection to Create Files:-Using the echo and cat commands in conjunction with output redirection enables you to create files. The echo command prints whatever you type to standard output, normally the screen. You can create files by redirecting the echo command to a file.

The cat command can be used with redirection to send output from the keyboard to a new or existing file. When the cat command is given no input file, the input defaults to the keyboard. Use Ctrl+D to determinate the input.

65

Page 66: HISTORY AND DEVELOPMENT OF LINUX22

One of the purposes of the cat utility is to merge the contents of several files into a single file, or to concatenate the files. The cat command is short for concatenate. Using the cat utility in conjunction with output redirection concatenates files. For example, cat file1 file2 > file3 places the contents of file1 and file2 into file3.

Appending to a File:-The append redirection symbol (>>) also redirects standard output. However, the shell doesn't initialize the receiving file if the file already exists. Instead, the new output is appended to the end of the receiving file. For example, the list file was created by typing ls > list. To append the contents of the testfile file to the end of the list file, enter cat testfile >> list. If the receiving file doesn't exist, the shell creates the file, as it does with a > symbol.1. What are the symbols for redirecting standard input, standard output, and standard error?Ans: The standard input redirection symbol is <, the standard output redirection symbol is >, and the standard error redirection symbol is 2>.

2. What command is used with the redirection command to send output from the keyboard to a new or existing file?

Ans: The cat command.

CHAPTER 8 Archiving Files

Lesson 1 Archiving Files with tar

Lesson Objectives

In this lesson, you will:

Identify the three primary reasons for creating tape-archived files. Explain what tar is.

Introduction:-Tape archiving is a feature that enables you to transfer data to and from remote media, such as a disk, tape drive, or CD-ROM. Tape archiving is not limited to sending information to a remote device; you can create tape archives in your current directory or any other designated location on your system.

Creating tape-Archived FilesThere are three primary reasons for creating tape-archived files:

To back up files and directories. To transfer information to the tape, disk or other media. To prepare information as a single file to be sent across a network.

The system administrator is usually responsible for backup procedures. However, if you're working with sensitive or important information that needs to be backed up more often than the scheduled backup, you can use the tape-archive feature to accomplish this. If you need to share data or transfer data to a user who isn't on your system or who isn't networked to your system, you can use tape archiving to transfer the data to disk, tape, or other media and then deliver the information to the user.

Finally, if you need to send data, such as a complex directory structure across a network, you can create a single tape-archived file containing the entire structure and send it as a single file. This is a much more efficient and secure method of accomplishing this transfer, thus decreasing the chances of information being lost in the process.

Creating Tape Archives

To create a tar file, use the tar command with the syntax

tar -cf destination source

The -c option indicates that you're creating a tape-archive file. The -f option indicates that you're creating a tape-archive file with the name that follows. The destination is the location and name of the tape-archived file. The destination might be a remote device, your current directory, or another location. The source is the location and name of the filename or directory to use to

66

Page 67: HISTORY AND DEVELOPMENT OF LINUX22

create the tape-archive file. If a directory is specified, all subdirectories and files contained within the subdirectories will also be archived.

To append to or update a tar file, use the -r option. If the source is a new file, the file will be appended to the end of the tar file. If the file is a new version of a file already in the tape archive, the old file will be replaced with the new version.

When you include the -v option, the tar command displays to the screen the files and directories upon which it's operating. If you're creating a tape archive and you use the -v option, the names of the files being archived or copied will be preceded with an aa

Formats of the tar Command.

TIP: You can edit a tar file by adding or removing a file from a tar file.

Listing the Contents of a tar File

After you create a tar file, you should verify that the files made it into the tar file. You can do this with the command

tar -tvf tarfilename

To display the contents of a tar file, use the -t option. Using this table of contents option (-t) will produce a listing of the files and directories contained in the tar file. The listing will be similar to what you get with the ls command. The name of the tar file must be preceded with its location or with its device name. To display a long listing of the contents of the tar file, use the -v option.

Restoring tar Files and Directories:-To restore a file or an entire directory structure from a tape archive, use the -x option. The command, tar -xvf source

will restore the entire contents of the source. To restore a portion of a tar file, use,

tar -xvf source path/destination

By using the path and name of the file you wish to extract, you can retrieve specific files and directories from a tar file. You must use the exact path and name that was used when you created the tar file.

Backing Up a Directory Structure:So far, you've seen how to back up and restore single files. Now, let's look at how to back up and restore an entire directory structure.

While there might be times when you need to back up a single file, most often you'll need to back up an entire directory structure or filesystem. The commands are the same as they were for backing up a single file.

Archiving Interactively:-If you wish to verify files that you create or extract with the tar command, use the -w option. The command tar -wcvf destination source creates a tar file interactively. The -w option (wait for confirmation) makes

67

Page 68: HISTORY AND DEVELOPMENT OF LINUX22

the command interactive. Before a file is added to the archive, you're prompted whether to archive the file. You can also make restores interactive as in the command,

tar -wxvf destination source

Scripting Your Backup Procedures:-If you use the tar feature to do frequent backups, you might find it worthwhile to create a script. By including comments and feedback with the appropriate tar commands, you can perform frequent backups of important files and directories by entering the name of your backup script. If you place the script file in a directory within your path, you can perform the backup from any location in your directory structure.

So far, we've just created the archive file in the current directory. However, in most cases, you'll be creating the tar file on another device such as a tape drive or another disk drive. Let's see how you would do this to other devices.

It is also a good idea to check out the tar file to make sure it's readable. You can do so with the command,

tar -tvf tarfilename

1. What are the three primary reasons for creating tape-archived files?

Ans: Back up files and directories; transfer information to a tape, disk, or other media; and prepare information as a single file to be sent across a network.

2. What is tar?

Ans: Tape archive command. Used to back up files and directories, to transfer information to another medium, or to combine several files into a single file for transfer.

Lesson 2 Archiving Files with cpio

Lesson Objectives

In this lesson, you will:

Explain what cpio is. Identify the main reason you need to back up data.

Introduction:-The copy in-out program, cpio, is similar to tar. This command can archive in several different formats, including tar. The cpio command reads the archive as standard output when extracting files from an archive. You can also copy files to another location on the local machine using cpio. The cpio command operates in one of three different modes: copy-out, copy-in, and copy-pass.

Copy-out mode is used to create an archive. It copies files into the archive. A list of filenames is read from a source and cpio writes the archive to standard output or the output destination you specify. Sources include a text file, the output of the find command, output from an ls command, or other sources that list files one line at a time. The format of the copy-out mode is,

source | cpio -ocBv > archive_filename

Copy-in mode is used to get files from an archive. It copies files out from the archive. By default, all files are extracted from the archive. However, you can specify a metacharacter pattern. The format of the copy-in mode is,

68

Page 69: HISTORY AND DEVELOPMENT OF LINUX22

Copy-pass mode is used to copy files from one directory tree to another. It combines the copy-out and copy-in modes without really using an archive. The options used for creating and verifying an archive file are listed in the following table.

Creating and Verifying Options

Option Used Too Create an archive using copy-out mode.B Change block size to 5120 bytes rather than the default of 512 bytes.c Specify ASCII archive format.v List the files processed.t Print a list of the input.Restoring Files with cpio:-The main reason you need to back up data is so that you can retrieve data if a file gets corrupted, deleted, or the like. If you used cpio to move files to another location, you'll need to get the files out of the archive file so you can use them. The format of the copy-in mode is, cpio -icdv < archive_filename

The -i option extracts files from the archive file using the copy-out mode. The d option creates directories if needed to restore files from the archive.

1. What is cpio?

Ans: The copy in-out program, cpio, is similar to tar. This command can archive in several different formats, including tar. The cpio command reads the archive as standard output when extracting files from an archive. You can also copy files to another location on the local machine using cpio. The cpio command operates in one of three different modes: copy-out, copy-in, and copy-pass.

2. What is the main reason you need to back up data?

Ans: So that you can retrieve data if a file gets corrupted, deleted, or the like. If you use cpio to move files to another location, you'll need to get the files out of the archive file so you can use them.

Lesson 3 Archiving Files with Other Utilities

Lesson Objective

In this lesson, you will:

Explain how you can display the contents of a compressed file.

Introduction:-The Linux operating system provides users with the ability to compress the size of files so that the files don't occupy as much space as they normally would. By compressing file sizes, you can:

69

cpio -icdv < archive_filename

Page 70: HISTORY AND DEVELOPMENT OF LINUX22

Reduce the space that seldomly used files occupy. Reduce the size of large files before they are archived or sent over the network.

Add an additional level of protection to a file by compressing and encrypting the file.

To reduce the size a file occupies, use the compress command. The designated file will be reduced in size by roughly 40-50 percent. The name of the file will have .Z appended to it to indicate that it's compressed. If you display a long listing of the file before and after compression, you can see the difference in name and size.

To determine the percentage that a file has been reduced by compression, use the -v option with the compress command. The most advantageous use of file compression for the end-user is that of reducing the size of seldom used, but important files so that the files occupy less space in the user's directory.

Displaying the Contents of a Compressed File:-You can't use the cat command to display the contents of a compressed file. Because of the compression, the file contents have been modified and you are no longer able to view the file using the usual UNIX commands. To view the contents of a compressed file, use the zcat command. The zcat command enables you to examine the contents of a compressed file as though it were in an uncompressed state. The compressed file isn't modified with zcat; it remains compressed.Restoring Compressed Files:-Use the uncompress command to restore a compressed file to its original size and uncompressed state. The file will be expanded to its original state, and the .Z extension will be dropped from the filename.1. How can you display the contents of a compressed file?Ans: With the zcat command.

Lesson 4 Zipping Files

Lesson Objectives

In this lesson, you will:

Identify the other utility used to reduce file sizes. Explain the most efficient way to create a zip file.

Introduction:-Another utility that can be used to reduce file sizes is the gzip command. Files will have the .gz extension added to the filename. In many cases, this utility shrinks files even smaller than the compress command can. To unzip files that were zipped with the gzip utility, use the gunzip utility. The zcat utility is used to view the files in their natural state.

TIP: The gzip command uses the same compression algorithm as the PKZip command does.

Archiving Files with gzip:-In addition to making files smaller, you can use the gzip command to combine several files into a single file. The contents of the source files are piped into the gzip command, and the output is redirected into a gz file.

The zipped file can be used as an archive. You can also use it when you need to transfer several files; you can combine them into a single file, transfer the file, and then unzip them at their destination. You can also zip files before archiving them with tar or cpio.

1.What is another utility used to reduce file sizes?

Ans: The gzip command.

2. What is the most efficient method of creating a zip file?Ans: To cat the files into gzip and redirect the output to another file.

Lesson 5 Examining Backup Issues

Lesson Objective

70

Page 71: HISTORY AND DEVELOPMENT OF LINUX22

In this lesson, you will:

Identify a way of verifying a backup.

Introduction:Now that you have seen how to back up files and directories, let's look at some of the issues surrounding backups. We will examine where you should store your backups and how often you should back up. We'll also discuss how to verify that your backups are good.

Storing Backups

After spending the time to back up your data, you need to properly store the backup media. You should store it offsite in a secured location. There are services with huge storage vaults or you can use a safe deposit box at a bank. If you want to store a set of tapes on site for easy access to restore files quickly, you can do so, but you should also store a set offsite. This is because if there should be a fire or theft, you'll still have your data.

Verifying Backups

Before sending your backups off to secure storage, you should verify that the backup was successful. To do this, you can use the verify option when backing up the data.

1.Where should you store your backups?

Ans: You should store them in a secure offsite location. Optionally, you can store an additional set onsite for quick access.

Troubleshooting Backup and Restore Errors:-Make sure your backup drive is in good working order. Sometimes, if they are out of alignment, your tapes can be read only on the drive they were written with. This can be a problem if you need to replace your drive before restoring the data. You might encounter various backup errors. One that you might encounter is tar: tarfilename: Permission denied. This is usually encountered when you try to back up files logged in as a regular user. You usually need to have root or equivalent access in order to back up files.

Among the restore errors you might encounter is the error tar: Error is not recoverable: exiting now. This catch-all message can mean anything from the tar file is corrupted to the tape drive support isn't loaded

1. List at least two problems you might encounter when backing up and restoring files.

Ans: Answers might include misaligned drives, tapes that can't be read on another tape drive, not enough rights, and damaged backup files.

1. What is a way of verifying a backup?

Ans: You can use the verify option when backing up the data.

CHAPTER 9 Working in X Windows

Introduction to X Windows and GNOME

Lesson Objectives

In this lesson, you will:

Identify the commands that start and exit X Windows. Identify the program that enables you to manage files in GNOME.

71

Page 72: HISTORY AND DEVELOPMENT OF LINUX22

Introduction:-X, or the X-Window System, provides an interface for applications to draw graphical displays under Linux. X also allows applications running on one computer to display their output on another. A desktop environment, such as GNOME or KDE, runs on top of X and provides integrated applications and common programming tools, but requires a Window manager to handle the look and feel of windowed applications. A window manager, such as sawfish or KWin, runs on top of the desktop environment and controls the appearance, display, and movement of windows on the desktop.

X Windows is a standard user interface for Unix and UNIX-like operating systems such as Linux. X Windows enables applications to run within a windowed environment, like that provided on MacOS and Microsoft Windows systems. This environment provides a desktop on your computer screen on which you can work with many windows-each window containing a separate application or task.

There are many X Windows implementations that can run on Linux. One of them, GNOME, is the default choice with the Red Hat Linux workstation or custom installation. The GNOME acronym stands for GNU Network Object Model Environment. Like the MacOS and Microsoft Windows, GNOME provides a desktop environment that is easy to use and configure.

X Windows Servers and Clients

One of the more confusing aspects of understanding X Windows is the terminology used to describe the various parts of the X Windows system. The software that runs on the local machine is called the X Server. The window manager is an X Client that can be run locally or on another machine. Each of the applications you may run under X Windows (Netscape, Xterm, etc.) is also an X Client.

XFree86 is the standard X Server that comes with most distributions of Linux. Other X Servers that work well with Linux include:

X SERVER

Accelerated-X (Xi Graphics) Metro-X (Metro Link)

Window Managers:-GNOME provides a windowed environment compatible with the X Windows standard. As such, it is very configurable. Like other X Windows implementations, GNOME supports installable window managers. Window managers are software packages that control how windows are drawn on the screen and how they behave.

72

Page 73: HISTORY AND DEVELOPMENT OF LINUX22

GNOME extends the basic X Windows functionality, providing many additional features that support ease-of-use and customization, such as the GNOME Pager and drag-and-drop to the desktop.

For a long time, Enlightenment was the only window manager that supported all of GNOME's functionality, although other window managers work with GNOME and support many GNOME features. As time progresses, more window managers support all of GNOME's features. Window managers that work well with GNOME include:

Window Mangers

Sawfish Enlightenment Ice (IceWM) Window Maker FVWM

1. Describe the function of the desktop.

Ans: It specifies to draw boxes, icons, and other window elements.

2. Describe the function of the window manager.

Ans: It specifies the look of the boxes, icons, and other window elements and how they are drawn.

4. What is the standard X Server that comes with Red Hat Linux? What other X Servers are available for Linux?

Ans: XFree86 is the standard X Server. Other X Servers are Accelerated X and Metro-X.

Starting X Windows: The Xconfigurator enables you to configure X Windows to run automatically when you start Linux, or you can opt to start X Windows manually from the command line. To start X Windows from the Linux command line, you simply enter the command startx. This launches GNOME with the currently specified window manager. In some versions

when you first launch GNOME, it is preconfigured to automatically launch two applications: the GNOME Help Browser and the File Manager. In Red Hat 7.0, the GNOME hint dialog box, the GNOME panel, and several desktop icons appear.

losing and Opening Windows:-Windows are opened when you launch an application or open a document from an icon. From a desktop icon, you launch an application or open a document by pointing at the icon and double-clicking (two mouse clicks in close succession). To open icons on the GNOME panel, you need only to single-click. Alternatively, you can choose options from the Main Menu to launch applications.

73

Page 74: HISTORY AND DEVELOPMENT OF LINUX22

Some applications are fully compatible with GNOME features such as the ability to remember their size and location from a previous session. You can click the Window Options button to display window options that enable you to do such things as remember a window's size, location, or other attributes. (Some applications, such as the File Manager, do not support these features.)

You can close a window by clicking its Close button. As shown in the figure below, some windows have other ways to close, such as a Close or Cancel button or a File�>Exit menu

The Minimize, Maximize, and Close buttons

The Main Menu:-The GNOME Main Menu is accessed by clicking on the four-toed foot icon in the bottom-left of the Desktop. The Main Menu displays a list of installed applications and control panels that you can run by selecting them with the mouse. The Main Menu is similar to the MacOS Apple Menu and Windows' Start menu.

74

Page 75: HISTORY AND DEVELOPMENT OF LINUX22

Sizing and Moving Windows:-Sizing and moving windows requires that you drag a portion of the window by using the mouse. To drag, you point, press and hold down the left mouse button, move the mouse pointer to your destination, and release the mouse button. The item you originally pointed at is moved to the location where you dragged it.

To resize a window, you drag one of the window's borders. You'll know when you've positioned the mouse correctly over the window's border because the mouse pointer becomes a different arrow, showing that you can move that border left and right or up and down, and then changes to a hand as you resize the window.

To quickly make a window as large as possible or to hide it, you can use the Maximize or Minimize buttons, respectively. To close the window, use the Close button. To move a window, you point at its caption or title bar (the top part of the window that contains the window title) and use the mouse to drag it to a new location.

Follow the steps below to learn how to size windows:

Open the GNOME Help Browser. Examine the buttons in the GNOME Help Browser window's title area. Three buttons are visible on the

right side of the window.

Click on the Maximize button. The window stretches to fill the screen.

Click on the Maximize button again. Because the window was already maximized, it shrinks back to its former size.

Click on the Minimize button. The window shrinks from sight, but its title still appears in the panel at the bottom of the screen.

In the Task List, click on GNOME Help Browser. The window is restored to view.

Position the mouse pointer on the bottom edge of the window.

While pressing the left mouse button, drag the bottom edge of the window upward, until it is about half its height.

Release the mouse button, and observe how the window snaps to its new size.

Point at the GNOME Help Browser's title bar, and drag the window to the lower-right corner of the screen.

Click on the Window Options button to display the Window Options menu. Different distributions have different wording, but they usually have similar capabilities. For example, Red Hat Linux has a History menu choice and TurboLinux has a Remember menu choice. These are both used to set where the window appears next time you open that window.

Close the menu by clicking outside the menu.

75

Page 76: HISTORY AND DEVELOPMENT OF LINUX22

Close all windows. No windows are displayed now; just the desktop, desktop icons, and GNOME panel are visible.

Activating Windows:-Rather than work within a single text-only screen, in GNOME you will work within multiple windows that represent multiple applications or software tasks. Each window is as likely to contain graphics as it is text.

You still have only one keyboard, however, so it is necessary to have some way to specify where (to which program) you are directing your input when you type. You need to specify which window is active. The mouse provides you with a means to do this. To activate a particular window, text entry box, or some other item on the display screen, you simply move the mouse until the mouse pointer is pointing at the item you want to activate; then you press the main mouse button (typically the left button)-a procedure called point and click. (The right mouse button typically displays a special menu of commands-called a context menu-for the item that you clicked on.)

TIP: In some distributions, a feature known as �implicit focus� is enabled. This means that when your mouse pointer is in a window, it is the active window. However, this doesn�t necessarily bring the active window to the top of the stack. To bring it to the top, you need to click on the title bar. You might need to move the upper window(s) to be able to click on the title bar you want to move to the top

Follow the steps below to learn about activating windows:

From the Main Menu, choose Programs�>File Manager. This opens the File Manager window. From the Main Menu, choose Programs�>Help System. This opens the GNOME Help Browser window.

Using the mouse, point at the title bar of the File Manager window. If necessary, move the Help Browser window so that you can see the title bar of the File Manager window. To move the window, grab it by the title bar and drag it elsewhere. The mouse pointer changes to a hand.

Press the left mouse button. The File Manager window appears to move in front of the Help Browser window. When you click on a window this way, you activate it. Activating a window informs GNOME that you intend to work in that window. Words that you type and commands that you issue will be directed to the active window.

Click the window behind the File Manager window. The Help Browser window becomes active, moving to the front.

The GNOME Panel:-The GNOME Panel provides a convenient way to launch applications and open documents. By right-clicking on the panel, you can get a menu that lets you configure preferences, add applets and menus, or create different panels.

However, it does take up valuable desktop space that might be better used for applications. You can hide the GNOME panel by clicking on one of its Hide buttons, which are located on the right and left ends of the panel. When you hide the panel, all that remains is the Hide button itself, which you can click on a second time to make the panel visible again. There is also an auto hide property available that makes the panel disappear until you point the mouse pointer at the bottom of the desktop.

76

Page 77: HISTORY AND DEVELOPMENT OF LINUX22

The GNOME desktop with the GNOME panel hidden.

It's not necessary to show the panel to access the Main Menu, however. You can right-click on the Hide button to display a shortened version of the Main Menu. (To right-click, you click as normal with the mouse, except that you use the right mouse button instead of the left.)

The Desktop Guide (Pager) and Tasklist:-You can have many windows open on your desktop. This can be a source of some confusion at times, even for experienced users of windowed environments. To make matters a bit more complicated, GNOME enables you to have multiple pages of desktop space, so that your desktop can cover an area larger than your computer screen is capable of displaying at one time. To enable you to track all of the windows that you have open, GNOME provides the Pager and the Tasklist.

The Pager provides a map of your desktop, which can cover a larger area than your actual screen display can handle. In the figure below, for example, you can see that the currently displayed desktop is just ¼ of the actual desktop size.

You can have windows partially on one page and partially on another, but this makes it a bit confusing. If you are interested in trying this feature out, select Sawfish Window Manager�>Workspaces in the Control Center window, and then click on the Toolbox icon on GNOME Panel. In the right pane, select the Edge Flipping tab. You can experiment with the different selections on this page. A better way to use the large desktop is to run separate applications on separate pages, and click on the Pager display to move back and forth between pages, which is the default setup of Pager.

The Tasklist provides a list of applications that you are currently running. By simply clicking on an item in the Tasklist, you can activate the window for that task.

77

Page 78: HISTORY AND DEVELOPMENT OF LINUX22

The Pager.

Different implementations of the software treat some aspects of its functionality slightly differently. That is the case between TurboLinux and Red Hat Linux. TurboLinux uses Enlightenment as the default window manager with certain settings, and Red Hat Linux uses Sawfish as the default window manager with different settings. Even if they had used the same window manager, they could have set up different defaults.

Follow the steps below to learn about using the pager and tasklist.

Open the GNOME Help window. Click on the upper-right square of the Pager. This displays another virtual desktop.

Open another application. Click on the upper-left square of the Pager.

Click on the other squares to display the other virtual desktops and see what applications are open on them (if any).

X Windows Applications:-Because of its GNU heritage, Linux is typically distributed with a large number of free applications. Although each user will have his or her favorites, some of the notable applications include:Notable Application

GIMP—A full-featured graphics editor. Calendar—A time management tool. Gnumeric spreadsheet---Electronic spreadsheet software. GnomeCard---An electronic business card manager.

78

Page 79: HISTORY AND DEVELOPMENT OF LINUX22

Netscape Navigator---Web browser software. LInuxconf---The Linux configuration program (requires root access). Gnome mines---This and several other games are built with Red Hat Linux.

Once again, different Linux distributions vary slightly. There are different applications included with each distribution. While some of the applications might be the same, others might not be included, or might be placed differently on the menus.

Exiting X Windows:-To exit X Windows, choose Log Out from the Main Menu. A dialog box is then displayed, from which you can click on No to remain in X Windows, or Yes to exit. The dialog box presents three Action options:

Action OptionsLogout Exits X Windows and returns you to the Linux command lineHalt Exits X Windows. If you have adequate rights to shut down the computer, it shuts the computer down.

Otherwise, it prompts u for a password to shut the computer down .if you do not provides root’s password, it returns you to the Linux command line, logs u out(of Linux), & displays the login prompt.

Reboot Exits X Windows. If you have adequate rights to reboot the computer, it does so. , it prompts u for a password to shut the computer down .if you do not provides root’s password, it returns you to the Linux command line, logs u out(of Linux), & displays the login prompt.

The dialog box also displays an option labeled Save Current Setup. If you check this option, GNOME saves the current window arrangement and any changes that you have made to the GNOME panel, so that they are restored the next time you run GNOME.

When you log out of GNOME, you are returned to the command prompt. You are still logged into Linux, though. If you want to log out of Linux, you will need to enter logout or exit, or press Ctrl+D as you would end any text-based Linux session.

You can also close X Windows with a key sequence. Pressing Ctrl+Alt+Backspace simultaneously will close X Windows and return you to the command line.

1. What are the commands that start and exit X Windows?

Ans: The startx command starts X Windows. To exit X Windows, you choose Log Out from the Main menu.

2. What program enables you to manage files in GNOME?Ans: The File Manager program enables you to perform windowed file management, such as dragging and dropping files to copy or move them.

Lesson 2 Managing Files and Filesystems

Lesson Objectives

In this lesson, you will:

Explain how to copy or move files in the File Manager. List the viewing options available in the File Manager window.

Introduction:-The GNOME File Manager window contains two panes. The left pane contains an outline view of your computer's filesystem. The right pane displays the contents of the directory that is selected in the outline pane. You select a directory by clicking on it. The right pane updates to show the files in that directory. You can click on plus signs (+) in the outline view to expand the outline at that location to show subdirectories. You click on minus signs (-) to collapse the outline again.

79

Page 80: HISTORY AND DEVELOPMENT OF LINUX22

The File Manager.File Manager View Options:-You can customize the view in the File Manager's right pane. Buttons in the File Manager window enable you to select the viewing option you want:Viewing OptionsIcons (Defaults view) displays file using large icons.Brief Displays file & directories in a vertical list.Detailed Displays a vertical list (list brief) but with additional information listed in columns.Custom Also provides a vertical list, but u can customize what type of information will be shown for each file.In the vertical list views, you can specify which column of information will be used to sort the list by clicking on that column's title. You can reverse the sort order by clicking on the column title again. You can change the width of columns by dragging the dividing line between the titles.

80

Page 81: HISTORY AND DEVELOPMENT OF LINUX22

File Manager scroll bar.

Sometimes, there might be more files than there is room to display them. In such cases, the File Manager will display a scroll bar that enables you to change which portion of the list you are viewing. The scroll box slides up and down the scroll bar to represent your location within the list.

Copying Files:-One way to copy a file is to display the file's context menu by right-clicking on the file. Then, choose Copy from the menu. The Copy dialog box is displayed. Type in the path where you want the file to be copied. If you want to rename the file when you copy it, include the new name of the file at the end of the path. When you click on OK, the file is copied to the location you specified.

The Copy dialog box.

Follow the steps below to learn how to copy a file: In the File Manager, right-click on the file icon that you would like to copy. A context menu is

displayed. Choose Copy. The Copy dialog box is displayed. The dialog box contains one text box. You are

prompted to enter the file's destination into this text box. If you do not know the exact path of the destination, you can browse to it by clicking the Browse button.

The Find Destination dialog box is displayed. A text box near the bottom of the dialog box shows the current directory.

Click on the Selected Directory button, located near the top of the dialog box. When you click, a drop-down menu that contains a list of the directories between the current directory and the root directory (/) is displayed.

Choose a directory from the drop-down menu. Click on the OK button. The path to your chosen directory is displayed in the text box. (Alternatively, you could have typed this path in directly.)

Click on the OK button. The file is copied to your chosen directory.

Creating Directories:-To create a directory, display the location where you want to create the directory. In the right pane of the File Manager window, right-click to display the context menu, and choose New Directory. You will be prompted to enter a name for the directory. Enter the directory name and click on OK.

The Create A New Directory dialog box.

Follow the steps below to learn how to create a directory. In the right pane of the File Manager window, right-click on a blank area. A context menu is displayed.

81

Page 82: HISTORY AND DEVELOPMENT OF LINUX22

Choose New Directory. The Create A New Directory dialog box is displayed. You are prompted to enter a name for the new directory. Give the new directory a name.

Click on the OK button. The new directory is displayed in the right pane.

Renaming Files and Directories:-To rename a file, click once on its name (which, depending on the type of view that is selected, appears below or next to the icon in the File Manager's right pane.) A border will appear around the name to indicate that you have selected it. Simply type to enter a new name for the file, and click away from the file or press the Enter key to deselect it. Follow the steps below to learn how to rename a file.

Click on a file icon to select it. Click on the text beneath the icon. A selection box is displayed around the text. Type the new name. Press the Enter key. The file now has the new name. Directories can be renamed the same way.

Drag-and-Drop File Management:-If you are used to using a mouse, the simplest way to copy files is to display two locations-the source and the destination-and then drag the file from its source window to its destination. (You can launch two instances of the File Manager to display both locations at the same time.) By default, dragging files moves them. By holding down the Ctrl key when you drag, you can force the file to be copied, instead of moved.

Dragging to move a directory to the desktop.

Deleting Files and Directories:-To delete a file, select the file and right-click to display its context menu. Choose Delete from the menu. When you are prompted, confirm the deletion by clicking on Yes. When you delete, copy, move, or perform other actions on files, you can work with more than one file if you select multiple files first. To select multiple files, click on the first file; then, while holding down the Ctrl key, click on subsequent files to add to the selection. Then, perform the command as you normally would. Mounting and Unmounting Filesystems:-To mount and unmount filesystems within GNOME, you can open a terminal window and use the command-line within GNOME, or you can use the Disk Management utility. To run the Disk Management utility, choose Programs�>System�>Disk Management from the Main Menu. The following window is displayed.

82

Page 83: HISTORY AND DEVELOPMENT OF LINUX22

The Disk Management utility.

This window displays devices that you can mount or unmount, and provides you with buttons to mount, unmount, and format the medium controlled by the specified device. (Mounting and unmounting use the same button. When a device is mounted, the button is labeled "Unmount," and when a device is not mounted, the button is labeled "Mount.")

As when you are at the command line, you must have root access or the equivalent to mount and unmount other filesystems. Once mounted, you access mounted volumes through the /mnt path. To unmount a volume, you must first close any files that are stored on that volume. (This includes any files that you might have opened before you started X Windows.)

1. How do you copy or move files in the File Manager?

Ans: One way is to right-click on the file and choose Copy or Move. You then enter the destination in the dialog box and click on OK. Another way is to drag the icon to a window that is displaying the directory you want to copy it to. Normally, dragging moves a file, but you can hold down the Ctrl key while you drag to force the file to be copied instead.

2. What viewing options are available in the File Manager window?

Ans: Icons, Brief, Detailed, and Custom.

Lesson 3 Customizing X Windows

Lesson Objective

In this lesson, you will:

Identify the program that enables you to customize the appearance and behavior of GNOME windows.

Introduction:-Many GNOME settings are customizable. You can configure GNOME settings through the GNOME Control Center, which you can launch by clicking on the toolbox icon on the GNOME panel.

Configuring Sawfish:-Sawfish is the default window manager used with the Red Hat 7.0 GNOME desktop. The Configuration Tool For Sawfish enables you to display the Sawfish Configurator. With this tool, you can change various aspects of the Sawfish window manager.

1. What program enables you to customize the appearance and behavior of GNOME windows?Ans: The GNOME Control Center enables you to customize the appearance and behavior of GNOME.

Lesson 4 Configuring X Windows

83

Page 84: HISTORY AND DEVELOPMENT OF LINUX22

Lesson Objectives

In this lesson, you will:

Identify the utility used to configure the Xfree86 X Server. List the actions performed by the Xconfigurator.

Introduction:-The XFree86 X Server is configured via the XF86Config file, located in the /etc/X11 directory. The Xconfigurator utility provides a menu-driven interface to the creation of an XF86Config file. Xconfigurator is automatically run during the installation process. Xconfigurator can also be used to configure the X Server after installation.

Xconfigurator performs the following actions:

Xconfigurator Actions

PCI probe Monitor Setup Video Card Probe And Mode selection Configuration Test XF86Config File Output

Once the configuration process is complete, you can start the X Server by entering startx at the Linux command line.

Follow the steps below to learn how to start Xconfigurator:

Log in as root. Enter Xconfigurator to launch the Xconfigurator. A Welcome screen is displayed.

With OK selected, press Enter to begin the configuration process. Select the appropriate settings for your monitor and accept all defaults until you get to the video modes. You don't want to change anything except the resolution.

Using the Tab and arrow keys, move to the 24-bit column and down to the 640 x 480 option. Press the Spacebar to mark this option. Press Tab to select OK, and then press Enter. This will change the resolution to 24-bit 640 x 480.

When prompted, if you can see the box, click on Yes. When prompted to boot into X, click on No, and then click on the OK button.

Enter startx to restart X Windows and verify that the resolution was changed.

If the warning message You Are Running The GNOME File Manager As Root is displayed, click on the OK button.

XF86Setup Utility:-In most cases, you'll want to use the Xconfigurator utility to make changes to your X Server setup. However, you might want or need to use a different utility in certain cases. Another utility for working with the XFree86 server is XF86Setup. This is a graphical configuration utility for XFree86. It is used to perform the initial setup of the X server. It is also used to make changes to that configuration.

It initially starts with the VGA 16 server. You can then enter your configurations. Then, the appropriate server for the hardware is started and the configuration settings are saved to the /etc/X11/XF86Config file.

For more complete information on using this utility, visit www.xfree86.org/3.3.6/QuickStart.html. This site contains the Quick-Start Guide to XFree86 Setup. Among the topics in this document are:

Using XF86Setup Running XF86config

84

Page 85: HISTORY AND DEVELOPMENT OF LINUX22

Fixing the XF86Config file

Running xvidtune

Troubleshooting

Follow the steps below to examine the XF86Setup utility: Log in and start X Windows. Open a Web browser and access the Quick-Start Guide to XFree86Setup at

www.xfree86.org/3.3.6/QuickStart.html. This guide explains how to configure XFree86.

Read through Sections 1 and 2. Section 1 explains what information you need before you start and Section 2 provides an overview of the tools used to configure the X server. The XF86Setup, xf86config, and xvidtune are the three tools that can be used to set up XFree86.

Read through Section 3, which describes how to use XF86Setup. The mouse, keyboard, card (video card), modeselect, and monitor are the configuration areas that can be configured through XF86Setup.

Read through Section 7, which describes some of the problems you might need to troubleshoot.

1. What utility is used to configure the XFree86 X Server?

Ans: Xconfigurator.

2. What are the actions performed by the Xconfigurator?

Ans: PCI Probe, Monitor Setup, Video Card Probe and Mode selection, Configuration Test, and XF86Config File Output.

Lesson 5 Choosing and Changing Window Managers and Desktops in Red Hat

Lesson Objectives

In this lesson, you will:

List the window managers that work well with GNOME and KDE. Identify which utility is used to change the default desktop environment.

Introduction:-Linux offers the flexibility to configure both window managers and desktop managers. Different window managers provide different features geared towards making X Windows easier to use. Desktop managers do the same thing, but they also support different programming toolkits, providing additional capabilities to X Windows clients.

Switching Window Managers The window manager is charged with displaying the windowed applications themselves, managing the resizing and relocation of the windows, and handling general window-specific tasks. Window managers that work well with GNOME and KDE include:Window Mangers

Enlightenment IceWM Window Maker FVWM After Step

In the GNOME Desktop, the Window Manager Capplet can be used to switch the window manager. In KDE, the window manager can be changed by editing the KDE startup script.

Switching Window Managers in KDE:-In KDE, the window manager can be changed by editing the KDE startup script. In a Red Hat Linux 7.0 system, you can find the kde startup script, startkde, in the /usr/bin directory. Any text editor can be used to modify the file. The window manager information is contained at the end of the file. It is this section that you will need to alter in order to change window managers.

85

Page 86: HISTORY AND DEVELOPMENT OF LINUX22

The X Window system with the KDE desktop and kwm window manager.Switching Between GNOME and KDE Desktops:-The desktop environment is a user-friendly set of GUI applications and desktop tools to be used in conjunction with a window manager for the X Window System. The desktop environment provides the underlying graphics subsystem for rendering application windows, buttons, and other elements of the user interface. The two prevailing desktop environments are GNOME (GNU Network Object Model Environment) and KDE (K Desktop Environment). Modern versions of Red Hat Linux include both GNOME and KDE and allow you to configure which desktop environment to use.

GNOME is the default desktop environment in Red Hat Linux 7.0. However, some users prefer to use the KDE desktop. The default desktop environment can be changed by using the switchdesk utility. Switchdesk functions as both a command-line application and an X Windows client, but the change does not become effective until the user restarts X Windows. Switchdesk stores the desktop environment setting in the ~/.Xclients-default file. If this file doesn't exist, the system-wide default setting is used.

A third desktop option, Another Level, may also be available in the switchdesk utility. Another Level is most similar to the original Linux desktop environment, and is sometimes preferred by veteran users. Generally speaking, GNOME or KDE offer a much larger feature set and tend to be much easier to use.

Change the Desktop Setting to GNOME:-You need to open an Xterminal to run the switchdesk command. Once inside the terminal window, just type switchdesk, which spawns the switchdesk program in another window. You can also access the command line by pressing Ctrl+Alt+F2 and then typing switchdesk. This produces the same result as an Xterminal.

TIP: If you want to switch to another virtual terminal and you are in the GUI rather than at the command line, press Ctrl+Alt+F2 to access the second virtual terminal (instead of pressing Alt+F2 as you would at the command prompt). The X terminal is represented by F7 (and if you are running a second instance of X, it would be F8).

1. What are the window managers that work well with GNOME and KDE?

Ans: Enlightenment, IceWM, Window Maker, FVWM, and AfterStep.

2. Which utility is used to change the default desktop environment?

Ans: The switchdesk utility.

Lesson 6 Remote X Window Access

86

Page 87: HISTORY AND DEVELOPMENT OF LINUX22

Lesson Objective

In this lesson, you will:

List the options available for a remote log in.

Introduction:-One of the most useful features of the X Windows System is the ability to run X Clients on remote X Servers. One of the original reasons for this functionality was to allow users to access an application on a powerful server computer, but to view the application's graphical output on their local machine. When an application is launched on a remote machine, all of the application processing is performed on the remote machine. Only the user interface processing and graphics display is performed on the local machine. This concept allows for the creation of X Terminals or simple hardware terminals that run X Servers, which then connect to more powerful server computers to run the X Client applications.

Displaying X Applications on Remote Hosts

One of the reasons for the popularity of the X Window system is that it can display an X Application on a remote host. Through X, you can seamlessly access one workstation from another that is running applications. Even if the other system is running a different operating system, you can still display applications on them!

If you don't have secure shell access (ssh), the following is another way of accessing remote hosts. Before ssh, this is how it had to be done. Now, if possible, it is recommended that you use ssh, which does automatic, encrypted X11 forwarding.

This method uses X11's client-server architecture to run the server on one machine and the client on another machine. Through the xhost program you grant permission to host applications to other machines. Use the command xhost +remotehost to enable permission to display remote applications. To disable permission to display remote applications, use the command xhost -remotehost. On the remote machine enter the command: export DISPLAY=your.localmachine.name:0.0 to display a shell to another host.

After running this command, that shell's display is set to the remote machine specified. Any commands run in that shell are then displayed to the remote machine.

1. What options are available for remote log in?

Ans: Options include ssh, telnet, and rlogin, but ssh is recommended for security purposes.

CHAPTER 10   Printing Files

Lesson 1 Configuring a Local Printer

Lesson Objective

In this lesson, you will:

Explain the difference between a local printer and a remote lpd printer.

Introduction:-When Linux is installed, you have the opportunity to install a printer if it detects a local printer. You can also add printers after installation using the Print system manager in X Windows.

A local printer is attached directly to your Linux workstation via a parallel or serial port. A remote lpd printer is a printer attached to another Unix or Linux machine elsewhere on the network. SMB/Windows 95/98/NT printers are attached to a Windows 95/98 or Windows 2000/NT machine. NetWare printers are on a NetWare network. For any except for the local printer,

87

Page 88: HISTORY AND DEVELOPMENT OF LINUX22

you'll need to know the name of the system to which the printer is attached and the queue name. You'll also need to have an account on that system to get access to the printer.

Selecting a Linux-Compatible Printer

The standard page description language (PDL) supported by Linux is PostScript. PostScript printers feature complete printing support because PostScript Printer Definitions (PPDs) describe and provide access to printer specific features. PPDs need to be manually installed in order to gain full access to the device. Devices that support only PCL (Printer Control Language) do not interpret PostScript. Such printers require translation to their supported PDL, which is usually done using GhostScript. GhostScript converts the PostScript command generated by a Linux application into a supported PDL.

For information about specific distributions of Linux and installation of printer drivers, visit the Web site of the specific distribution. The specific distribution will be the best resource for support or questions related to setup.

You also need to determine just how much printing you will be doing and what you will be printing. If you are printing mainly text documents, a laser printer will most likely be your best investment. If you require color output, you will probably want an inkjet printer. Color laser printers are still quite expensive. Inkjet printers tend to cost more to print per page as the consumables (print cartridges for the most part) are more expensive per page than the consumables for a laser printer (toner and drum, usually).

Stair-Stepped Text

An option available when creating a new printer is to Fix Stair-stepping Text. This refers to the way text is printed by default-at the end of a line of text, a line-feed is issued, but no carriage return is sent. This results in the next line beginning one character to the right of where the previous line ended. See the figure below for an example of this effect.

Most printers are built for DOS applications where a carriage-return and line-feed are both sent at the end of each line. UNIX systems just send line-feed at the end of each line. This selection sends the carriage-return along with the line-feed so that the next line begins where it should, not directly below where the previous line ended.

Follow the steps below to learn how to create a printer spool:

Log in as root and start X Windows. If necessary, click on the OK button to close the Warning box. You have to access X Windows as root to

use the Print System Manager. Linux warns you that you're logged in as root and can damage your system.

Click on the Terminal Emulation Program icon (monitor with footprint) on the GNOME panel, and at the command line, enter printtool. Press the Enter key. The Print System Manager is displayed.

If prompted, click on Ignore to acknowledge the Samba and NetWare messages.

Click on the Add button to add a new printer entry. Local Printer is selected by default. Click on the OK button.

Linux attempts to auto-detect the local printer. Read the message and click on the OK button. The Edit Local Printer Entry box is displayed.

88

Page 89: HISTORY AND DEVELOPMENT OF LINUX22

Click on Select to specify the printer type.

Select your printer from the list and check the following three options: Send EOF After Job To Eject Page (if you get an unwanted blank page at the end of your print job, uncheck this option), Fix Stair-stepping Text, and Fast Text Printing (if your printer is not a postscript printer). Click on the OK button.

Click on the OK button to create the print spool entry.

Choose lpd�>Restart lpd. This will restart the local printer daemon and activate your configuration changes.

1. What is the difference between a local printer and a remote lpd printer?

Ans: A local printer is attached directly to a Linux workstation via a parallel or serial port. A remote lpd printer is a printer attached to another Unix or Linux machine elsewhere on the network.

Lesson 2 Printing

Lesson Objectives

In this lesson, you will:

Explain what the lpq command does. Explain what the pr command does.

Introduction:-To get your files from disk or standard output to the printer, you'll need to use the lp or lpr commands. The lp command sends data directly to the printer port; this can usually be done only by the root user and only if lp is installed. Everyone else will need to use the lpr command set. You can also redirect standard output to the device (cat file > /dev/lp0).

The lpr Command:-When you enter the lpr command, the file you specify to print is actually copied to a spool directory where it waits until the printer can print it. A spool directory is defined when the printer is installed.

A Linux daemon, lpd, handles all print jobs. It takes over after you submit the job with the lpr command and tells the printer how to print the file. After lpd is alerted that a file is to be printed, it starts a copy of itself, which prints the file. The original copy of lpd waits in the background to process more printing requests; this enables queuing of multiple print jobs.

The syntax of the lpr command is lproptions filename. Unless you have set an environmental variable (PRINTER) to specify the default printer name, you'll need to use the -P option to specify the printer name. If you don't specify a filename as the argument to the lpr command, it waits for input from standard input (the keyboard). Some examples of using the lpr command to print are shown in the following animated tip.

Using the Ipr Command

Command Descriptionls>lpr –p lp0 Redirects the file listing to the printer named lp0.cat filel>lpr –p lp0 Redirects the contents of file 1 to the printer named lp0.pr -145 filel>lpr Formats the file1 to 45 lines per page and then redirect the output to the default printer defined in the

PRINETR environmental variable.The lpq Command:-The lpq command is used to view the print queue. This can be useful to see how many print jobs are scheduled ahead of yours or to see if your job has been sent to the printer; it won't be in the queue when it has been sent. The output of the lpq command is shown in the figure below.

89

Page 90: HISTORY AND DEVELOPMENT OF LINUX22

The output of the lpq command.The lprm Command:-If you need to cancel a job that has been submitted, use the lprm command. To delete all of your jobs in the queue, you can enter lprm. To delete a specific job, find the job number by issuing an lpq command, and then enter lprm #, where # is the job number. The lprm command without any options deletes the last job you submitted.Follow the steps below to learn how to print a file.

Log in. Enter cat myletter to view the contents of the file you'll be printing. This can be useful to make sure of what you are printing.

Enter lpr -P "yourprintername" myletter. The -P option specifies which printer to print to. The printer name is lp (the default printer name when Linux was installed).

Enter lpq -P "yourprintername" to view the print queue for the printer "yourprintername." Record the job number for your print job.

Enter lprm -P "yourprintername" job_number to remove your print job from the queue (where job_number is a numeral). Display the queue again to verify that the job was deleted.

Enter export PRINTER="yourprintername" to set this printer as your default printer. If you do this, you don't need to specify the printer name in each of the lp commands.

Send myletter to the printer using lpr myletter. Then, view the queue with lpq, and remove your print job with lprm.

Formatting Output for Printing:-The pr command is known as the print files command. It is generally used in combination with commands that send output to a printer. By default, the pr command sends its output to the terminal screen.

The pr command applies a general format to files before they're printed. Included in the pr format is a header containing the page number, filename, date, and time. Also set by the pr command is a default page length of 66 lines.

pr Options:-The syntax of the pr command is pr[-options] filename(s). There are many options available for use with the pr command. Refer to documentation for a complete rundown on the options (man pr). You'll use a few of the most common options so you get the feel for what you can do with this command.

One of the options is to change the page length for your output. This option is -l#, where # is the number of lines per page. A header is printed on each page of the output.

Another option allows you to change what is included in the header at the top of each page. This option is -h followed by "new header text" where the text between the quotes replaces the filename in the default header contents.

TIP: You need the quotes only on the �h option if your header text includes spaces.

Piping:-Just as it is possible to redirect output to a file, it is also possible to redirect output to another command. Pipes are used to combine commands on a single command line, enabling you to use the output of one command as the input to another.

The pipe symbol is a vertical bar ( | ) that you type between two commands. For example, ls|more enables you to look at a large directory listing one screen at a time.

Sometimes, it is necessary to send output from a command both to a file and the screen. To achieve this, you combine the tee construct with a pipe. For example, ls -l|tee myfile sends the output of ls -l to the screen and to the file, myfile.

Using pr with Piping

When you format your output with the pr command, you can send the formatted output to a file to be printed using redirection (>) or pipe the formatted file directly to the printer using the lpr command.

For example, pr -l45 sales>sales.out creates the sales.out file, which is then formatted and ready for printing. pr -l45 sales|lpr sends the formatted sales file directly to the default printer

1. What is the lpq command used for?

90

Page 91: HISTORY AND DEVELOPMENT OF LINUX22

Ans: The lpq command is used to view the print queue. This can be useful to see how many print jobs are scheduled ahead of yours or to see if your job has been sent to the printer.

2. What is the pr command used for?

Ans: The pr command is known as the print files command. It is generally used in combination with commands that send output to a printer. By default, the pr command sends its output to the terminal screen.

Lesson 3 Managing Print Spools and Queues

Lesson Objective

In this lesson, you will:

Explain what the lpc command does.

Overview:-You already learned about two commands for managing print jobs-lprm and lpq. In this topic, you'll learn about the lpc command.

The lpc command is used to control the operation of the line printer system. Each line printer configured in the /etc/printcap file can be managed. Through lpc, you can perform the operations described in the following table.

Use this Option To

abort all printer Terminate the current printer daemon and disable printing to the specified printer.

clean all printer Remove files that can't be printed from the specified print queue.

disable all printer Disable a printer queue.

down all printer message Disable a printer queue and add the message to the printer status file.

enable all printer Enable the specified print queue.

exit or quit Exit lpc.

restart all printer Attempt to restart the printer daemon for the specified printer.

start all printer Enable the print queues and start the print daemons for the specified printer.

stop all printer Disable the specified printer daemon after the current jobs have finished printing.

status all printer Display the status of the specified printer.

topq printer jobnumber users Move the specified job to the top of the queue.

up all printer Enable print queues and restart daemon for the specified printer.

hold Hold the specified job.

holdall Hold all jobs.

move printer Move jobs to a new queue.

redirect Redirect jobs.

redo Redo a job.

release Release a job.

91

Page 92: HISTORY AND DEVELOPMENT OF LINUX22

reread LPD reread database information.

defaultq Specify default queue for LPD server.

Follow the steps below to learn about managing print spools and queues:

Log in. Enter lpc status to display the current status of the printer. Enter lpc to enter the lpc command mode.

Enter help to display the options. Enter quit.

Print at least three print jobs.

Enter lpq and record the job numbers.

Enter lpc topq and then type the highest job number recorded above, and press the Enter key to move the last job printed to the top of the queue.

Enter lpq to verify that the job moved to the top of the queue.

Enter lpc hold to place the current job on hold. To hold a specific job, enter the job number along with this command. Enter lpc release to remove the hold placed on the job.

Enter lpc down printername where printername is the name of your printer. This will disable both queuing and printing for the specified printer.

Enter lpq to view the status of the print queue. Enter lpc up printername. Enter lpq to verify that the print queue is active again.

1. What is the lpc command used for?

Ans: The lpc command is used to control the operation of the line printer system.

Lesson 4 Configuring Remote Printers

Lesson Objective

In this lesson, you will:

Compare the process of printing to a local and to a remote printer.

Introduction:-In a networked environment, users of a Linux system can print to remote printers via the Linux print system. When you enter the lpr command, the file you specify to print is actually copied to a spool directory where it waits until the remote print server can print it.

Setting Up a Printer Spool for a Remote Printer

92

Page 93: HISTORY AND DEVELOPMENT OF LINUX22

In order to print to a remote printer, a printer spool needs to be created on the local system that specifies the remote printer. The Print System Manager, appropriately named printtool, is used to set up this spool.

Follow the steps below to learn how to create a printer spool:

Log in and enter startx. Click on the Terminal Emulation icon on the GNOME panel, and at the prompt, enter printtool. The Print System

Manager is displayed. Click on Add to add a new printer entry. Choose Remote Unix (lpd) Queue from the list of possible queues. Enter the appropriate information about the printer into the Queue Entry dialog box. Click on Select to specify the printer type. Select your remote printer from the list. Check Send EOF After Job To Eject Page and Fix Stair-stepping Text. Click on the OK button twice to create the print spool entry. Choose lpd�>Restart lpd. This will restart the local printer daemon and activate your configuration changes.

Printing to the Remote Printer:-Once a printer spool is set up for printing to a remote printer, the print process is identical to the local printing process. Let's print to the printer attached to the classroom server.

Managing Remote Print Jobs

Just as you can manage local print jobs to remove jobs from the queue, hold jobs, or re-order jobs, you can manage remote print jobs. You might not be able to do this as a regular user and might require someone with administrative access to the remote printer to do this for you. However, you should be able to hold or delete your own jobs

Follow the steps below to learn how to manage print jobs:

Log in. Create a text file using your favorite Linux text editor and save it as myfile.txt. Enter lpr -P "yourprintername" myfile.txt. The -P option specifies which printer to print to.

Enter lpq -P "yourprintername" to view the local print queue for the remote printer.

1. How do you print to a local printer and to a remote printer?

Ans: In printtool, specify whether the printer is local or remote, and then specify the remote system where the printer is located.

CHAPTER 11 Package Management

Lesson 1 Examining Package Solutions

Lesson Objectives

In this lesson, you will:

Explain dependency. List three ways in which you might find software packaged.

Introduction:-To install applications on your Linux system, you have several options, depending on how your system is configured. Some systems use the Red Hat Package Manager; others use DEB; still others use a more basic utility to install tarball packages. Packages include all of the files required to run an application. However, there might be other packages that are required in order to install the application that you want to install. This is referred to as a dependency. In that case, you will need to install the other package (and possibly even more additional packages) before you can install the package you wanted to install. Let's look at each of these package installation utilities.

93

Page 94: HISTORY AND DEVELOPMENT OF LINUX22

What is RPM?

Red Hat Package Manager (RPM) is a tool for maintaining applications. It is distributed under the Gnu General Public License (GPL). It is used to install, uninstall, update, and maintain Linux software. It was developed by Red Hat, but can be used with many distributions of Linux and even some other UNIX implementations.

RPM makes administrating and maintaining a Linux server, or a farm of servers, much easier by providing a standard software packaging format and a powerful utility to manipulate these packages. The RPM utility provides a standard installation mechanism, a way to display information about installed packages, a method for uninstalling packages from the system, and a simple method for upgrading existing packages. RPM provides facilities to:

Facilities Protected by RPM

Query packages. Maintain installed packages. Verify installation and integrity of packages. Build ROM packages.

What is an RPM Package?

RPM works on packages. A package is a file that holds all of the binary files needed to install an application. Packages are often named following a specific naming convention. For example, the cpio program is installed from the package cpio-2.4.2-13.i386.rpm. The name of the package is listed first (cpio), then the version (2.4.2), followed by the release (13), then the architecture (i386), and ending with the extension .rpm.

Packages are considered pristine sources. This refers to an RPM file containing all of the files needed to install an application. This source can be used to replace files if they get deleted or corrupted after the application is installed on your system.

Where Can You Find Packages?

The Red Hat distribution includes the RPMS directory containing packages. You can also find packages on the Internet and FTP sites. One Web site where you can find packages is http://rpmfind.net. When you install Linux, you might end up installing all of the packages it comes with, but more likely (and better for security), you should install only the packages you need. Later, you might find that you need to install additional packages, and your CD (or whatever source you used) can be used to obtain additional packages. You'll want to check to see if updated versions of the package have been released and whether you should install the more recent version instead.

What is DEB? DEB tools is a suite of tools for package management for Debian-based Linux distributions. It is used to install, list, and remove packages conforming to the DEB packaging standard. Advanced Package Tool (APT) is a front-end to the DEB suite of tools to make it more user friendly. The tools included in the DEB suite include those found in the following rollover.

94

Page 95: HISTORY AND DEVELOPMENT OF LINUX22

Tools Included in the DEBUtility Descriptiondpkg The main package management program. It main purpose is to install DEB packages.apt-get A user-friendly way to install DEB packages. It uses the /etc/apt/sources. list file to acquire the relevant DEB file

rather than working directly with the DEB packages.dpkg-deb Used to manage DEB packages, including extracting DEB package contents to a directory and displaying package

information.dpkg-split Splits packages into smaller parts. Useful for splitting packages into 1.44MB parts, so that they can fit on a series

of floppy disks.dselect A menu driven front-end interface to dpkg. Through this utility, u can install and remove packages.What is tarball? Some applications are just plain old tar files, but in the UNIX tradition, you can't just say tar file-you need to come up with a strange name for it. Thus, tarball. Tarballs come in several different formats, as shown in the following rollover.

TIP: This is the default format of packages on the Slackware Linux distribution.

Tarball Format

Format Description

.tar This is the standard tar archive without extra compression.

tar.gz or .tgz This is the standard gzip compressed tar archive.

.tar.bz2 This is a tar archive that has been further compressed using the bzip2 utility.

.bin.tar, .bin.tar.gz or .bin.tgz This is a tar archive containing binary file rather than source.

The standard is .tar.gz files, so that is what you will most often encounter. To extract the file, at the command line, enter tar zxvf tarfile.tar.gz. To extract the file through X Windows file manager, right-click on the tar file; then choose Extract or Open With Archiver (depending on whether you are using GNOME or KDE). At this point, you will have extracted the file, but you aren't done yet.

Next, you need to compile it. This needs to be done at the command line or through an xterm window. Change to the directory that has been made by the package. Here you should find an INSTALL file. Be sure you read through the contents of the INSTALL file. Most tarballs include one or more of the following files: INSTALL, COPYING, README, or CHANGES. The INSTALL file usually says basically the same thing: it includes a generic process for installing tarballs. If a program needs to be compiled in a certain way, this is found in either INSTALL or README. To install a generic program extracted from a tarball, complete the tasks shown in the following rollover.

Task to Complete

Command Description./configure You’ll want to take note regarding any configuration error.make You’ll want to take note regarding any compilation error.make clean Clean up after successfully compiling.

This is how it works in theory, but it doesn't always work. This is usually due to dependencies on other programs.

95

Page 96: HISTORY AND DEVELOPMENT OF LINUX22

Here is an example of the process of installing a tarball and what you might experience. You want to install a game called xgame from a tar.gz file. During the configure, you get output regarding SDL. On the Web site where you downloaded the tarball from, you also saw something about SDL. After doing a Web search, you find out that SDL is a graphics library for X and that you need to install it for your xgame, so you download the current SDL tar file from the Web site and install it successfully. Then, you try to install xgame and it still won't install, but this time you get a different message about not being able to find Qt 1.3 on a ./configure. Your system has Qt 1.3.4 so you wonder why this error is coming up. After doing some more research, you find that Qt (which is another graphics/programming toolkit) is installed in a different folder than where ./configure is looking. At this point you can either edit ./configure manually to try to fix the situation or you can try removing Qt, and installing another instance of it from another source. RPM distributions often place libraries or packages in different locations than a tarball might, so you might find that when installing a tarball, the new tarball can't find a library or package which you know was installed on your system. Sometimes you can modify the configure file to specify the location, or you might need to re-install the library or package from a tarball to satisfy the dependency.

Managing Packages Through Other Utilities:-Some Linux distributions include their own system administration utilities. For example, TurboLinux uses TurboPkg (or the TurboConfigCtr), SuSE includes YaST, and Caldera includes Lisa. These utilities include options to manage packages on the system. This includes listing, installing, and removing packages.

1. What does RPM stand for? What is it?Ans: Red Hat Package Manager. It is a package management system.2. What is RPM used for?Ans: Managing packages including installing, querying, verifying, uninstalling, building, and rebuilding databases.3. What is meant by pristine sources?Ans: Software that is the way it was distributed by the original software authors.4. Is RPM just for use on Red Hat Linux systems?Ans: No. It can be used on any Linux system. There are also versions in development for non-Linux systems.5. What is DEB?Ans: It is a package management system for Linux distributions based on Debian Linux. 6. What can you use DEB to do?Ans: Install, uninstall, update, maintain, verify, and build packages.7. What is a tarball?Ans: A tar file from which you extract the software.8. How do you install an application using tarball?Ans: Extract the file, and then change to the directory where it was extracted to. Then you need to compile it to use it. Run ./config, make, and make clean.9. Identify when it would be appropriate to use RPM, DEB, or tarball to install applications.Ans: It will depend on how the application is packaged. If it is packaged as an RPM, you will need to use RPM, and so forth.1. What is dependency?Ans: Dependency happens when an application, library, or package is required to be installed before installing another package. 2. What are three ways in which you might find software packaged?Ans: You might encounter tarballs, RPMs, and DEBs.

Lesson 2 Managing Packages with RPM

Lesson Objective

In this lesson, you will:

Explain how to use RPM to query, install, and remove packages.

Introduction:-RPM is probably the package you'll encounter most often. For this reason, it is the package management system we will use in this topic to show you how to manage packages.

Querying Packages:-Once your Linux system has been installed, it is often necessary to determine if a certain package has been installed on the system. It may also be helpful to determine the version of the package and the files associated with that package.

It's hard to remember every package that has been installed on your system. Other times, you just might not know what has been installed. Using the query mode, you can see which packages have been installed. Entering,

96

Page 97: HISTORY AND DEVELOPMENT OF LINUX22

rpm -qa

lists all of the installed packages on your system. To query a specific package, enter:

rpm -q package_name

Listing Installed Packages

There are several RPM options you can combine when listing installed packages. You can also pipe the results of the command to another command to get specific information. The following rollover describes some of these options.

RPM Options

Command Descriptionrpm-qa Produces a list of the package name including version information.rpm-qi Produces a detailed description of the RPM package specified in the command.rpm-qa | grep packagename Sends the results of the rpm query command to the grep command to search the results for a

specifies character pattern.

If you don't know the full package name, you can use grep to try to query installed packages. For example, the samba package in Red Hat 7.0 is named samba_common2.0.7-21ssl. This will be slightly different in other releases as samba is upgraded. The commands rpm -qa|grep samba will pull any package containing samba from the list and list it for you.

Detailed RPM listing.

The following table describes the fields displayed in a detailed RPM listing.

Field Name Description

Name Name of the application or package.

Version Major version number.

Release Release under the major version number.

97

Page 98: HISTORY AND DEVELOPMENT OF LINUX22

Relocations Indicates whether the package can be relocated.

Vendor Who released the package.

Build Date When the package was created.

Install Date When the package was installed on your system. If not installed, a message stating this is displayed, rather than a date.

Build Host The host on which the build was created.

Group The package category.

Source RPM The name of the RPM package the application was installed from. Usually this name is built from the package name, version, and release information.

Size The size, in bytes, of the package.

License Who holds the license to the application (for example, Red Hat or BSD).

Packager The company who built the package.

Summary A brief description of the package.

Description A longer description of the package than the summary.

Getting Information About Uninstalled Packages:-Before you install a package, you might want to get information about it. You can do so with the RPM utility. To get a detailed description of the package, use the -qip options. To get a listing of the files in the package, use the -qlp options.

Installing Packages with RPM:-RPM makes the installation of new Linux applications easy and reliable. Installing applications without RPM generally involves unarchiving files, reading documentation to determine installation prerequisites, possibly configuring and compiling source code, and installing the binaries and configuration files. With RPM, the packages are already compiled, and installation is performed in a single step.

Dependencies

When you install a package, RPM checks the package to see if any other packages are required in order to work. This is referred to as dependencies. If the package requires another package to be installed, you need to install the other package first, and then come back and install the package you wanted to install.

There is an option to install without meeting dependencies, but in most cases, you won't want to do this. The package has a good possibility to not be fully functional if you don't resolve the dependencies.

Removing Packages with RPM:-Removing packages with the RPM system is a simple task. Upon issuing the RPM remove command, all of a package's installation binaries, configuration files, and documentation are removed from the system.

You use the -e or --erase option to remove or erase the package. You'll need to be specific in the name of the package you want to remove. When a package is removed, RPM performs several steps:

Checks the RPM database for any package dependencies on the package you want to erase. Unless you explicitly specify that it is to delete the package, it won't if other packages are dependent upon this package.

Runs the pre-uninstall script.

Checks the config files and saves a copy of any config files that have been modified.

Deletes all of the files related to the package you are removing.

Runs the post-uninstall script.

98

Page 99: HISTORY AND DEVELOPMENT OF LINUX22

Removes all references to the package from the RPM database.

If you want more information on the removal process, use the -v or -vv options to get verbose or very verbose information. You can also use the --test option to see what would happen if you actually removed the package. The --test option doesn't actually remove the package.

1. How do you use RPM to query, install, and remove packages?

Ans: To query, use rpm -q pkgname. To install, use rpm -ivh pkgname. To remove, use rpm -e pkgname. (You can use more or fewer options with each of these.)

Lesson 3 Verifying and Repairing Applications

Lesson Objective

In this lesson, you will:

Explain what it means to verify a package.

Overview:-The integrity of a package can also be verified via the RPM system. Verifying a package compares the information taken from the original RPM file (and subsequently stored in the RPM database) with the current state of the installed files on the system. This verification process can be used to ensure that package files are present in the correct directories, unmodified, and have the proper permissions. More specifically, RPM checks the size, MD5 checksum, permissions, type, owner, and group of each file in the package.TIP: MD5 is a one-way hash algorithm used to create secure digital signatures. Refer to RFC 1321 for more information on the MD5 message-digest algorithm.

The verify mode of RPM is used to check the consistency of files on your system. If a file was corrupted, you can compare the current files to the original files. To do this, enter:

rpm -V package_name

If all is fine with the package, no messages are displayed, and you are returned to the command prompt. If a problem is detected, an eight-character string is displayed to alert you of the change. Based on this output, you can determine if the package needs to be re-installed. The verification error codes are listed in the following animated tip.

Verification Error Codes

Error Codes Descriptionc Configuration file.5 MD5 checksum test failed.S Change in file size since installation.L Symbolic link error.T Current file modification time doesn’t match original file modification time.D Device attribute.U Different user setting from original.G Different group setting from original.M Different permission or file type mode.

1. What does it mean to verify a package?

Ans: Verifying a package compares the information taken from the original RPM file (and subsequently stored in the RPM database) with the current state of the installed files on the system. This verification process can be used to ensure that package files are present in the correct directories, unmodified, and have the proper permissions.

99

Page 100: HISTORY AND DEVELOPMENT OF LINUX22

Lesson 4 Upgrading and Freshening Packages

Lesson Objective

In this lesson, you will:

Explain why you might want to upgrade a package.

Introduction:-One of the more difficult aspects of system administration is keeping the system's software up to date. Many applications are in active development and new releases are made available on a regular basis. These new releases may add functionality, fix bugs in older versions, or provide important security updates. One of the most useful aspects of RPM is the ability to quickly and easily upgrade software packages.

If you perform an upgrade and the package isn't installed, it will be installed. If the package is installed, it will be upgraded.

The freshen option is similar to the upgrade option. Freshen checks package versions you specify against the package versions installed already. If a newer version of a package is found by the freshen process, the package is upgraded to the newer version. If the package isn't installed, it won't be upgraded or installed. This is a key difference between the freshen and upgrade options; upgrade installs packages even if an older version of the package wasn't already installed.

You can use the freshen option on single packages or with a group of packages. Entering rpm -Fvh *.rpm automatically upgrades only those packages that have already been installed.

Accessing Updates from the Red Hat FTP Site

The Web site www.redhat.com/support/errata/ lists the current updates and fixes for Red Hat Linux.

Errata Types

Errata Type Contains Links ToSecurity Advisories Updates that are essential in maintaining system security.Bug Fixes Updates all users are recommended to implement. This includes updates to error in code

discovered after the release of the product.Package Enhancements Updates to features or functions issued since the original release.

You can access the files from links at each of these errata-type sites. If the Red Hat FTP site is busy, you can use mirror sites to download the files. These mirror sites are located throughout the world, so you can usually find one that you can get into.

Checking for Updates

How often you check for updates to packages you use will vary, depending on your needs. Some users should check daily. Most users will be okay if they just check weekly, monthly, or quarterly.

1. What are some reasons you might want to upgrade a package?

Ans: Answers might include: To take advantage of new features, to fix bugs, or to close security holes.

CHAPTER 12 Configuring the Linux Environment

Lesson 1 Examining Shells

100

Page 101: HISTORY AND DEVELOPMENT OF LINUX22

Lesson Objective

In this lesson, you will:

Explain the purpose of the shell.

Introduction:-The two primary components of the Linux operating system are the kernel and the shell. The kernel is the part of the system that interfaces directly with the hardware. Some of the functions the kernel performs include:Kernel functions

Managing computer memory. Maintaining the filesystem. Handling error and interrupts. Performing input and output services. Allocating the resource among users.

In contrast, the shell is the part of the operating system that reads the commands you enter and makes arrangements to see that the commands are carried out. The shell is sometimes called the command interpreter. Some of the functions performed by the shell include:

Shell Functions

Prompting the user for input and waiting for a command to be entered. Verifying the correctness for a command and processing the command. Expanding wildcard to their full meaning. Determining where input comes from and where output goes. Returning the prompt after the completion of a command and restarting the cycle.

Types of Shells:-There are several major variations of the UNIX shell as shown in the following rollover.UNIX ShellsShell Shell Program Descriptionash /bin/ash The Linux shell based an AT&T System V UNIX shell.bash /bin/sh/bin/bsh/bin/bash The default Linux shell. This shell is based on the original Bourne shell. This is

a POSIX complaint shell.C-Shell /bin/csh/bin/tcsh This was the second shell developed that added many features it uses C

programming style syntax.

Other shells that you might encounter include the Korn shell (/bin/ksh), which is similar to the Bourne shell with features of the C shell and the Z shell (/bin/zsh).

Shells contain a shell-programming language. Because of its universal availability, many of the administrative scripts used to maintain UNIX systems are written in the Bourne shell.

101

Page 102: HISTORY AND DEVELOPMENT OF LINUX22

Starting a New Shell:-When you log in, you automatically create a new shell. This shell is referred to as your login shell. The default shell type for your login shell is the Bash shell. You can specify a different default shell through the /etc/passwd file.

Once created, user shells operate independently. In a multiuser environment, having separate user shells is one of the ways in which users can work without conflict.

One way to start a new shell from your login shell is to run a program. For example, from your login shell you might create and run a shell script. When started, that shell script might create a new shell that exists until the script finishes running. You can also start a new shell from the command line.

To create a new Bash shell, use the sh, bsh, or bash commands. When you run the command, a Bash shell is started and you're placed in the new shell. The standard default prompt for the Bash shell is the dollar sign ($). This is your only visual indication that you're in a Bash shell.

Many of the Bash shell commands that you will use are available in other shells. Some will have equivalent commands, but under different names. Other commands will be specific to the individual shell types. Some commands are referred to as shell built-ins. Built-in commands are part of the particular shell's code, rather than an external program that functions in any shell.

To create a new C shell, use the csh or tcsh commands. When you run the csh command, a new C shell is started, and you're placed in that new shell.

1. What is the purpose of the shell?

Ans: Interacting with the kernel, customizing your login session, and programming.

Lesson 2 Using Variables

Lesson Objectives

In this lesson, you will:

Define a variable. Explain when you need to use double quotes to define a variable.

Introduction:-Linux shells provide several variables to make using Linux easier. Variables are a useful way of generically referring to an entity whose value changes from time to time. Most of the shell variables are set either by the operating system when you log in, or by the shell when it is initially invoked.

102

Page 103: HISTORY AND DEVELOPMENT OF LINUX22

Local and Exported Variables:-A shell variable can be local in scope, in which case its value is known only to the current shell. A shell variable can also be exported, which means that the shell automatically passes the variable and its value to other commands (including new copies of the shell) that you invoke. Variables that have been exported are sometimes called environment variables. To test whether a variable is exported, use the env command.

Default variablesViewing Variable Values:-Variables that are set by the operating system when you log in are automatically exported. Variables created by the shell remain local in scope unless you manually export them. To display the value of a variable, use the echo command followed by a dollar sign ($) and the variable name (with no space between the $ and the variable name). For example, to find out what is set as your default shell, you would enter echo $SHELL. The value of the variable is displayed to the screen (such as /bin/bash in this case). Like Linux commands, the shell variables are case-sensitive.

Local Variables;-Local variables are variables that haven't been exported. The value of a local variable is known only to the current shell. Use the set command to view the current list of all local variables. Some typical local variables include PS1 (the primary shell prompt), PWD (the current working directory), and SECONDS (how many seconds since starting the shell).

Declaring Variables

In addition to using and modifying the predefined variables, you can create your own. The following rules apply to creating variable names:

Creating Variable Name Rules

A variable name must begin with an upper-case or lower-case letter or an underscores(_). The initial letter or underscores can be followed by any number of additional upper-case or lower-case letters,

the numbers 0 through 9 , or an underscore. The following character combination have special meanings and shouldn’t be used as variable name or the end a

variable name:$@, $#, $$, $*, $-, $? And $0 through $9.

To assign a value to a variable, you type the variable name followed by an equal sign (=) and the value (with no spaces). To export a variable, making it known to commands and other shells, type export followed by the variable you want to export.

TIP: Notice that u don’t use the $ here.

Assigning Variable Values Containing Spaces

Often, the value that you wish to assign to a variable contains white space (meaning space or tab characters). Because white space is a delimiter to the shell, values containing white space don't get assigned correctly unless you use single quotation marks around the value. Enclosing the value in single quotes tells the shell to interpret the white space literally.

103

Page 104: HISTORY AND DEVELOPMENT OF LINUX22

The same is true for any metacharacters. Normally, the shell attempts to expand the metacharacters; however, if the metacharacters are enclosed in single quotes, the metacharacters are interpreted literally. Thus, the command echo '* hello *' would result in the following output: * hello *

There are three rules for using single quotes:

Use single quotes (') to protect text from any substitution. Backslashes ( \ ), metacharacters, variables, double quotes ("), and grave marks ( ` ) are ignored when they occur within single quotes.

Only another single quote can end a single-quoted string.

You can't place a single quote in single-quoted text. For example, 'Mary's computer' would produce unpaired single quotes and cause the shell to search for further input.

Using Double Quotes in Assigning Values to Variables:-Many of the rules for using single quotes in variable assignment apply to using double quotes (""). A key difference when you're using double quotes is that the shell doesn't interpret literally the $, \, "", and ` characters. Therefore, if you need to assign a value to a variable which itself contains a variable, enclose the value in double quotes. Otherwise, if you use single quotes, the shell will interpret the $ literally instead of as a variable to be expanded.

Removing Variables:-To remove a variable, type unset followed by the variable name (for example, unset STRING). If the variable is one that is created by the system, the variable will return and be active when you log in at your next session.

Saving User-Created Variables

User-created variables will be lost when you log out of the system. You can make your personal variables a permanent part of your user environment by placing your variable definitions in a configuration file.

Working with the PATH and CDPATH Variables:-Two useful variables that save you typing are PATH and CDPATH. There is often a directory deep in your directory structure to which you frequently change. By defining this in a CDPATH variable, you can more easily change directly to that path. If you create executable commands, you won't have to specify the path to the command as long as its directory is included in the PATH variable.

Working with the PATH Variable:-The PATH variable defines a list of directories in which the shell should search for a command name. A default PATH variable is established during installation, but you will typically define a new value for your PATH variable in your .bash_profile. To define the value of PATH, type the list of directories, with each delimited by a colon. For example, $PATH=/bin:/usr/bin:. tells the shell to search for commands in three directories: /bin, /usr/bin, and the current directory ( . ).

Using the CDPATH Variable:-If you frequently move between particular directories or subdirectories, typing full or even partial pathnames with the cd command will quickly become a cumbersome task. You can set the value of the CDPATH variable to a list of directories containing frequently used files and directories. This way, when you type cd followed by a directory name, Linux will first search the directories specified by the CDPATH variable.

The shell doesn't set the CDPATH variable automatically. You must assign a value to CDPATH if you want the cd command to use it.

Setting the CDPATH variable changes the way the cd command works. Normally, to move to a directory below your current position, you type cd followed by the directory name. With the CDPATH variable set, this will work only if the desired directory is specified in CDPATH. If the directory isn't specified in CDPATH, you must precede the directory with a period.

For example, if the CDPATH variable is set but doesn't contain the tempdir directory, you must type cd ./tempdir. If you just type cd tempdir, the shell will search for the tempdir directory in only the directories specified by the CDPATH variable.

104

Page 105: HISTORY AND DEVELOPMENT OF LINUX22

1. What is a variable?

Ans: A symbolic name that represents a value.

2. When do you need to use double quotes to define a variable?

Ans: When the value contains another variable.

Lesson 3 Examining Linux Configuration Script Files

Lesson Objectives

In this lesson, you will:

Explain what a Linux configuration script file does. Explain what a vi editor is.

Introduction:-Most users like to customize their environments to suit their needs. For example, you might want the date and time to appear on your screen when you log in.

Files such as .bash_profile and .exrc are used to customize your environment. You can further customize your environment by changing your keyboard settings. Modifying your environment can enable you to work in a more comfortable and efficient manner.

The .bash_profile File

The .bash_profile script runs only when you log in. An example of a .bash_profile is shown in the figure below.

105

Page 106: HISTORY AND DEVELOPMENT OF LINUX22

A sample .bash_profile file.

The .bashrc File:-The .bashrc file is called from the .bash_profile file. It also runs when you start a new shell. An example of a .bashrc file is shown in the figure below.

A sample .bashrc file.

The .bash_logout File:-The .bash_logout file runs only when you log out of the system. It doesn't run when you close a shell (unless it is the login shell). An example of a .bash_logout file is shown in the figure below.

A sample .bash_logout file.

The .exrc File:-The .exrc file is a file you can use to control your vi environment. When you first start the vi editor, many of the options that you might want to use are set by default to the off state.

For example, when you first edit a file, no line numbers appear next to your text. By creating a .exrc file and entering set option commands in the file, you can configure the vi editor so that the desired options are set each time you start the editor.

To determine the names of all of the available vi options and to view their current settings, you must first start the vi editor. Once you have started the vi editor, you can use the set all command to view the vi options and current settings. Some of the options that you might find helpful include those found in the following rollover.

Helpful Options

vi Option Action

106

Page 107: HISTORY AND DEVELOPMENT OF LINUX22

Autoindent Start each line at the same column as the preceding line.Flash Change the terminal bell to a screen flash.Number Display line numbers. The on/off indication for settings is usually option or no-option. For example, if the line-number option is set, the setting

will indicate number. If the setting is turned off, it will indicate nonumber. Other options are indicated by their numeric

values.

To set the options while in the vi editor, use the set option command; to turn the option off, use the set no-option command. To have your option settings set automatically each time that you start vi, add your set commands to the .exrc file. In the .exrc file, you don't need to precede the set command with a colon (:). Once you save the file as .exrc, these commands will be read by the system each time the vi editor is started, and the vi options will be set accordingly.

1. What is a Linux configuration script file?

Ans: It is a file that allows users to customize their environment to suit their needs.

2. What is a vi editor?

Ans: A text editor.

Lesson 4 Examining System Startup Files

Lesson Objectives

In this lesson, you will:

Explain what a runlevel does. Name the script file that is responsible for the initial startup system configuration tasks.

Introduction:-Red Hat Linux system initialization and startup is a complex process that spans several initialization and configuration files. The process begins with the loading of the Linux kernel, which includes the initialization and configuration of hardware devices through drivers compiled into the kernel. After the kernel has loaded, it starts the init process, which is the parent process of all Linux processes. Different init runlevels are permissible, but the default runlevel in Red Hat Linux is 3, which is full multiuser mode. The init process continues the system initialization by calling the /etc/rc.d/rc.sysinit script (which in turns calls a number of other scripts) to install required kernel modules and initialize the system environment. Then, based on the configured runlevel, the init process calls the /etc/rc.d/rc script which, in turn, starts the necessary system daemons. Init then starts the /sbin/mgetty applications to service the Linux console and virtual consoles. Mgetty provides the login prompt that you see after the system startup is complete.

TIP: rc stands for run commands.

The init Process:-The init process is the core of the system startup process, as described in the previous section. Init is configured by the /etc/inittab file, which specifies the default runlevel, system initialization script locations, and various other startup parameters. The inittab file is very rarely modified, as its default locations and parameters are sufficient for most installations. The installed inittab file is provided here for reference.

Changing the Default init Level:-If you need to change the default init level for your system, you can do so in the inittab file.

TIP: Not all systems use the rc. sysinit file or the path /etc/rc.d for the system initialization file. The path following si::sysinit: will contain the name of the file (and the path to the file) that is in use on that system.

Editing the inittab File:-One thing that is commonly changed in the inittab file is whether Ctrl+Alt+Delete can be used to reboot the system. If you disable it, it is a good idea to add a message that will display when users press that key combination.System V Initialization:-The rc.sysinit script is located in the /etc/rc.d directory and is responsible for all of the initial startup system configuration tasks. This includes the following tasks, in order of operation:

Set system hostname and networking status.

107

Page 108: HISTORY AND DEVELOPMENT OF LINUX22

Mount the /proc filesystem.

Configure kernel parameters.

Set the system clock.

Load the keymap and system font.

Start memory swapping (if a swap partition exists).

Check disk quotas to initialize plug and play capabilities.

Initialize necessary kernel modules.

Initialize sound modules and settings.

Initialize software RAID devices, if any exist.

Perform a filesystem check (fsck) on all partitions, if necessary.

Mount local filesystems.

Perform interactive system configuration, if necessary.

Initialize disk quotas.

Clean up temporary files and delete stale locks.

Load SCSI tape module, if detected.

There's a line in the /etc/inittab that specifies which script is run for system initialization. In Red Hat, that line looks like: si::sysinit:/etc/rc.d/rc.sysinit. In other distributions, the file after sysinit is often different. For example, in Caldera, the system initialization file is /etc/rc.d/rc.modules, and in SuSE it is /etc/init.d/boot.

Follow the steps below to learn how to use the system initialization file.

Open /etc/inittab in a text editor and search for the text si::sysinit. This identifies the file used to set initial system settings.

Close the text editor.

Examine the /etc/rc.d/rc.sysinit file using a text editor or the less command. This file sets the initial startup configuration.

Locate the PATH setting. This is the default path. Other configuration scripts, such as those that run when you log in, will add to or replace this path.

Return to the command prompt.

Configuring LILO:-You can configure how LILO works with the LILO Linux command. Issuing the command without any options writes the changes to the master boot record. Some of the LILO command options are described in the following table. For details on the rest of the options, refer to the LILO man pages.

TIP: Combine the �t and �v options to determine what LILO is set to do.

LILO Command Option

Option Description

108

Page 109: HISTORY AND DEVELOPMENT OF LINUX22

-R Sets the default command line for the next reboot.(Used to change from Linux booting by default to DOS booting.) This is a one-time only setting that is reset after u reboot.

-t Test but don’t write a new sector or map file.

-v Increase verbosely (show more detailed messages). LILO version,

Follow the steps below to learn how to edit the LILO configuration file. Open the /etc/lilo.conf file in a text editor. Change the delay time before the operating system starts to

30 seconds. Remember that the parameter for this option is specified in deciseconds. Change the file so that DOS is the default operating system at boot time (use the default variable). Save

the changes to the file.

Write the changes to the master boot record by entering lilo -v. This writes the changes. Using the verbose option displays information about the changes to the screen. Verify your settings with lilo -t -v.

Reboot and wait until the default operating system boots. If the DOS autoboots after 30 seconds, then you did exactly what you should have done in the previous two steps.

The /etc/rc.d Directory

The /etc/rc.d directory contains most of the system shell scripts that are called during the startup and initialization of the system. The following files and subdirectories are present in the /etc/rc.d directory.

File/Directory Description

rc.local Local initialization script.

rc Runlevel initialization scripts (starts/stops services based on runlevel).

rc.sysinit System initialization script.

init.d/ Directory of control scripts for individual services and daemons.

109

Page 110: HISTORY AND DEVELOPMENT OF LINUX22

rc0.d/ Directory of configuration scripts for runlevel 0.

rc1.d/ Directory of configuration scripts for runlevel 1, single user.

rc2.d/ Directory of configuration scripts for runlevel 2, multiuser.

rc3.d/ Directory of configuration scripts for runlevel 3, full multiuser.

rc4.d/ Directory of configuration scripts for runlevel 4.

rc5.d/ Directory of configuration scripts for runlevel 5, to boot directly into X Windows.

rc6.d/ Directory of configuration scripts for runlevel 6.

The files in the rcx.d subdirectories are actually symbolic links to scripts in the /etc/rc.d/init.d directory. These files, and the corresponding behavior at startup, are configured via the chkconfig command discussed in the lesson entitled, "Configuring and Managing Services."

Symbolic and Hard Links:-Symbolic and hard links are a feature of the Linux filesystem, ext2, and are common in the filesystems of most UNIX and UNIX-like operating systems. A link contains no data of its own, only a reference to another file. A symbolic link allows a single file or directory to be accessible via multiple filenames. This is useful when you need to share a single file amongst several locations without copying it. A symbolic link is somewhat similar to a shortcut in Microsoft Windows, but it provides much more flexibility as it is usable for most normal file operations.

A hard link, like a symbolic link, provides a reference to another file. Unlike a symbolic link, a hard link looks like a real file to all applications. After a hard link is created, the file may be deleted and its contents will still be available in the linked file. This is a function of how hard links are handled by the underlying filesystem. Hard links may not be created for directories. Hard links might not be created to files that exist on a different partition.

1. What does the runlevel do?

Ans: The runlevel specifies a specific group of processes to be run by init.

2. Which script file is responsible for the initial startup system configuration tasks?

Ans: The rc.sysinit script file.

Lesson 5 Examining the /etc/fstab File

Lesson Objective

In this lesson, you will:

Explain what the fstab file does.

Overview:-When you boot your system, certain filesystems are automatically mounted. These filesystems are defined in the /etc/fstab file. This file specifies the default device, mount point, filesystem type, and mount type. It also specifies dump and mount order options.

A sample /etc/fstab file.

110

Page 111: HISTORY AND DEVELOPMENT OF LINUX22

Follow the steps below to learn about the /etc/fstab file. Display the man page for fstab. When you are done reading through it, return to the command prompt. Display the contents of the /etc/fstab file. The first field of the file specifies the device to be mounted. The second field

of the file specifies the mount point for the filesystem. The third field of the file specifies the filesystem type. The last two fields specify whether the filesystem contents need to be dumped and how and when the filesystem is checked on reboot.

Reboot your system (with root level access (su), enter shutdown -r now) and observe as the system reboots. The filesystems listed in the fstab file are checked and mounted during the system boot.

1. What does the fstab file do?

Ans: It contains static information about the filesystems.

Lesson 6 Examining the cron System

Lesson Objective

In this lesson, you will:

Explain the difference between cron and anacron.

Introduction:-The cron daemon provides a mechanism for automating task execution by running programs on a regular, time-scheduled basis. Cron allows an administrator to schedule a command to execute at regular intervals or to repeat at a specific time or day.

The cron daemon is invoked at system startup and runs continuously to ensure that scheduled jobs will be executed. Borrowing from mainframe terminology, a command scheduled via cron is referred to as a cron job, or job for short. Cron jobs may run either at the system level or for individual users.

Setting Up Scheduled Jobs Using cron

Scheduling a cron job is accomplished by adding the job to the system-wide/etc/crontab file. The crontab file may also contain environment variables that will be passed to the commands at execution time. At a minimum, the variables shown in the following table are generally set in the crontab.

Variable Set in the crontab

Field DescriptionSHELL The shell to use to run command.PATH The file PATH. MAILTO The target email address for cron results.HOME The HOME directory for the cron job.

Jobs in the crontab file are called entries, and they include a time description, the user name to run the command as, and the command. The format of a crontab entry is:

minute hour monthday month weekday user command

The time fields in a crontab entry are described in the following rollover.

111

Page 112: HISTORY AND DEVELOPMENT OF LINUX22

Time Fields in a Crontab Entry

Field Allowed ValuesMinute 0-59Hour 0-23Day of month 1-31Month 1-2: or names Jan-DecDay of week 0-7(0 or 7 is Sunday), or names Sun-Sat

In addition to specifying a particular time/day, a pattern can also be described by using asterisks (*) to specify all of a particular field. (For example, an asterisk in the minute field would indicate that the command should be carried out every minute, pending the other criteria.) In addition to asterisks, time ranges are also permitted by separating values with a dash (-), and lists of values are specified by separating values with a comma ( , ). Sample time entries are as follows:

User crontab Files:-In addition to system-level cron jobs, individual users can also schedule cron jobs. Unlike the system-level crontab, each user has his or her own crontab file that is stored in the /var/spool/cron directory. The format of entries in this file is the same as that of the system-wide crontab, with the exception of the user field. Because the entire crontab file is dedicated to a single user, the user field is not included. While the /etc/crontab file can be edited directly, user crontab files are best edited via the crontab utility.

Setting the Preferred Editor for crontab

The crontab utility uses the value of the EDITOR environment variable, if it exists, to decide which editor to launch to edit crontab files. Be sure to set the EDITOR variable to your favorite editor prior to using the crontab utility. For example, enter 'export EDITOR=/usr/bin/pico' to set your editor to Pico under the Bash shell. If you're using the csh or tsch shell, you can set the EDITOR environment variable by entering 'setenv EDITOR /usr/bin/pico'.

Using anacron:-If your system is down or unavailable for whatever reason when a cron job should have run, it won't run. For this reason, an alternative to the standard cron was developed, called anacron. With anacron, if a cron job is missed, it will run when the system is rebooted.1. What is the difference between cron and anacron?Ans: Both cron and anacron are used to schedule recurring jobs. Jobs in cron won't run if the system is down; with anacron, any jobs that should have run while the system was down will run when the system is restarted.

112

Page 113: HISTORY AND DEVELOPMENT OF LINUX22

Lesson 7 Creating a Shell Script

Lesson Objectives

In this lesson, you will:

Define a shell script. Explain what you need to do in order to run a script file.

Introduction:-Linux is a versatile operating system. One aspect of its versatility is that it can be moved from one platform to another with a minimum amount of effort. Linux also enables you to build and name your own commands. The commands that you develop are called shell scripts.

A shell script is a file made up of Linux commands. It is usually located in the user's home directory and can be run by entering the filename.

Tasks that you perform on a daily basis might be repetitive and involve using many commands. By making a shell script that includes these commands in the proper sequence, you can shorten and simplify your work.

Commands that are used in combination to perform common and repetitive tasks can be grouped together and placed in a file to create a shell script. By using the echo command, you can also include descriptive comments, printed to the screen, that clarify the output from your script.

Your file is made executable by using the chmod command. Once the file is executable, the filename can be typed at the command line and all of the commands in the file are executed in the order in which they were placed in the file. The shell script runs in a separate shell from your login shell.

A shell script can be as simple or as complex as you choose to make it. In advanced shell scripts, or shell programs, programming structures such as loops and conditional statements can be included.

A Directory Utility Shell Script:-In this topic, you'll put together commands that you have previously learned to perform tasks that may be typical of those required in your workplace. You'll create a shell script to return system information including the operator, date, a listing of your files and directories, and a count of the directories in your home directory. To accomplish this by typing separate commands for each action requires many entries. The output is interspersed between the commands, and has no meaningful headings. By creating a custom command and personalizing the output with descriptive headings, you can perform these tasks at any time, with a minimum of effort and with a more meaningful result.Making Shell Scripts Executable:-Before you can run your shell script, you need to use the chmod command to change permissions on the file. Whoever you want to be able to run the script file needs to have executable (x) permission to the file.

To force the system to look in the current directory rather than the /bin directory for the command, precede the command with ./ notation. The /bin directory is the default location for shell scripts to be run from.

Running Shell Commands from vi

In vi, the shell escape (:!) enables you to temporarily leave vi and run the specified command. When the command has finished running, a message to press [Enter] is displayed. Pressing [Enter] brings you back to where you were in vi.

You can also open a shell window from vi. This is useful if you need to run more than one command while you are shelled out of vi. To do this, from within vi, enter :shell. This will run another instance of the default shell. To return to vi, enter exit.

Commands Frequently Used in Shell Scripts:-While you can use most any shell command in a script file, the grep, cut, paste, if, and find commands are very useful in shell scripts. Let's look at how these might be used in a shell script.

113

Page 114: HISTORY AND DEVELOPMENT OF LINUX22

The grep Command

The global regular expression printer (grep)filter is used for pattern matching. You specify a pattern, called a regular expression, to guide the grep command's search through a file and grep, in turn, examines the specified file, line by line, to see if it contains the pattern.

The syntax of the grep command is grep [pattern] [filename]. The following list explains how to use the grep command:

Many of the grep metacharacters are identical to the shell metacharacters, but there are some important differences. The grep metacharacters are also used in the vi editor.

The dot character ( . ) matches on any single character. For example, code t.m filename would find all lines containing the patterns "tim,""tom," and "tam."

The .* expression matches on any number of any character. For example, grep t.* filename would find all lines containing words that begin with a t in the specified file.

The caret character (^) refers to the beginning of a line. For example, grep ^W filename would find all lines that begin with a W in the specified file.

The $ expression refers to the end of a line. For example, grep 4$ filename would find all lines that end with a 4 in the specified file.

The [] and [ - ] expressions provide the same functionality as they do in the shell metacharacters.

The backslash ( \ ) character tells the shell to interpret literally the character immediately following the "\". For example, \. would cause the shell to interpret the "." literally, rather than as a special character.

If the pattern contains spaces or tabs, the entire pattern must be enclosed in single quotes. If the pattern contains special characters that the shell might try to interpret, it is good practice to place the pattern in single quotes. Until you are comfortable with the differences between the regular expression metacharacters and the shell metacharacters, it is a good idea to place the regular expression in single quotes if it contains metacharacters, tabs, or spaces.

Let's look at some examples of grep commands containing metacharacters. In the example, grep '197.*MK' nyp1, the search pattern is placed in quotes because the asterisk has special meaning to the shell. Placing the pattern in quotes prevents the shell from trying to interpret the asterisk. In the command grep ^J nyp1, because the caret has no special meaning to the shell, it isn't necessary to place the pattern ^J in quotes. However, it is good practice to place in quotes any regular expression that contains metacharacters.

You can also use grep to filter the output of another command (rather than working on a specific file). For instance, rpm -qa|grep samba. The rpm -qa command would normally display to the screen all of the installed packages. Here, we are piping that output as input to the grep command and searching for the text "samba" in the output.

The find Command

The find command, which you learned about in the lesson entitled, "Introduction to the Filesystem," is also often used in shell scripts. It is useful in locating files that haven't been recently accessed so they can be backed up and deleted from the filesystem. It is also useful to locate all of the files owned by a user. It is often combined with the grep command.

114

Page 115: HISTORY AND DEVELOPMENT OF LINUX22

The cut Command

The cut command is used to cut out selected columns or fields from the specified files. In actuality, what it does is print out the selected parts of lines from each file to the screen. You can redirect it to a file-an excellent use for a script file! The following table lists how to select the parts of lines in a file.

The Parts of Lines in a File

Option To-b or –byte=list Print only those bytes.-c or –characters=list Print only those characters.-f or –fields=list Print only those fields. Also prints any line without a delimiter character unless suppressed

with the –s option-s or –only-delimited Not print lines without delimiters.-d or—delimiter=delimiter Change the field delimiter from [Tab] to the specified delimiter.

This could be used in a script file to obtain user (field 1) and real names (field 5) from the password file with the command cut -d: -f1,5 /etc/passwd. It could also be combined with the who command to list login names with the command who | cut -d" " -f1.

The cut command can also be combined with the paste command to print the cut results in a file. The cut results will be pasted into tab separated columns in the new file. For example, to cut field 4 in file1 and paste it back in the first field of the same file, enter cut -f4 file1 | paste - file1.

The if Command

The if command begins a conditional statement. The if command needs to be combined with then, else, or fi to be useful. The following table explains each of these commands.

The if commands

Command Descriptionif Indicates the beginning of the conditional statement and specifies the criteria being evaluated.then Specifies what the script should do if the “if” condition is true.else Specifies what the script should do if the “if” condition is false.fi Indicates the end of the conditional statement.

1. What is a shell script?

Ans: A file consisting of Linux commands and programming constructs.

2. What do you need to do in order to run a script file?

Ans: Change the file permission to include the executable (x) permission for those who will be running it.

CHAPTER 13 Multitasking

Lesson 1Managing Jobs and Background Processes

Lesson Objectives

115

Page 116: HISTORY AND DEVELOPMENT OF LINUX22

In this lesson, you will:

Define multitasking. Describe what a jobs table is used for.

Introduction:-A key feature of the Linux operating system is its multitasking capability. This multitasking capability was what set UNIX operating systems apart from other operating systems. Multitasking is the ability of the operating system to run more than one process concurrently. For example, the user may simultaneously be spell-checking a document, compiling a computer program, and reading and replying to email.

The processes created by these tasks are all active at the same time. However, users are still able to work at their terminals as if only one task were being performed. The processes aren't in a sequential order or suspended state, waiting to be run. Rather, they are active and sharing the processing resources. Processes placed in a multitasking state remain active until completed, unless terminated or suspended by the user.

The Program and Process Concept

To understand multitasking and the ways in which the user is able to manage multitasking, it is necessary to distinguish between a program and a process. A program is a set of instructions describing how to carry out a task. A command that resides on your system is a program. For example, the ls command contains instructions for displaying the names of files and directories on the terminal screen.

When you enter a command from the prompt, you're putting into action a set of instructions to perform a task. The operating system creates a process to carry out that task. While there is no universally agreed-upon definition of a process, perhaps the most common definition is that a process is a program in execution.

The processes that are created have unique identities and exist until their tasks are completed. Each process is assigned a specific identification number. When the task is completed, the process is terminated.

The Linux operating system and the shell provide the user with techniques to manage processes. In this lesson, you will work with the tools used to manage processes.

Running Multiple Processes:-You can work at the prompt and run many programs simultaneously provided that you place the programs in the background. To run a program, start a process, and place the process in the background, you type the appropriate command followed by the ampersand character (&).

TIP:You can put a space or leave no space between the command and the ampersand.

116

Page 117: HISTORY AND DEVELOPMENT OF LINUX22

Understanding the Jobs Table:-The shell maintains a table containing information about processes that are running in the background. This table is referred to as the jobs table. Each user has their own jobs table. Any jobs that a user has placed in the background will appear in that user's jobs table, but other users' jobs won't appear.

Each job in the table is assigned a number. To display your jobs table, use the jobs command. The jobs table contains the following information:

A numeric label for each job. These labels usually indicate the order in which the jobs were started. A plus symbol (+) to designate the current job or the most recently started job.

A minus symbol (-) to designate the job that was started just before the most recently started job.

The status of each job.

The name of each job, which is also the command that started the job.

TIP: The plus (+) and minus (�) symbols indicate only the order in which jobs are started. However, all of the jobs are actually being run simultaneously. The processor is swapping execution among the different jobs.

There are four possibilities for the status of a job as shown in the following animated tip.

117

Page 118: HISTORY AND DEVELOPMENT OF LINUX22

The jobs table contains entries for only those jobs that are running your current shell. If you were to start a new copy of the shell, the jobs table for the new shell would be empty. However, the jobs started in the previous shell would continue to run.

Terminating Jobs Listed in the Jobs Table:-If a job is hung up, taking longer than expected, or needs to be stopped before completion, you can use the kill command to terminate the job. The kill command followed by a percent sign (%) and the number of the job entry enables you to terminate a specific entry in the jobs table. A message is displayed to the screen, indicating successful termination. If there is only one job running in the background, you don't have to specify the number in order to terminate the job. For example, kill % works just like kill %1 if there is only one job running in the background.

Using the Jobs Table to Bring a Job to the Foreground:-If you need to bring a job from the background to the foreground, use the fg command, with the format fg %#. This command brings the specified job to the foreground. You don't have to enter a number after the percent sign (%) if there is only one job running in the background.

Suspending Jobs:-If you have a job running in the foreground and you want to place it in the background, you must first suspend the job, and then place it in the background. Press Ctrl+Z to suspend a job running in the foreground. This key combination suspends the current job and enables you to use your terminal.

Notice that the Ctrl+Z key combination suspends a job, while the Ctrl+C combination terminates, or kills, the job. If you display the jobs table after you press Ctrl+Z to suspend a job, you'll see that the current job is in a suspended state (labeled in the jobs table as "Stopped"). Although the jobs table lists jobs running in the background, a foreground job that gets suspended appears in the jobs table to remind the user that there is a suspended job waiting to be restarted or terminated. Refer to the table for a summary of job control command.

Action Foreground Background

Suspend a process Ctrl+Z Bring to foreground; then press Ctrl+Z

Terminate a process Ctrl+C Kill %#

Let's try suspending some foreground and background jobs.

Restarting a Suspended Job:-To restart a background process that has been suspended, use the bg command. The bg command will restart the specified background job. If there is only one process running in the background, then you don't have to specify a number in order to restart the process in the background. You can simply type bg % to restart the process. Next, let's try bringing proj3 to the foreground, suspending it, and then starting it again in the background.1. What is multitasking?Ans: The capability to perform more than one task at a time for each user.

2. What is a jobs table?

Ans: A table containing information about processes running in the background. Each user has his or her own jobs table.

Lesson 2 Using the Process Table to Manage Processes

Lesson Objectives

In this lesson, you will:

Define a process table. Explain the difference between a parent process and a child process.

Introduction:-While the jobs table is unique to each user's specific shell, the process table is system-wide. The jobs table contains entries only for jobs that one user specifically places in the background. The process table contains entries for all of the processes that are started by any of the users on the system.

118

Page 119: HISTORY AND DEVELOPMENT OF LINUX22

The process table enables the operating system to keep track of all users' activities. Each process started by a user is assigned a PID (Process Identification) number. In the user's job table, a single entry may consist of more than one process (as when commands are strung together with semi-colons). In the process table, each process is assigned a specific PID number.

The ps Command

Use the ps command to display the processes in the process table started from your login shell. The ps command displays the information found in the following rollover.

ps Command Information

Name Description

PID Process identification number. TTY Terminal on which the process is running.

TIME Processor time used by the job.COMMAND Name of the command.

Child Processes:-The process table contains listings for child processes as well as for the original or parent processes that you start. A child process is one that is started by another process. There might be several levels of processes. The original process can spawn a child process; the child process can spawn another child process, and so on.

In the jobs table, only the original process is displayed as an entry. In the process table, the original process and all of the subsequent processes that are started are displayed.

Identifying child processes isn't an easy task. By examining the order of the Process Identification numbers, you might be able to determine the order in which the processes were created, and infer which processes are related. Let's compare jobs tables and process tables to see what they show us.

There are many options available with the ps command. Let's examine some of the options that are used most often.

119

Page 120: HISTORY AND DEVELOPMENT OF LINUX22

ps Command Options

ps Option Descriptiona Lists all processes.e Includes environment information.l Lists processes using a long listing format.u Includes user name and start time.r Excludes processes that aren’t running.x Includes processes without a terminal.

Various options display different fields. The following rollover lists the fields that can be displayed via the ps command.

ps Command Fields

Field DescriptionPRI Process scheduling priority. Lower priority has higher number.NI Process nice value. Processes using less CPU time have a higher number. SIZE Virtual image size.RSS Physical memory in KB.WCHAN Kernel function in which process resides.STAT Status. Values includes R(running), T(stopped), D(asleep & uninterruptible), S(asleep), Z(zombie), W(no

resident pages), N(postive nice value).TT The TTY associated with the process.PAGEIN The number of major page faults.TRS Resident text size.SWAP Number of KB of swap used.SHARE Amount of shared memory.Using the PID Number to Terminate Processes:-You have learned how to use the kill command with the jobs table. You can also use the kill command with the process table. By entering kill followed by the PID number, you can terminate specific processes.

When you use the kill command with the jobs table, you are working only with jobs that you have started. However, the process table might display processes that don't belong to you. As a user, you can use the kill command only with processes that you own. As root, you can kill anyone's processes. Next, let's use the kill command and the PID number to terminate a background process.

Learn about terminating a process by following the steps below.

Enter ls -lR / 2> err| grep date >file1 & to place in the background a search for the pattern date in all of the files on your system. The errors are being redirected to the err file and the output of the grep command is being redirected to file1.

Display the process table and observe the entries. A process has been started for the ls command as well as for the grep command.

Determine the PID number of the ls process, and then enter kill followed by the PID number of the ls process to terminate the ls process.

Display the process table again to verify that the ls process has been terminated.

Using kill Signals:-There are many options available with the kill command. These options are referred to as kill signals.

On occasion, you might run into a difficult process that can't be eliminated by the kill command. To terminate this process, use the kill command with the -9 signal. This is an immediate and unconditional termination of the process.

120

Page 121: HISTORY AND DEVELOPMENT OF LINUX22

TIP: Before terminating a process, be sure that you understand what the process you are terminating does, and whether you really want to terminate it. Terminating processes that have parents or children may result in unexpected and undesirable results

Follow the steps below to learn how to use the -9 Signal.

Enter ls -lR / 2>err| grep date >file1 & to place in the background a search for the pattern date in all of the files on your system.

Determine the PID number of the ls process, and then use the kill -9 PID number command to send an unconditional and immediate terminate signal to the ls process. For example, if you found that the ls PID was 1346, you would enter kill -9 1346.

1. What is a process table?

Ans: A table created by the ps command that lists all of the processes running on the system.

2. What is the difference between a parent process and a child process?

Ans: A parent process is a process that you start. A child process is a process started by another process.

Lesson 3 Introducing Delayed and Detached Jobs

Lesson Objective

In this lesson, you will:

Explain the difference between a delayed job and a detached job.

Introduction:-Delayed and detached jobs enable users to put off the start of a job until a later time (while still logged in) or to wait until they are logged out of the system before starting a job. A delayed job is one that can be run at some specified time after you issue the command. A detached job is a job that can be run after you log out.

Delaying the Start of a Process

To delay the start of a job, use the sleep command followed by the delay in seconds and the command name. The sleep command suspends any action upon the specified command for the specified number of seconds, and then the command is executed. The number of seconds can be up to 2,147,483,647 seconds. This is roughly 596,523 hours, or 24,855 days, or 68 years, so you should have plenty of time!

Follow the steps below to learn how to use the sleep command

Enter who to display the current system users. The command is run as soon as you press the Enter key. Enter sleep 5; who. This delays the start for five seconds with the sleep command, and then when the

five seconds are up, the who command is run.

Running a Process After You Leave the System:-If you have a task that won't be completed until after you leave work, or if you have a task that is CPU intensive and might slow the system, you might want to start the task before you leave and specify that it continue even after you log out of the system. You can do this by using the nohup (no hangup) command. The nohup command should be run in the background so that it doesn't tie up your terminal.

To enable a command to run in the background after you have logged out, use the syntax, nohup command &.

1. What is the difference between a delayed job and a detached job?

121

Page 122: HISTORY AND DEVELOPMENT OF LINUX22

Ans: A delayed job can be run at some specified time after issuing the command. A detached job is a job that can be run after logging out.

CHAPTER 14 Configuring and Managing Services

Lesson 1 Starting and Stopping Services

Lesson Objective

In this lesson, you will:

Define syslog.

Overview

he Linux init program is responsible for starting all of the processes that need to run at boot time on your system. A script for each of these processes is located under /etc/rc.d/init.d/ directory. Each of these scripts has been written to accept an argument, which can be start, stop, and restart. These arguments enable you to start, stop, or restart the service defined in the script file. In addition to starting these files through the init file, you can run the scripts manually, followed by one of the arguments listed above.

For example, the http daemon, httpd, is located in the /etc/rc.d/init.d directory. To start the HTTP service, enter /etc/rc.d/init.d/httpd start; to stop the service, enter /etc/rc.d/init.d/httpd stop; after making changes to configuration files, you need to restart the service with the command /etc/rc.d/init.d/httpd restart. Many scripts also include the argument status, which will display the current status of the service-started or stopped.

Syslog

Syslog is the utility used by many daemons to log messages to various system log files. It is a good idea to always run syslog. An example of the syslog file is shown below.

1. What is syslog?

Ans: A shell script containing a series of commands using if and case statements. It also includes functions for the various capabilities of the script, including start and stop. The Restart option runs the stop and start functions.

Lesson 2 Identifying Core and Non-Critical Services

Lesson Objective

In this lesson, you will:

122

Page 123: HISTORY AND DEVELOPMENT OF LINUX22

Explain how processes relate to your login and the commands you enter.

Overview:-Some services are required in order for your Linux server to work properly. These core services include ps, PID, PPID, init, and timer services. Depending how you configure your system, other services might or might not be running. These non-critical services include SMB, NIS, NFS, HTTP, POP, SMTP, SNMP, and FTP. Let's look at how these critical services are used in making Linux function.

But first, we should define process. A program that runs independently with its own set of resources is referred to as a process. The kernel manages all of the finite system resources such as memory and disks. All other parts of the system are referred to as processes.

Your terminal is monitored by a getty process before you log in. This process dies after you log in and the terminal is then managed by your shell. This is a separate process. A new process is created for each command you enter. When processes are split, this is referred to as a forked process.

The ps command reports process status. It gives a snapshot of the current processes running on the system. This is often used with the -aux options to display information about the running processes.

PID retrieves process ids. The IDs are created with the open command. The pid command returns a list of the process identifiers of all the processes in the pipeline, in the order they are listed. The first column of the ps command output displays the PID of the process.

PPID refers to the Parent Process ID. The init process is the parent of all processes. It creates processes using the script file /etc/inittab. This file controls autonomous processes and contains the code to spawn gettys that enable you to log in.

The timer process is used to queue events for processing by the kernel. The kernel records the time a process is created and the amount of CPU time it has consumed. The CPU time includes both the time spent in user mode and the time spent in system mode. Processes may also have their own interval timers, which may be single shot or periodic. These can use signals to notify the process when timers expire.

1. How do processes relate to your login and the commands you enter?

Ans: Your terminal is monitored by a getty process before you log in. This process dies after you log in and the terminal is then managed by your shell. This is a separate process. A new process is created for each command you enter.

Lesson 3 Configuring Basic Client Services

Lesson Objectives

In this lesson, you will:

Define NIS. Define NFS.

Introduction:-Samba is an open source application that provides SMB/CIFS protocol support for a variety of platforms, including Linux. Samba provides the following CIFS (Common Internet filesystem) services:

123

Page 124: HISTORY AND DEVELOPMENT OF LINUX22

TIP:SMB is the Server Message Block protocol, and came out of what was the file-sharing capabilities of the NetBIOS network interface software. CIFS is the Common Internet filesystem.

Samba allows Linux to emulate the most popular services that a Microsoft Windows NT® or Windows 2000® server provides. In fact, several independent tests have shown that Samba on Linux outpaces Windows NT at its own game! Samba is fairly easy to install and configure in a simple installation. When it is installed, the main configuration file, smb.conf, is created. Several other configuration and utility files are also installed with the package. The following is an example of the minimum required for smb.conf.

A sample smb.conf file.

The three default sections of the smb.conf file are [global], [homes], and [printers]. Options within each section are used to configure Samba. You can define other sections by placing the section name within brackets, such as [tmp] and [dos-disk].

A sample smb.conf file, such as the example shown in the figure above, enables remote users to access their home directories on the local machine. Users connect a network drive from Windows File Manager or Explorer.

124

Page 125: HISTORY AND DEVELOPMENT OF LINUX22

The smbd might bind to the wrong Ethernet interface if the system contains multiple NICs. To make it bind to the desired NIC, you can add a line to the [global] section containing the IP address of the NIC that is assigned to the correct Ethernet interface.

When specifying the hosts that can connect to your Samba server, use the hosts allow directive. You can use network wildcard ranges; for example, 192.168. would enable any host with the 192.168. prefix to connect to the Samba server.

Starting the Samba Service

After you install Samba, you need to check that the settings in smb.conf are appropriate for your needs. There are five main steps to configuring the file. You need to check the workgroup setting. By default, this is set to WORKGROUP. Set the workgroup to the workgroup or domain containing the Windows system you will be sharing files and/or printers with.

Next, add the settings to identify the shared directory or printer. These entries should be placed in the Share Definitions section of the smb.conf file. Each entry consists of:

After you save the changes to the smb.conf file, you should check the syntax. This can be done using the testparm utility.

Now, you are ready to start the Samba server. Enter /etc/rc.d/init.d/smb start to start the server. If the server was already started, and you edited the smb.conf file, you will need to restart the server using /etc/rc.d/init.d/smb restart. You can also use smbrun to start the SMB server and smbstatus to display information about the server after it has started.

Finally, you should test whether you can access the Samba shares. Use the smbclient -L localhost command, and when prompted for a password, press the Enter key. All Samba shares should be listed if it has been properly configured. The smbclient program is the client software used to connect to an SMB server from a Linux client.

WINS Servers:-If a WINS server is present, the wins server directive should be set to the IP address of the WINS server. If there is no WINS server on the network, this directive can be commented out.

Other Files Needed for Samba:-Some of the files installed with Samba include:

smbpasswd: The file in /etc is used to configure the Windows password file for the server. The same filename in /usr/bin adds users to the /etc/smbpasswd file to enable the use of encrypted Windows passwords.

nmbd: Contains NetBIOS names for network systems.

smbuser: Maps Linux users to Windows users.

smbadduser: Adds Samba users to the system.

125

Page 126: HISTORY AND DEVELOPMENT OF LINUX22

smbmount and smbumount: To mount and unmount shared filesystems.

smbprint: Enables use of SMB shared printers.

Testing Samba:-As mentioned previously, part of setting up Samba is to test the configuration and access to the shares. You can use the status parameter with the smb command to display the current status of the Samba server.

The results of the smb status command.

The testparm command tests the syntax of the smb.conf file. If there are any sections that contain incorrect or missing information, you will be notified of this by the testparm command. If it doesn't find any problems, the message Loaded Services File OK is displayed; otherwise, it lists the errors so that you can fix them. It will also display a dump of your service definitions after this. This is a long listing of default services and the services that you defined.

The utility smbclient comes with the Samba package. It enables copying of files to and from a Samba share. This is similar to simple FTP client software. The format of the command is smbclient //HOSTNAME/username. To test your system, you can issue the command smbclient -L localhost -U username. You are prompted for your password and logged in to your home directory.

Connecting to a Samba server.

The network settings on the client must specify "Client for Microsoft Networks" as the primary network login and you must be logged in with the user name of yourname and the password you provided to smbpasswd. You should be able to view and edit files in a share called yourname on the Linux server (file path: //servername/yourname).

126

Page 127: HISTORY AND DEVELOPMENT OF LINUX22

Transferring Files from Linux to Windows:-The Samba server and client applications can be used to transfer files to and from Windows machines. In Linux, the smbclient utility provides a simple method of accessing files from a file share on a Windows, or another Linux, system. Windows users can easily copy files from a Linux server using the standard file sharing methods.Transferring Files from Windows to Linux:-Just as you could transfer files from the Linux environment to your Windows workstation, you can transfer files from your Windows workstation to your Linux system. Let's try it now.

NIS:-The Network Information Service (NIS) was developed by Sun Microsystems to provide a centralized method of storing user information and provide distributed authentication capability across an enterprise. NIS is fully supported under Linux and it can be configured to use NIS or NIS+ for all user authentication requirements. For simplicity, this topic will refer to both NIS and NIS+ as NIS.

NIS Clients

NIS clients query a NIS server to perform user authentication and obtain information about a user. The NIS server can be explicitly configured, or the client can automatically find a NIS server via a network broadcast.

PAM (Pluggable Authentication Modules) provides an interface to NIS that allows existing applications to use NIS for user authentication. This PAM interface is supplemented by the following NIS client utilities, which can be found in the yp-tools and ypbind RPM packages.

NIS Client Utilities

127

Page 128: HISTORY AND DEVELOPMENT OF LINUX22

Command Descriptionypbind Gathers and records NIS domain and server information.ypwhich Find the NIS server name used by the client.ypcat For the specified NIS database, print all key values.yppoll Displays the specified NIS map version and master server.ypmatch Display NIS map key values.

PAM is the interface layer of the authentication subsystem. This works closely with NIS to resolve the commands in the previous table. NIS then passes the results of these commands to PAM.

NIS Server

A NIS server provides centralized directory and authentication services for the network. Multiple NIS servers, in a master/slave(s) configuration, are often used in larger NIS installations.

The NIS server daemon, ypserv, provides NIS services. Since NIS is handled through Remote Procedure Calls (RPC), the portmapper (portmap) daemon is also required. The makedbm utility is used to convert an existing /etc/passwd file into a NIS user database. Password changes are handled by the rpc.yppasswd daemon, and these changes are propagated to slave NIS servers via the yppush command.

The NIS server is provided in the ypserv RPM package. The /etc/nsswitch.conf file configures the order in which lookups occur when user information or authentication is requested by a NIS client.

Follow the steps below to examine the nsswitch.conf file.

Log in as root. Enter less /etc/nsswitch.conf to display the file one page at a time.

NIS stands for Network Information Service. It provides a centralized method of storing user information and provides distributed authentication capability across an enterprise. The name of the configuration file for NIS is /etc/nsswitch.conf. Read through the comments at the top of the file. These comments document the purpose of the file. Read through the rest of the file and observe the default settings. You often use these default settings and rarely change them. You should be aware of what the defaults are, though, in case they get corrupted or changed.

The Network filesystem (NFS) was introduced in an attempt to provide transparent file access across a network. An NFS client connects to an NFS server and mounts the exported directories at a local mount point. These shared directories can then be accessed as if they were on the local filesystem.

A single NFS server can service multiple clients simultaneously, making NFS an excellent solution for shared CD-ROM, file, and database servers. NFS clients are available for most major operating systems, but are most commonly used on Linux and UNIX systems. For a file sharing solution for Microsoft Windows® clients, Samba is the answer.

An NFS volume resides on a specific system, but is mounted as a local filesystem on remote systems. To make a filesystem available through NFS, you need:

TCP/IP access between the host and clients. The resident filesystem made available for export.

The client to mount the remote filesystem via the mount command (or fstab for automatic mounting at boot time).

NFS uses the client-server model. The remote system is considered the server and the local system on which you are mounting the remote filesystem is considered the client.

128

Page 129: HISTORY AND DEVELOPMENT OF LINUX22

The mount command is used to mount the remote filesystem, just as it is used to mount local filesystems. Edit the /etc/fstab file to enable users to mount the remote filesystem; specify the user option in the file so that users don't need to be root to mount the remote filesystem.

1. If you want to share a CD-ROM from a central server, would NFS be an appropriate solution? Why or why not?

Ans: Yes, it would be appropriate. NFS was developed specifically to share filesystems on remote systems.

2. For which operating systems was NFS developed?

Ans: Linux and UNIX.

3. To make a filesystem available through NFS, what do you need?

Ans: TCP/IP access between the host and clients, the resident filesystem made available for export, and the client to mount the remote filesystem via the mount command or fstab for automatic mounting at boot time.

NFS servers tend to fill a variety of roles in an organization. One of these roles is as a central data file repository to a number of clients spread across an enterprise. By connecting to a remote NFS server and mounting the exported files on the local system, users on multiple workstations can seamlessly operate on the same data.

Client-Side Files for NFS

To mount a remote filesystem, you need to have specific daemons running on your client system as well as on the server system. The client modules include portmap, mount, and showmount.

In order for the NFS file locking feature to work correctly, portmap and NFS file locking services need to be running. The showmount command displays information about an NFS server, such as the exported filesystems on that server. The portmap command is a DARPA port to RPC program number mapper. It is a server that converts RPC (remote procedure calls) program numbers into DARPA protocol port numbers. It must be running in order to make RPC calls. When an RPC server is started, it will tell portmap what port number it is listening to and what RPC program numbers it is prepared to serve. When a client wants to make an RPC call to a given program number, it first contacts portmap on the server to determine the port number where RPC packets should be sent.

The mount command is used to mount the remote filesystem. The format of the command is mount servername:/path /mountpoint where servername is the name of the system containing the exported filesystem, path is the path on that system to the exported filesystem, and mountpoint is the mount point on your local client where the remote filesystem will be mounted.

Installing NFS:-In order to provide NFS services to clients, an NFS server needs to be installed. Once installed and configured, an NFS server can export multiple filesystems to various clients and provide a central file repository for your users.

NFS can be installed when you install the server or you can install it later. The NFS daemon requires several other files to run. These include portmap and rpc. If you start the NFS server using the /etc/rc.d/init/d/nfs start command, the portmap daemon and the RPC daemons that are part of the knfsd package (rpc.statd, rpc.rquotad, rpc.mountd, and rpc.nfsd) are all started. You also need to create and configure the /etc/exports file to specify which filesystems are to be made available, to whom, and with what rights.

Checking that NFS is Installed

Depending on the options chosen during installation, the NFS daemons may not be installed on your system. The core of the NFS system is implemented as a kernel module in recent kernel versions. As a result, only the NFS portmap, mountd, and nfsd daemons are necessary to provide NFS services. The following animated tip describes the purpose each of these commands has in supporting NFS.

129

Page 130: HISTORY AND DEVELOPMENT OF LINUX22

Another useful tool in determining the status of a command is chkconfig. The chkconfig utility updates and queries runlevel information for system services. It can be used to start and stop services also. The --list option shows whether the specified services are on or off.

Another useful tool in determining the status of a command is chkconfig. The chkconfig utility updates and queries runlevel information for system services. It can be used to start and stop services also. The --list option shows whether the specified services are on or off.

Format of an entry in the /etc/exports NFS configuration file.

The first portion of the line specifies the export point. It indicates the directory on the local filesystem to be exported. The second portion is the machine name specifier. This portion lists the hosts that are permitted to connect to the share. Notice in the example that the wildcard (*) is used to include all of the hosts on the logicept.com network. The final portion of the line contains the configuration option. The information between the parentheses following the host(s) lists the configuration parameters in place for that particular host.

Mount Options

You can configure how the filesystem is exported, whether users will have read only access, and who will be able to access it. The following rollover describes some of the common options you might configure.

Mount Options

Option Description

130

Page 131: HISTORY AND DEVELOPMENT OF LINUX22

ro Default. Read only.rw Read/Write.root_squash Root access request mapped to NOBODY_UID on server.no_root_squash Default. Enables root user on the local system to access file as if they were root on the remote server.noaccess Client has no access below the specified directory.all-squash Maps all users to anonymous user, useful for FTP sites.no-all-squash Default. Maps user ID on local system to user ID on remote system.

The machine name identifier might be a specific domain, a list of domains, a list of specific clients, or blank. If it is blank, anyone can access it.

A sample /etc/exports file.

Reloading the NFS Configuration:-After making changes to the /etc/exports file, the NFS services need to be restarted for those changes to take effect. Rather than restarting the service (and possibly disrupting users already using NFS), the following commands found in the following animated tip can be performed to update the exported filesystems.

Automating NFS Filesystem Mounting:-During installation, the /etc/fstab file was created. This file defines the default filesystem types and mount points for the filesystems you want to mount on your system. The settings in this file make it more simple when you go to mount a filesystem. It contains information such as the mount point, filesystem type, type of mount and filesystem dump, and mount order. You can also specify if a filesystem should be mounted automatically when the system is brought up.

A sample /etc/fstab file.

You can add new filesystems manually to this file. That is how you would automatically mount an NFS filesystem from another system to your system each time you reboot your system. There are no services that need to be restarted after editing the file, so it

131

Page 132: HISTORY AND DEVELOPMENT OF LINUX22

is ready to use as soon as you save your changes. Of course, you'll need to manually mount volumes set for automount if you want to access them before you reboot your system.

An example entry you would need to add to mount an NFS to your system in your /etc/fstab file is: servername:/path mountpoint nfs defaults 0 0. The fourth column (defaults in this example) is used to specify mount options. These might include noauto so the filesystem isn't automatically mounted at reboot, ro for read-only access to the filesystem, or user so the user doesn't need root access to mount the filesystem. These options can be combined in a comma-separated list. The final column (in the example 00) specifies if it can be dumped and the order it should be mounted.

While NFS is extremely useful, there are some drawbacks. NFS is vulnerable to RPC security holes. Also UIDs and GIDs (user and group number IDs) are exposed and are vulnerable to attack. Be sure to secure portmapper to help seal these potential holes.

1. What is NIS?

Ans: Network Information Service (NIS) is a service developed by Sun to provide a centralized method of storing user information and distributed authentication capability across an enterprise.

2. What is NFS?

Ans: The Network filesystem (NFS) is a filesystem type that provides transparent file access across a network.

Lesson 4 Configuring Basic Internet Services

Lesson Objectives

In this lesson, you will:

List three basic Internet services included with Linux. Define a proxy cache.

Introduction:-There are several basic Internet services that you will encounter. These include HTTP for serving Web pages, ftp for serving ftp files, gopher for locating files on the Internet, and others. Each of these has a specific daemon to service those requests. Let's look at the HTTP daemon, httpd.

The httpd Daemon

One of the reasons Linux became so popular was that it came with a free Web server named Apache. This enabled people to quickly and inexpensively set up a Web server and start serving Web documents.

To create a Web server, configure httpd, the daemon that services HTTP requests. You will then need to create the documents that will be served up on your Web server. There are many HTTP servers available, but Apache Web server is the most popular.

Depending on your Linux distribution and the version of the httpd server you are using, the file and directory structure supporting the Web server varies. In any case, the following table attempts to describe the most common location for the files and directories. You can use the find and locate commands on your system to determine the location of the files. You can also examine the httpd configuration file to see what files and their locations have been defined to support the httpd service.

Httpd Configuration

File or Directory Description/usr/sbin/httpd The file is the server itself. The httpd executable file is run and it reads the

configuration file to get its setting./etc/httpd/conf This directory contains the httpd configuration files. The main configuration file in

most instances is the file httpd.conf./var/www.html or /usr/local/httpd This directory contains the HTML files to be served on your Web server. U can set this

132

Page 133: HISTORY AND DEVELOPMENT OF LINUX22

using the DocumentRoot directive in the httpd.con file./var/log/httpd or /etc/httpd/logs This directory contains the server log files. These are typical named access, error &

combined or something similar. The location of these files can be set using the appropriate directives in the httpd/conf file.

Follow the steps below to learn how to configure HTTP services.

Enter find / -name httpd to locate the httpd executable file on your system. Record the location of the file.

Locate the httpd.conf or equivalent file on your system, then record the location.

Open the httpd.conf file in your favorite editor and examine the structure of the document. It contains keywords called Directives that are used to define how the Web server is set up and configured. The values between the opening and closing Directive keywords show the location of files or directories, or describe how the server serves up documents.

Determine the DocumentRoot on your Web server. Then, determine the location of the log files and the names of the log files used.

Close the file.

Configuring SMTP Services:- One of the most popular Internet applications is Electronic Mail, or email. The first form of email was sent sometime in the early 1970's. Today, there are tens, if not hundreds of millions of email users throughout the world.

The modern Internet email system is implemented by a set of standardized protocols and a combination of several server applications. The figure below illustrates the process of sending an email to a user. In the illustration, the email is composed by the originating user in an email client, also referred to as a Mail User Agent (MUA). Some of the more popular MUAs are Microsoft Outlook, Lotus Notes, Qualcomm Eudora, Netscape Composer, and Pine. Once the message is composed and the user clicks on Send, the message is transmitted to the user's local SMTP server (often provided by their ISP) via the Simple Message Transport Protocol (SMTP). The SMTP server, also called the SMTP Mail Transfer Agent (MTA), receives the message and places it in its outgoing message queue. When the server is ready to send the message, it removes the message from the queue and sends it to the target user's SMTP server (via the SMTP protocol). At this point, the SMTP server will store the message in the target user's Inbox. When the target user next checks his or her email, the message will be detected and retrieved, most often by the Post Office Protocol (POP) or Internet Message Access Protocol (IMAP). The user then views the message on his or her email client.

Red Hat Linux comes with sendmail, the most commonly used SMTP server on the Internet. Sendmail provides SMTP mail sending and relaying services. Red Hat Linux also has POP and IMAP servers for the retrieval of email. In the following topics, we will discuss the configuration and use of these services.

1. What is another name for an email client?

133

Page 134: HISTORY AND DEVELOPMENT OF LINUX22

Ans: Mail User Agent (MUA).

2. Once the message is composed and the user clicks on Send, where is the message transmitted?

Ans: Simple Message Transport Protocol (SMTP).

3. What SMTP server is included with Red Hat Linux?

Ans: Sendmail, the most commonly used SMTP server on the Internet. It also includes POP and IMAP servers for email retrieval.

Configuring Sendmail:-Sendmail is one of several available MTAs that provide SMTP services for the sending and relaying of Internet email. Other commonly used MTAs for Linux include Qmail and Postfix.

Sendmail is configured via a complex set of rules, called rulesets, that dictate the paths that incoming and outgoing email should take. These rulesets specify the way Sendmail handles cases including mis-addressed emails, email aliases, and email domains. Sendmail rulesets are specified in the /etc/sendmail.cf configuration file.

Because the rulesets are configured in a default manner, a system administrator generally does not need to alter the configuration for a typical installation. However, an administrator may desire to configure Sendmail for a specific machine name(s) and to add email aliases. If a machine has multiple names, for example foocompany.com and www.foocompany.com, these have to be configured in order for Sendmail to properly receive email addressed to both machine names.

Configuring POP Services:-The Post Office Protocol (POP) provides a means for email clients to retrieve messages from an email server. The Internet Message Access Protocol (IMAP) also provides this capability, but includes several more advanced features for multiple folder management and advanced user authentication. Both POP and IMAP services are installed as a part of the imap RPM.

POP3 is the current version 3 protocol. POP3 is defined in RFC 1081. POP3 enables a client to retrieve email from a POP3 server. This is often a remote, dial-up connection. POP3 doesn't cover sending email. Sending email is carried out with SMTP or a similar protocol.

Because POP clients don't usually have a permanent network connection, a post office, the POP server, holds users' mail until they retrieve it. Messages are stored on the post office server and then downloaded to the client systems to be read. Most client software enables users to read and store messages offline after retrieving them from the POP server.

Follow the steps below to learn how to install POP and IMAP services.

Enter rpm -q imap to check that the imap RPM is installed on your server. If it is not, install the imap RPM with the rpm -Uvh command.

View the file /etc/xinetd.d/ipop3.

By default, this service is disabled. Using a text editor, edit the ipop3 file and change disable=yes to disable=no to enable it.

Enter /etc/rc.d/init.d/xinetd reload. At this point, you would be able to connect to a POP or IMAP service.

Configuring SNMP Services:-SNMP (Simple Network Management Protocol) is a network management protocol. This can be implemented on a Linux system using the ucd-snmp package, created by the UCD-SNMP project. UCD-SNMP comprises various SNMP tools, including:

134

Page 135: HISTORY AND DEVELOPMENT OF LINUX22

This package contains the snmpd and snmptrapd daemons, documentation, and such. Network management tools can be found by installing the ucd-snmp package. Install the ucd-snmp-utils package for additional UCD-SNMP utilities.

SNMP enables you to remotely monitor and configure routers, bridges, network cards, switches, and so forth. There are many libraries, clients, daemons, and SNMP-based monitoring programs available for Linux.

Or, as David Perkins posted in a recent response to a newbie: "It will take you at least six months or so of studying and usage to SNMP very well. I suggest that you read a few books (more than one) on SNMP and RMON, since authors focus on different aspects of the subject area."

Follow the steps below to learn how to configure SNMP services.

Install the ucd-snmp packages. Display the man page for snmp_config. This help page describes how to configure the ucd-snmp

applications.

Read through the man page.

Display and read through the snmpd.conf man page.

Display and read through the snmp_config man page.

Display and read through the /etc/snmp/snmpd.conf file. The comments (the lines beginning with #) explain how this file is used. Follow your instructor's discussion of this file.

FTP:-The File Transfer Protocol, or FTP, was one of the original Internet protocols created to make the transfer of files across TCP/IP networks simple and reliable. The wu-ftpd FTP daemon comes bundled with Red Hat and comes installed and configured out of the box. By installing the anonftp package, a publicly accessible FTP server can be configured.

Authenticated vs. Anonymous FTP

There are two methods for accessing a Linux server via FTP: authenticated and anonymous. Authenticated access requires that the user has a user name and password for the FTP server. Upon connecting to the server, the user enters that user name and password and gains access to his or her home directory on the system. The user can download files from the server via the FTP get command and upload files via the FTP put command according to permissions set for that user or that user's group.

TIP: It is a good idea to use your email address as your password for access to an anonymous FTP server, even though any password may be used.

135

Page 136: HISTORY AND DEVELOPMENT OF LINUX22

Anonymous FTP provides for a public file directory where any user can download (and sometimes upload) files. An anonymous FTP server is simply an FTP server that accepts the user name anonymous with any password and allows that user access to a directory of public files. One common use for an anonymous FTP server is to provide a public repository for downloading updates for your system.

Anonymous FTP Server Security Concerns

When you are determining whether to provide anonymous FTP access to your server, there are a number of security concerns to consider. The primary concern is that an anonymous user can upload files to your server for others to download without your knowledge. To avoid this, the default anonymous FTP installation restricts access to downloading. Be sure that you fully understand the implications of providing upload access to anonymous FTP users prior to implementation.

Starting FTP

Because FTP is started automatically by the xinetd daemon, there is no need to start an FTP daemon process. Other distributions that don't use xinetd, use inetd.conf to configure services such as FTP. In that case, you would need to edit the /etc/inetd.conf file and remove the comment mark (#) from the ftp and wu-ftp sections of the file, then restart inetd (killall -HUP inetd).

Follow the steps below to learn how to install FTP

Enter rpm -qa|grep ftp to check whether any ftp services packages have been installed. Several different packages containing ftp in their names might or might not be listed.

If necessary, install wu-ftpd and anonftp as well as any dependent packages. FTP is started automatically by the xinetd daemon on a Red Hat 7.0 system.

Configuring an FTP Server:-By default, users can get ftp access to your server and access their home directory after entering their user name and password. If this is the type of access you want for your ftp server, then no further configuration is required. However, if you want to limit access, there are three files that were installed with the package that you can use to change the configuration:

/etc/ftpaccess /etc/ftphosts

/etc/ftpusers

/etc/ftpaccess

The main configuration file for ftp is the /etc/ftpaccess file. The following table describes some of the important options you can set in this file.

136

Page 137: HISTORY AND DEVELOPMENT OF LINUX22

A sample /etc/ftpaccess file.

c/ftpaccess

/etc/ftpaccess Option Specifiesloginfails How many login attempts users are given before they are denied access.allow or deny tool access When or not utilities such as tar, chmod or compress can be used by the specified connection

type such as anonymous, guest or all.email Who errors are emailed to: by, this is to root.message The default file displayed.

/etc/ftphosts:-If you want to specify whether specific accounts are able to access the ftp server, you configure this in the /etc/ftphosts file. Entries in the file are either allow or deny in the format allow|deny username host. For example, allow anonymous 192.168.100.* lets anyone on the 192.168.100 network access the ftp server anonymously. Replacing allow with deny in this example would prevent anonymous access by users on the 192.168.100 network.

A sample /etc/ftphosts file.

/etc/ftpusers:-If you have specific users that you want to prevent from accessing the ftp server, add their name to the /etc/ftpusers file. Several entries are included in this file by default, as shown in the figure below.

137

Page 138: HISTORY AND DEVELOPMENT OF LINUX22

A sample /etc/ftpusers file.

TFTP:-TFTP is an unauthenticated version of FTP that runs over UDP. It is commonly used for diskless workstations, where the machine obtains its kernel from a TFTP server. To implement TFTP, you need to create a directory on your computer that will be the TFTP root. Be sure not to store any sensitive information in this directory. The TFTP daemon can't go outside of this root directory, so it can't access files like password or user files. To prevent unauthorized people from creating files, the file must exist before it is written. To do this, enter touch filename in the appropriate directory to allow the remote client to write to filename.

Exploring Squid:-The squid Web Proxy Cache is an open source, full-featured Web proxy cache for Linux and other Unix systems. Squid provides a variety of features, including:

A proxy cache acts as an intermediary for all requests from an internal network to the Internet (or any other external network). The proxy cache negotiates all requests on behalf of the client (for example, a Web browser) and retrieves the requested data from the external server. This data is then cached, or stored within the squid software, for future re-use.

When a Web browser requests a page that is already in the cache, the cached page is checked for freshness, and then it is returned to the user. This process of serving cached pages is much faster than retrieving the page from the external network. A proxy cache also provides methods for tracking usage of Internet resources and limiting access to selected sites.

The squid service is configured through the squid.conf file. By default, this file is located in the /etc/squid directory. Squid cache files are automatically created the first time you start squid. Squid listens on port 3128 for proxy requests. Squid can be installed from the squid RPM package.

1. What is squid most often used for?

138

Page 139: HISTORY AND DEVELOPMENT OF LINUX22

Ans: It is often used as a Web proxy server.

2. What is the squid configuration file?

Ans: squid.conf

3. What is the default port on which squid listens for proxy requests?

Ans: Port 3128 is the default port for proxy requests that squid listens on.

ipchainsIpchains is the Linux tool for managing packet filtering capabilities on a Red Hat Linux server. IP chains provides the ability to create Linux firewalls, gateways, and secure servers and workstations. The ipchains tool inserts and deletes rules from the kernel's packet filtering subsystem. These rules define the packets that are explicitly permitted or denied from being sent (or received) by the Linux system.

Blocking Access to Privileged Ports:-One common use of ipchains is to block access to the privileged ports of a Linux server. By blocking access to all incoming TCP/IP traffic, an administrator can prevent all network access to a networked Linux workstation.

Be sure not to confuse the term well-known ports with privileged ports. Well-known ports refers to a couple of different things (depending on who you ask), including those privileged ports that are assigned to specific services (for example, HTTP = port 80, SMTP = port 25), and this fact is "well-known." Technically speaking, there's nothing preventing anyone from running an HTTP server on port 25, even though port 25 is supposed to be SMTP. That's what well-known means. However, a non-root user couldn't run a server on either port 25 or port 80 because it's a privileged port.

1. What are ipchains?

ANs: The Linux tool for managing packet filtering.

2. What is the benefit of using ipchains?

Ans: The ability to create Linux firewalls, gateways, and secure servers and workstations.

3. What is a common use of ipchains? What does this do for you?

Ans: To block access to the privileged ports of a Linux server. By blocking access to all incoming TCP/IP traffic, an administrator can prevent all network access to a networked Linux workstation.

4. Compare well-known ports with privileged ports.

Ans: Well-known ports refers to the port on which a specific service is usually run. A privileged port refers to TCP ports 0-1023; only root can run.

1. What are three basic Internet services included with Linux?

Ans: Internet services include HTTP, SMTP, SNMP, and FTP.

2. What is a proxy cache?

Ans: A server service that acts as an intermediary for all requests from an internal network to the Internet or any other external network.

139

Page 140: HISTORY AND DEVELOPMENT OF LINUX22

Lesson 5 Working with Modules

Lesson Objective

In this lesson, you will:

Explain the difference between a monolithic kernel and a modular kernel.

Introduction:-The two primary components of the Linux operating system are the kernel and the shell. The kernel is the part of the system that interfaces directly with the hardware. Some of the functions the kernel performs include:

Managing computer memory. Maintaining the filesystem.

Handling errors and interrupts.

Performing input and output services.

Allocating system resources among users.

Monolithic vs. Modular Kernels:-In the early days of Linux, the Linux kernel was a monolithic kernel. A monolithic kernel is one in which all of the kernel services are compiled into the kernel itself and no external drivers are called. With a monolithic kernel, the kernel must be recompiled whenever a new device is added to the system.

As hardware support grew in Linux, the size of the full kernel also grew. Because the kernel must reside in memory at all times, the amount of memory required to boot such a kernel increased. In order to minimize the size of the running kernel, a modular Linux kernel was developed.

A modular kernel consists of a minimal core kernel, which is always present, and a set of modules that can be inserted into the running kernel to add support for additional devices and services. These modules can be loaded (and unloaded) as necessary. For example, if a server uses its SCSI tape drive only on rare occasions, the SCSI module for the drive would be loaded on use and then unloaded when the backup was complete. With a modular kernel, hardware devices can be added to a system without recompiling the kernel (as long as a module for the device is already compiled).

1. What are the two primary components of the Linux operating system?

Ans: The kernel and the shell.

2. List some of the functions provided by the kernel.

Ans: Answers might include: Managing computer memory, maintaining the filesystem, handling errors and interrupts, performing input and output services, and allocating system resources among users.

3. Compare monolithic and modular kernels.

Ans: Monolithic kernels are those in which all of the kernel services are compiled into the kernel itself, and no external drivers are called. Modular kernels consist of a minimal core kernel and a set of modules that can be inserted into the running kernel to add support for additional devices and services.

Module Commands:-Modules are stored under the /lib/modules path in the filesystem. The next layer of the directory structure is named after the kernel number. Under that are various directories containing modules. These might include misc, fs, ipv4, cdrom, pcmcia, net, video, scsi, and block among others.

The environmental variable MODPATH can be used to override this default path. To override the paths defined in MODPATH, the /etc/modules.conf file can be used. The MODULECONF environmental variable can be used to select a different configuration file instead of the /etc/modules.conf file.

140

Page 141: HISTORY AND DEVELOPMENT OF LINUX22

There are several commands used to manage modules. These include:

The create_module command is used to create a loadable module entry. It reserves the kernel memory needed to hold the module. You must be root to do this. The delete_module command removes an unused module from memory.

Some modules require other loadable kernel modules in order to load a module. The depmod command handles dependency descriptions for loadable kernel modules.

The modinfo command displays information about a kernel module. It examines the object file module_file associated with a kernel module and displays any information it can pick up from the file.

The insmod command installs a loadable kernel module into the running kernel. It links a module into the running kernel by resolving all symbols from the kernel's exported symbol table. The default directories will be searched for the object file. This default is defined in the /etc/modules.conf file or with the MODPATH environmental variable. Similarly, the rmmod command is used to unload loadable modules from the kernel.

To list the loaded modules, use the lsmod command. It displays information about all of the loaded modules in the format of name, size, use count, and list of referring modules. This information is obtained from the /proc/modules file.

The modprobe and depmod commands are used to manage the Linux modular kernel. Modprobe uses a dependency file to load the modules specified in the file. The dependency file is created with depmod. The modules are marked with a special tag. All modules needed in a module stack are loaded as defined in the dependency file. If any file in the stack can't be loaded, all of the modules loaded in the current stack are automatically unloaded.

1. What is the difference between a monolithic kernel and a modular kernel?

Ans: A monolithic kernel is a kernel in which all of the kernel services are compiled into the kernel itself, and no external drivers are called. It must be recompiled whenever a new device is added to the system. A modular kernel is a minimal core kernel that is always present, and a set of modules that can be inserted into the running kernel to add support for additional devices and services. Support for hardware devices can be added to a system without recompiling the kernel.

CHAPTER 15 Managing Network Services

141

Page 142: HISTORY AND DEVELOPMENT OF LINUX22

Lesson 1 Identifying Networking Concepts

Lesson Objectives

In this lesson, you will:

Provide a definition of a computer network. Explain the difference between a client and a server.

Introduction:-A computer network can be defined as a collection of hardware and software connecting a group of computers so that the computer users can communicate and share resources. Shared resources might include software, such as data and applications, and hardware, such as printers or modems.

A network is essentially a communication system. All networks share the same basic components: a message; a transmitter to send the message; a receiver to receive the message; and a communication channel to carry the message. Even something as basic as the tin-can telephone shown in the figure below can be considered a network. Just as this simple telephone network helps two people communicate, computer networks enable computers (and those who use them) to communicate.

The individual computers and other devices that communicate in a computer network are called nodes or stations. Because most network nodes can both transmit and receive data, they are often called transceivers. Additionally, computers that perform services (for example, storing files or providing access to a printer) on behalf of other network devices are called servers. Computers that request services from other computers are called clients.

Why Use a Network?

There are many advantages to using computer networks. Computer networks enable users to share hardware, software, and data. Sharing expensive peripherals, such as printers and modems, can help an organization to meet the needs of many users while keeping hardware costs to a minimum. Installing an application once (in shared network storage) can be less expensive and require less storage space than installing it on individual computers.

142

Page 143: HISTORY AND DEVELOPMENT OF LINUX22

Computer networks can also reduce the time and effort necessary to transfer files from one user to another. With a single command, a user can transfer a file to another user's storage location, without having to hand-deliver the file on a floppy disk. With software designed for use on a network, users can work on the same files simultaneously.

Networks can enhance communication among network users. Electronic-mail software enables users to communicate instantly. Special network software called groupware enables users to work as a group without leaving their desks. For example, groupware users might collaborate on writing a report or editing a document. Groupware can also make it easier to schedule meetings by providing users with instant access to a common calendar, or make it easier to find fellow employees by providing an electronic in/out board.

1. List the essential components of a network.

Ans: Network components include message, transmitter, receiver, and communications channel.

2. List the basic components of each of the following networks: telephone system, television broadcast, CB radios, a business meeting.

Ans: Telephone system Message = conversation; transceivers = the phones; channel = the fiber-optic cable.�

Television broadcast Message = the program; transmitter = the transmission tower; receivers = TV sets; channel = the radio �waves in the air.

CB radios Message = the conversation; transceivers = the CB radios; channel = the radio waves in the air.�

A business meeting Message = the discussion; transceivers = the participants; channel = the sound waves in the air.�

3. List some advantages of using a network.

Ans: Answers may include: To share peripherals, to share files, and to communicate.

4. In your own work situation, how will you specifically use the network?

Ans: Answers may include: Specific examples of file sharing, peripherals sharing, and communication.

5. List some potential disadvantages of using a network. Are any of these a concern in your own work situation?

Ans: Answers may include: Security issues, network reliability, and need for cooperation among users.

Components of Networks:-Connecting two or more computers together to a network requires some specialized hardware and software components. Typical hardware components of the network include:

Two or more nodes. Nodes can be computers, such as mainframe computers, minicomputers, or personal computers; or they can be devices, such as data-entry terminals.

The communications channel. A cable or some other medium such as optical fiber, infrared light beams, or radio waves, through which network nodes can communicate.

A network interface card (NIC), which is sometimes called a network board or network adapter (see the figure below). The network board is plugged in to your computer's system unit to connect it to the network cable.

143

Page 144: HISTORY AND DEVELOPMENT OF LINUX22

A sample network interface card.

Software Components of the Network:-A network requires software in order to work. Software components include:

Operating system (OS) software for each computer node on the network. The local operating system enables the nodes to connect to the network.

Network operating system (NOS) software is used to enable network nodes to communicate. Sometimes this is built in to the local operating system; sometimes you must purchase additional, specialized software. Linux contains all of the software you need to install and run a personal computer network.

144

Page 145: HISTORY AND DEVELOPMENT OF LINUX22

Networking Strategies:-There are many different types of computer networks in use today. These different types can be characterized by the strategies they employ to interconnect computers. Some of these strategies include the way network nodes interact, the processing strategy the network employs, and the physical area the network covers.

The three main types of node-to-node interaction are hierarchical, peer-to-peer, and client-server. The node-to-node interaction strategy determines which node or nodes can have overall control of the network.

Hierarchical networks are usually found in a mainframe environment. The mainframe is a host, and terminals are attached to it. Very little, if any, processing is done by terminals. The host manages and initiates network communication and controls most of the network resources.

In peer-to-peer networks, no single computer controls network communication. Each node on the network performs similar functions.

145

Page 146: HISTORY AND DEVELOPMENT OF LINUX22

Networks in which specialized, dedicated server computers control access to network storage and other network resources are called client-server networks. In client-server networks, network users do most of their work at client stations, often called workstations, while the servers perform network-management functions such as storing shared files, providing security, and managing centralized printers. Client computers might run a different form of the network operating system than the servers do.

Different types of networks can be linked together. This is called internetworking. For example, your company might have connected the Sales Department LAN and the Accounting Department LAN to help them communicate. A network that links all of the different computers of an entire organization is called an enterprise-wide network (EWN). AN EWN may incorporate many

146

Page 147: HISTORY AND DEVELOPMENT OF LINUX22

different LANs, WANs, and MANs. Usually, the bigger the network, the longer it takes to communicate with the most distant nodes.

1. List the hardware components of a network.

Ans: Two or more nodes, the communications channel, and a NIC.

2. List the software components of a network and the role they play.

Ans: A local operating system for each node and a network operating system for the server. The local operating system is the software required for the computer to connect to the network. The network operating system software enables nodes to communicate.

1. What is a computer network?

Ans: A computer network can be defined as a collection of hardware and software connecting a group of computers so that the computer users can communicate and share resources.

2. What is the difference between a client and a server?

Ans: A computer network can be defined as a collection of hardware and software connecting a group of computers so that the computer users can communicate and share resources.

Lesson 2 Configuring Basic Network Services and Settings

Lesson Objective

In this lesson, you will:

List two utilities that can be used to configure settings for TCP/IP, DNS, and DHCP.

Introduction:-Linux systems can communicate with other systems using TCP/IP, UUCP, and serial communications. The Linux implementation of TCP/IP is called NET-4 and supports the protocols, features, and network hardware found in a typical UNIX environment.

If you aren't using DHCP to assign IP addresses automatically, you will need to configure your network manually with static settings. These settings will be given to you by the network administrator.

147

Page 148: HISTORY AND DEVELOPMENT OF LINUX22

DNS:-In the early days of the Internet, all hosts on a TCP/IP network were addressed by their IP addresses. As the number of hosts on the Internet increased, it became more difficult to address systems by their IP addresses, so the /etc/hosts file was born. The /etc/hosts file contains a mapping of IP addresses to names (and vice-versa) and was referenced by all network applications. A centralized hosts file was created and distributed on a regular basis to hosts on the network. In time, the number of hosts on the network grew to the point where maintaining the hosts file was no longer a simple task. The Domain Name Server (DNS) system was born and implemented in the Berkeley Internet Name Domain (BIND) server software. DNS allowed name resolution to be performed in a distributed, hierarchical manner in an automated fashion.

The BIND software is the most commonly used name resolution software for Linux and Unix systems. The name of the BIND daemon is named (the name daemon). In BIND, domains and sub-domains are referred to as zones. Each zone may contain any number of hosts and any number of domains.

The rc Files

Network rc files are run at bootup by init. Different Linux distributions automate running rc files in different ways. Check your documentation to find out how your system implements networking. The following table illustrates two examples.

Distribution Networking Implemented Edit Using

Red Hat Each init level that includes networking includes the necessary files. For example, /etc/r.cd/rc3.d.

Control Panel or /etc/sysconfig

SuSE All networking files are included in a single location, /sbin/init.d. /etc/rc.config

Using linuxconf to Configure Network Services:-Through linuxconf, you can configure TCP/IP, DNS, and DHCP settings. These can also be configured through netconfig.

1. What are two utilities that can be used to configure settings for TCP/IP, DNS, and DHCP?

Ans: Netconfig or linuxconf can be used to configure settings for TCP/IP, DNS, and DHCP.

Lesson 3 Managing Network Services

Lesson Objective

148

Page 149: HISTORY AND DEVELOPMENT OF LINUX22

In this lesson, you will:

Explain what ifconfig is used for.

Introduction:-Linux provides a device interface system for managing IP addresses and network parameters for one or more NICs in your system. This is accessed through ifconfig, route, and other commands.

Understanding ifconfig Output:-The ifconfig command is used to show the status of interfaces and to configure them as well.

Sample ifconfig Output.

The command without any arguments shows the status of the active interfaces. The command with a device listed as the argument shows the status of the specified device. The command with the -a option shows the status of all devices. The output of ifconfig is described in the following table.

Item Description Example

Link encap Network protocol Ethernet

HWaddr NIC hardware address 00:60:97:59:57:31

inet addr IP address associated with NIC 192.168.0.21

Bcast IP broadcast address 192.168.255.255

Mask IP Subnet Mask 255.255.0.0

MTU Maximum Transmission Unit size (bytes) 1500

Metric The interface metric 1

RX Rackets Number of packets received since the device was brought up 42504

TX Rackets Number of packets transmitted since the device was brought up 28054

Errors Number of errors in received/transmitted packets 0

149

Page 150: HISTORY AND DEVELOPMENT OF LINUX22

Dropped Number of received/transmitted packets dropped 0

Overruns Number of TCP overruns in packets received/transmitted 0

Frame Number of frame errors 0

Carrier Number of carrier errors 0

Collisions Number of packet collisions 39

Txqueuelen Length of Transmit Queue 100

Interrupt IRQ used by the adapter 17

Base Address I/O port base address used by the adapter 0 x 8200

Configuring a Network Device:-Red Hat Linux provides an interface to the ifconfig command that makes configuration of a network device very simple. This interface is made up of the ifup and ifdown commands and two or more configuration files. The configuration files are the /etc/sysconfig/network file, which specifies the network configuration, and one or more files in the /etc/sysconfig/network-scripts, which specifies device-specific networking information. For a system with a single Ethernet card, the device-specific information is stored in the /etc/sysconfig/network-scripts/ifcfg-eth0 file.

The ifup and ifdown commands are used to start and stop specific network devices, respectively. The syntax of these commands is command devicename, where command is either ifup or ifdown and devicename is the name of the device (for example- eth0, eth1, etc.).

Because the ifup and ifdown commands control only a single network device, it is often easier to use the /etc/rc.d/init.d/network command with the start or stop parameters. This command starts (or stops) all of the network devices simultaneously.

Network configuration files

In the configuration shown in the figure above, device eth0 is named court.intranet.logicept.com and the device is set to boot via DHCP (Dynamic Host Configuration Protocol). The ifconfig command is used to configure Ethernet interfaces as well as to view status information. To specify the network address of a specific card, enter ifconfig interface_name address. Other options you can configure are listed in the following animated tip.

150

Page 151: HISTORY AND DEVELOPMENT OF LINUX22

You can also manually change the settings by editing the ifcfg-device file. If you do this, then you need to restart the network service (/etc/rc.d/init.d/network restart). You should then issue an ifconfig command to verify that your changes took effect.

1. What is ifconfig used for?

Ans: The ifconfig command is used to show the status of interfaces and to configure them.

Lesson 4 Managing Remote Network Services

Lesson Objectives

In this lesson, you will:

List three commands that can be used to manage remote network services. Explain what the ping command does.

Introduction:-There are many utilities available for managing and troubleshooting TCP/IP networks. Most of these are included with the TCP/IP protocol stack and are public domain applications. The utilities you will be looking at are:

151

Page 152: HISTORY AND DEVELOPMENT OF LINUX22

The traceroute Utility:-You can use traceroute to see what route data uses to get to its destination. Tracking the route data uses to get there can be difficult. Utilizing the Time-to-live field of the IP protocol, traceroute attempts to obtain an ICMP Time_Exceeded response from each gateway encountered on the path between you and your final destination.

UDP probe packets are sent with a short time-to-live. The traceroute utility then listens for an ICMP time exceeded reply from a gateway. This continues until you can get an ICMP port unreachable response, which either means that you got to the host or reached the default maximum number of hops (30). The address of each system that responds (each gateway you pass through) is printed to your screen; if no response is received within five seconds, an asterisk is printed for that probe.

For a list of the options available for the traceroute command, see the man page. The only required argument is the host you are attempting to reach. This can be the host name or IP address.

A sample of traceroute results.

The netstat Utility:-The netstat command displays statistics about the network including socket status, interfaces that have been auto-configured, memory statistics, and routing tables. The first argument controls the type of information displayed.

The netstat command is most often used to monitor your routing tables. To do so, enter netstat -r. It can also be used to display information about your interfaces (such as eth0 and lo) using the netstat -i option. To check masquerade connections, use netstat -M.

With no arguments, the default, netstat displays the open sockets. The following animated tip describes some of the other options available. For a complete list, check the netstat man page.

152

Page 153: HISTORY AND DEVELOPMENT OF LINUX22

The routing table displayed using netstat -r.

The ping Utility:-You can use the ping command to verify that a computer can be reached on the network. It checks the host name, IP address, and that the remote system can be reached.

Ping uses the ICMP ECHO_REQUEST datagram to check connections between hosts by sending echo packets, then listens for reply packets. To see the complete set of options available with ping, check the man pages. Some of the options include setting the packet size (-s), changing the Time-To-Live option (-t), and specifying how many times to ping the host (-c).

153

Page 154: HISTORY AND DEVELOPMENT OF LINUX22

The results of the ping command

1. What are three commands that can be used to manage remote network services?

Ans: netstat, traceroute, and ping.

2. What does the ping command do?

Ans: The ping command verifies that a computer can be reached on the network. It checks the host name, IP address, and that the remote system can be reached.

CHAPTER 16 Working with Hardware

Lesson 1ROM BIOS

Lesson Objectives

In this lesson, you will:

Describe the difference between the BIOS and CMOS. Explain what POST does.

Introduction:-BIOS stands for Basic Input/Output System, although the full term is used infrequently. The system BIOS is the lowest-level software in the computer; it acts as an interface between the hardware (chip set and processor) and the operating system (DOS, Windows 95, and so on).

Although most people don't realize it, there are in fact several different BIOSs in your PC. When people say "the BIOS," they are generally referring to the main system BIOS. However, there are also BIOSs to control PC peripherals. Typically, the PC's video card has its own BIOS that contains hardware-driving instructions for displaying video information. SCSI host adapters, hard drives, and other peripherals can also contain their own BIOS instructions.

The Boot Process

One of the most important functions of the BIOS is booting up the system. When the PC is first turned on, its main system memory is empty, and it needs to find instructions to tell it what to do. These instructions are found within the BIOS program.

154

Page 155: HISTORY AND DEVELOPMENT OF LINUX22

When your PC is powered on, the BIOS is loaded into memory. The BIOS then performs a subroutine typically known as POST (Power-On Self Test). If there are any fatal errors, the boot process stops. POST beep codes indicate the area of the boot problem. The BIOS, and often the POST, performs a system inventory to determine what sort of hardware is in the system. Each time the system is booted, the components are checked in the order found in the Knowledge Builder above.

In newer PCs, the main BIOS looks for the video card BIOS and then other peripheral BIOSs and runs them. If the BIOS supports the Plug and Play standard, it will detect and configure Plug and Play devices at this time and display a message on the screen for each one it finds.

Power-On Self Test:-As mentioned, the Power-On Self Test (POST) routinely checks your system for hardware errors, including configuration errors. The POST routine might detect interrupt, I/O address, or Base Memory address conflicts. If so, either an error code number or a series of beeps will tell you which error is present.

Normally, pressing F1 will enable you to acknowledge the error and continue booting. This might not be possible with the more serious error conditions. The following table lists common audio and video POST error codes and their meanings.

Audio Error Code

Video Output Problem Solution

One or more short beeps

DOS prompt None (normal startup beep) None

None None Power Check power cords, wall voltage, PC's power supply.

None Cursor Power Check the PC's power supply; check for sufficient wall voltage.

None DOS prompt None May be a defective speaker.

One short, one long beep

None Display Check for monitor power; check video cable; check display adapter.

Two short beeps

None or incorrect display (garbage)

Display Check for monitor power; check video cable; check display adapter.

Two short beeps

Error code number

See the "POST Error Codes" table for a list of error codes and their interpretations.

 

Repeating short beeps

Probably none Power Check the PC's power supply; check for sufficient wall voltage.

Continuous tone

Probably none Power Check the PC's power supply; check for sufficient wall voltage.

One long, one short beep

Probably none System board Check to see that all adapters, memory, and chips are seated firmly; check for proper power connections to the system board; use diagnostics software or hardware to further troubleshoot the system board.

One long, two short beeps

Probably none Display Check for monitor power; check video cable; check display adapter.

One long, three short beeps

Probably none Display Check for monitor power; check video cable; check display adapter.

155

Page 156: HISTORY AND DEVELOPMENT OF LINUX22

The following table lists the error-code numbers and their meanings.

POST Error Code Problem

02# Power

01## System board

0104 Interrupt controller

0106 System board

0151 Real-time clock or CMOS RAM

0162 CMOS checksum error

0163 Time and date (clock not updating)

164 or 0164 System memory configuration incorrect

199 or 0199 User-indicated device list incorrect

02## Memory

201 or 0201 Memory error (may give memory address)

0202 Memory address error

03## Keyboard

0301 Stuck key (scan code of the key may be indicated)

0302 Keyboard locked

06## Floppy-disk driver or controller

0601 Floppy-disk adapter failure

0602 Disk failure

17## Hard disk or adapter

1701 Drive not ready or fails tests

1704 Hard-drive controller failure

1707 Track 0 failure

1714 Drive not ready

1730-1732 Drive adapter failure

CMOS:-CMOS is a memory area with battery backup used to store system configuration settings. Prior to the use of CMOS, settings were configured with jumpers and switches. CMOS was introduced with the AT system boards. It allows for more configuration options than the switches and jumpers did. Also, you can configure CMOS without needing to open the cover; you configure things from the keyboard.

Some of the things you can configure through CMOS are:

156

Page 157: HISTORY AND DEVELOPMENT OF LINUX22

You can change the CMOS settings by accessing the menu and making the appropriate changes at the keyboard. If you can't access CMOS for whatever reason, you can remove the CMOS battery and it will lose all of its settings and return to factory defaults. You can then configure as appropriate.

CMOS will display error messages through the POST.

The messages Bad or missing command interpreter and Non-system disk or disk error are generated when the system can't access the operating system.

The error Display Type Mismatch is displayed if the video settings don't match the monitor attached to the system.

The error Memory Size Mismatch is displayed if the amount of RAM detected and the amount specified in CMOS don't match. This error is usually self-correcting, although you might need to reboot to fix it. Other devices such as hard drives can also generate mismatch errors. This generally happens when the physical device is different than what is specified in CMOS.

The error CMOS Checksum Failure is generated if the CMOS memory is corrupted. This can happen from a bad or dead battery, or a loose connection to the battery. Try replacing the battery and see if it clears up the problem. If it doesn't, the system board might be bad (or getting bad).

1. Indicate the order in which the following components are checked during a POST:

Video card, BIOS ROM, RAM, Floppy drives, System timing, Ports, Processor, Interrupt controller, Keyboard, DMA controller, BASIC ROMs, Expansion board initialization

Ans: Processor, BIOS ROM, DMA controller, Interrupt controller, System timing, BASIC ROMs, Video card, Expansion board initialization, RAM, Keyboard, Floppy drives, Ports.

Configuring the ROM BIOS:-In the ROM BIOS, you configure the basic settings for your hardware. For example, if you add a second hard drive, you need to tell the BIOS about the new hardware you just added. You can also set the date and time and specify a password for booting the system. The ROM BIOS also lets you configure ports and reserve system resources for specific cards. Lastly, you can use the BIOS to establish the boot order for devices. For example, you can configure the ROM

157

Page 158: HISTORY AND DEVELOPMENT OF LINUX22

BIOS to boot from a different hard drive controller or from a CD-ROM. Lastly, most modern BIOSs let you configure power management on your system.

System board manufacturers periodically release BIOS upgrades. In the past, the most common way to upgrade your BIOS was to install a new BIOS chip on your system board. Today, most BIOSs can be flashed; that is, you can reprogram the BIOS with the latest version provided by the manufacturer. In most cases, you can download BIOS upgrades from the system board manufacturer's support site on the Internet

1. What is the difference between the BIOS and CMOS?

Ans: The BIOS is software built into a ROM chip that allows configuration of hardware devices. The CMOS is a special type of memory that stores the configuration settings made in the ROM BIOS.

2. What does POST do?

Ans: The Power-On Self Test (POST) routinely checks the system for hardware errors, including configuration errors. The POST routine might detect interrupt, I/O address, or Base Memory address conflicts.

Lesson 2 Installing and Configuring Add-In Hardware

Lesson Objectives

In this lesson, you will:

List some issues to be aware of when purchasing new hardware for a Linux system. Define Kudzu.

Introduction:-After you have been using your Linux system for a while, you might find that you want to add some hardware to it. These might be internal or external components. Some internal components might include hard drives, network cards, modems, video cards, and so forth. Some external components you might add are printers, scanners, USB devices, and external modems, among others.

The first thing you should do before purchasing any component is to check whether it is on the hardware compatibility list for Linux. This can be found at the Linux Documentation Project Web site. Another useful site for a quick overview of hardware issues is The Cheap /Linux/ Box at http://ls.net/CheapBox.html. Now, let's take a quick look at some of the issues surrounding hardware for Linux systems.

Modems

Many of the modems you'll find today are controllerless modems. You should avoid controllerless modems and software modems. These are also known as winmodems. The V.90/K56Flex modems suit the needs of most Linux users. Any modem with the standard serial interface, RS-232, is a controller-based (hardware) modem, which will work with any operating system. External 56K modems are often less expensive than controller-based internal 56K PCI modems. Another reason to consider an external modem is that there are fewer and fewer ISA slots on the motherboards, and newer boards often do not have ISA slots at all. Currently USB modems are winmodems, so these won't work well for Linux. Some internal PCI modems work under Linux.

Some things that would indicate that the modem would be a good choice for use on a Linux system include that it is a controller-based ISA modem, DOS-compatible, Windows 3.1-compatible, with jumpers. Some things that would indicate that the modem would not be a good choice for use on a Linux system include that it says it is a HCF, HSP, PCI, or USB modem.

Many problems with modems are caused by incorrect initialization strings. You should find a list of AT commands for your modem from the manufacturer's Web site (usually in the support section). Or simply try AT&F, which restores factory settings that are reasonable. There is a Modem-HOWTO and Linmodem-HOWTO.

Configuring the Client Workstation for Remote Access

158

Page 159: HISTORY AND DEVELOPMENT OF LINUX22

If you have a modem installed, you can use the Red Hat PPP Dialer utility, rp3, to configure PPP. This is the tool for configuring dial-up Internet connections that use the Point-to-Point Protocol (PPP).

If you use ISDN, it is configured using the isdn-config tool. If you must use older protocols such as SLIP or CSLIP for dialup protocols, use the netcfg tool to configure these protocols.

Printers

Again, there are a lot of printers on the market that were created specifically for the Windows market. These don't have PostScript support. The Printer Compatibility Database at www.linuxprinting.org/database.html is a good resource for finding a Linux-compatible printer for your system.

PostScript printers work well for Linux. The UNIX world uses PostScript, so it works here as well. Some non-PostScript printers can emulate PostScript through the GhostScript utility included with Linux. However, the print speed will be quite slow for non-PostScript printers using GhostScript.

Other Hardware

Rather than trying to rewrite what has already been documented, we'll give you a list of the HOWTOs that relate specifically to hardware components. The most up-to-date version of these documents can be found at the Linux Documentation Project Web site.

HOWTO For URL

Cable Modem www.linuxdoc.org/HOWTO/Cable-Modem/index.html

CD-ROM www.linuxdoc.org/HOWTO/CDROM-HOWTO/index.html

Ethernet www.linuxdoc.org/HOWTO/Ethernet-HOWTO.html

Hardware Compatibility www.linuxdoc.org/HOWTO/Hardware-HOWTO/index.html

Modem www.linuxdoc.org/HOWTO/Modem-HOWTO.html

Optical Disk www.linuxdoc.org/HOWTO/Optical-Disk-HOWTO.html

PCI www.linuxdoc.org/HOWTO/PCI-HOWTO.html

Plug-and-Play www.linuxdoc.org/HOWTO/Plug-and-Play-HOWTO.html

SCSI www.linuxdoc.org/HOWTO/SCSI-2.4-HOWTO/index.html

Sound cards www.linuxdoc.org/HOWTO/Sound-HOWTO/index.html

UPS www.linuxdoc.org/HOWTO/UPS-HOWTO.html

Winmodems www.linuxdoc.org/HOWTO/Winmodems-and-Linux-HOWTO.html

ZIP Drive www.linuxdoc.org/HOWTO/mini/ZIP-Drive.html

Other Hardware Issues

No matter which operating system you are using, you still have the issue of IRQ, DMA, and I/O address conflicts. Be sure that each device has its own IRQ. This can be set using jumpers or software. If the kernel is configured with multiple devices for the same IRQ, then install with only one of those devices installed or enabled, and then recompile the kernel to specify a different IRQ for each of the other devices.

159

Page 160: HISTORY AND DEVELOPMENT OF LINUX22

DMA and I/O address and shared memory address conflicts are another issue. Check the documentation to see what the device should be set to. You can't always change this, so in that case you're out of luck. If possible, though, change the settings so each device is different. The following animated tip lists some common devices and their default IRQ and I/O addresses.

Removing and Installing Cards

To remove a card, disconnect all cables, making a note of where they were installed and the orientation (such as white wire on left pin), and unscrew the card from the case. Gently rock the card front to back (not side-to-side) to remove it from the slot, and then place it in an anti-static bag to prevent electrostatic damage to the card.

To install a card, locate a slot matching the card connector. For example, an ISA card needs to be installed in an ISA slot. Press the card down firmly into the slot. Finally, reconnect any cables, and then screw it to the case.

Configuring New Hardware

Red Hat Linux includes Kudzu, a tool that automatically detects any hardware changes on your system upon rebooting. You can also run kudzu from the command line without rebooting. A dialog box is displayed that identifies your hardware change. Kudzu then prompts you to configure the hardware at that time. It is a hardware probing tool run that determines what hardware has been added or removed from the system.

You might find the following resources helpful when installing and configuring hardware.

Configuring hardware through the control panel can be found at www.redhat.com/support/manuals/RHL-7-Manual/ref-guide/s1-sysconfig-control-panel.html.

Configuring hardware through linuxconf can be found at www.redhat.com/support/manuals/RHL-7-Manual/ref-guide/ch-sysconfig.html.

ISA Plug-and-play cards can be difficult to get working in a Linux system. For tips on how to get them to work, check out www.roestock.demon.co.uk/isapnptools/.

160

Page 161: HISTORY AND DEVELOPMENT OF LINUX22

Follow the steps below to learn how to add and configure new hardware.

Identify whether the hardware you are adding is internal or external. You might be adding an external component such as a printer or external modem, or you might be adding an internal component such as a network card, internal modem, or other card.

Properly shut down your system, then unplug it and remove the external cables and power cords. Be sure you know where each cable was plugged in so you can put it back in the proper location when you are finished.

If adding an internal component, remove the computer case. Each case is fastened on in its own way. Some have levers to flip so you can slide the case off; others have screws in various locations you need to unscrew before removing the cover.

If adding an internal component, locate the slot in which the component fits. The edge connectors on cards must match the slot in the computer. For example, PCI cards will not fit in an ISA slot or vice versa. If adding a drive, locate an available bay and power and data connectors for the drive.

Add the component to your system. If installing an internal component, be sure to secure the card to the chassis with the mounting screw. Press down firmly, but do not rock the card side-to-side as this can damage the card. If you drop the screw down inside the system, use a non-magnetic tool to retrieve the screw.

Reconnect the cables and power cord. You might want to leave the cover off until you are sure the card is working.

Restart your system and observe as Kudzu detects the hardware change.

Answer the questions as you are prompted.

1. What is something to be aware of when purchasing new hardware for a Linux system?

Ans: Whether the new hardware is compatible with the Linux operating system.

2. What is Kudzu?

Ans: Kudzu is a Red Hat utility that automatically detects hardware changes on the system.

Lesson 3 Removing and Replacing Hardware

Lesson Objective

In this lesson, you will:

Explain why the system should be updated after removing hardware and before installing a new component.

Introduction:-Today's ever evolving hardware technology seems to require upgrades on a regular basis. You can live with the equipment from two years ago, but it might be painful. For example, your monitor might be small or fuzzy, you might have filled all of your hard drives, your tape drive might have failed, or you just might have to have a newer scanner now that the prices have dropped. You also might have installed a component, but now find that you don't need it any longer (and could really use the cash you get for selling it to someone else). You should remove the existing hardware and update the configuration before attempting to install the new hardware.

Reconfiguring the System After Hardware Removal

Just as you had to update your system to support the hardware when you added it, you need to update your system to let it know that the hardware has been removed. You use the same tools as you did when you installed the hardware. In some cases, it wouldn't really matter if you left the support there, but you would be wasting system resources. In other cases, you'll get error

161

Page 162: HISTORY AND DEVELOPMENT OF LINUX22

messages when it can't find the component or you'll get conflicts if you replace it with another device that uses the same resources but different drivers.

Follow the steps below to learn how to remove hardware and reconfigure the system after hardware removal.

Properly shut down your system, and then unplug it and remove the external cables and power cords. If removing an internal component, remove the computer case.

Remove the component from your system.

Reconnect the cables and power cord.

Restart your system.

When Kudzu prompts you as to the change you made, answer accordingly. Kudzu walks you through the process of updating your system. Any configuration changes that need to be made are done through this process.

1. Why should the system be updated after removing hardware and before installing a new component?

Ans: In case there is a resource conflict.

Lesson 4 Installing and Configuring Hard Drives

Lesson Objectives

In this lesson, you will:

Define a form factor. Contrast ATA and SCSI hard drives.

Hard Disks:-Hard drives, or fixed disks, are types of storage devices that provide fast access to large amounts of storage in a small, reasonably reliable physical package. Without them, most modern computing applications would be impossible.

Hard disks are often composed of multiple disks. A cylinder consists of a track on the top side of the top-most disk, and all of the tracks beneath it, as shown in the figure below. A cylinder represents all of the data that the read/write heads can access when they are in a certain position. (There is a separate read/write head for each side of each disk, but they all move together.)

162

Page 163: HISTORY AND DEVELOPMENT OF LINUX22

Hard drives have been designed to meet users' needs for speed and capacity. With the maturation of the technology, designers now add reliability to and reduce the cost of the design process. This constant redesign process has produced better drives, in many different types. However, even with differences, almost all hard drives operate the same way: data is stored as locations of magnetic flux, or change, on a disk of specially coated aluminum or glass. Hard disks can have one or more of these platters or disks. The information is read or written with a head, or small magnet, that floats on a cushion of air over the platter. The platter spins at a high rate, generally 5,400 or 7,200 revolutions per minute (rpm). The heads are moved across the platter by one of two technologies: older designs used a motor, called a stepper motor, that moved only in pre-defined increments, or steps. Newer designs use a voice-coil, similar to an audio speaker, to move the heads more precisely over the platter.

Writing Data to the Hard Disk:-Hard disks spin at very fast speeds, and the read/write heads hover over the platters, very close to the surface so that they can read or write data. The platters are made of a rigid material, such as aluminum, that is coated with a magnetic material. To write data, the computer positions the head in a particular track. When the appropriate sector passes by, pulses of electricity are sent through a coil of wire in the head. This creates an electromagnetic field, which aligns magnetic particles on the disk surface. By alternating the flow of the current to the head, ones and zeroes can be encoded magnetically.

The data is encoded, or written, in circular tracks as the head floats over the rotating platter. Each platter has its own read/write head. The newer voice-coil designs allow cylinders to be written closer together so more data can be fit onto the same-sized platter.

163

Page 164: HISTORY AND DEVELOPMENT OF LINUX22

Newer coatings, developed in recent years, as well as smoother platter surfaces, have enabled more data to be stored on a hard drive. A few years ago, drives with a couple of hundred megabytes were considered large. Now, disks capable of storing multiple gigabytes are commonly available.

Reading Data from the Hard Disk

To read data, the computer positions the head over the appropriate track. When the sector passes by, the magnetic particles on the disk create an electrical current in the head through a phenomenon known as inductance. In the head, the alternating patterns of magnetism on the disk translate into alternating flows of electrical current, which can be translated into ones and zeroes.

Avoiding Head Crash

You should never transport or jar a hard disk that is spinning, because you can easily cause a head crash. If the read/write heads bang against the surface of the disk, you might damage that part of the disk, and possibly the read/write heads as well. Most hard-disk drives automatically park over an unused section of the disk when the computer is switched off.

Hard-disk drives are tightly sealed to prevent dust and other particles from entering the drive. A single dust particle is likely to be larger than the gap between the head and the disk platter. With the platter spinning, dust acts like sandpaper on the surface of the disk. For this reason, you should never break the seal on a hard-disk drive.

Physical Characteristics

Physically, hard drives come in a number of designs. The terms form factor and height are used to describe the physical characteristics of hard drives that are mounted internally. External drives are most often simply internal drives mounted in a case that also has a power supply.

Form factor. The form factor of a drive refers to its width. This measurement is derived from the original IBM PC/XT case that had drive openings of 5.25 inches. Most drives today are actually smaller than their rated form factor and use spacers, or mounting brackets, to fit within the case. The 5.25-inch and 3.5-inch form factors are the most popular for desktop and deskside computer systems. Newer form factors, designed for use in laptops and notebooks, include 2.5-inch and even 1-inch designs.

Height. Again, the height of the drive is a measurement derived from the original IBM PC/XT case. A device that would fill the height of the drive bay of the XT is considered to be a full-height device. Other heights include half-height and the newer 1-inch high drives.

You must match the form factor and height of a drive you purchase with the available openings in your computer.

164

Page 165: HISTORY AND DEVELOPMENT OF LINUX22

Installing Hard Drives:-The specific steps for setting up a hard disk in a system depend on the system and the type of hard disk you are installing; however, the main tasks are:

1. Physically install the hard disk into the computer. 2. Prepare the new hard disk for use in the system.

Configuring Hard Drives:-You should configure the hard drive before you install it in the case. The drives are configured with jumpers. There is often a label on the drive with the jumper settings.

The first drive is referred to as the master drive. The second drive is referred to as the slave. If you have two ATA devices on the same cable, one needs to be set to master and the other to slave. This allows both devices to properly communicate on a single channel. It also specifies the boot order of the drives. The master drive on the first ATA channel is the first ATA drive accessed when the system boots.

You will need to change the jumper settings to reflect their role (master or slave). Also, some drives have separate settings if there will be only one drive in the system. This is usually referred to as single drive or cable select if there is only one drive on the ATA channel.

If possible, place hard drives on a different channel than CD drives. This requires two ATA controllers. One or two hard drives should go on ATA 1, as master and slave, or single. If you have an ATA CD-ROM and a second CD drive (such as a rewriter, DVD, or just another CD-ROM), they should go on ATA 2 as master and slave.

Working with Hard Drives

Keep the following in mind when you are working with hard drives:

Because of the delicate nature of hard disks, you need to be very careful when you are handling them. Do not bump or shake them unnecessarily, and do not transport them unless they are encased in protective packaging.

When performance is a less-critical issue than cost, consider adding another hard disk to an existing controller board, rather than replacing the controller, disk, or computer

Follow the steps below to view fixed disk drive settings.

Restart your computer and enter the BIOS setup utility. Locate the settings for the hard drive. These might be on a different screen than the one that first

appears.

Select Primary Master and press the Enter key if you want to examine or change settings for the first or master drive. The second drive is usually referred to as the slave or secondary drive.

Different BIOSs have different settings. Some of the typical settings you'll find include:

o Cylinders

o Heads

o Sectors

o CHS Capacity

o Maximum LBA Capacity

o PIO Mode

o Ultra DMA Mode

165

Page 166: HISTORY AND DEVELOPMENT OF LINUX22

At this point, you could exit BIOS without saving changes or make any necessary changes and then save changes as you exit BIOS setup.

1. Compare master and slave settings.

Ans: The first ATA device on a single ATA channel is the master drive. The second ATA device on a single ATA channel is the slave drive.

2. You have two ATA hard drives and an ATA CD-ROM drive. How should you configure your system to support these three devices?

Ans: Place hard drives on a different channel than CD drives. This requires two ATA controllers. The hard drives should go on ATA 1 as master and slave and the CD-ROM drive should go on ATA 2 as master.

3. Where can you view hard drive settings?

Ans: Through the BIOS setup utility.

4. What are some typical hard drive settings?

Ans: Cylinders, heads, sectors, CHS capacity, maximum LBA capacity, PIO mode, and Ultra DMA mode.

ATA Drives:-ATA, or AT Attachment, drives connect to the computer through the ATA drive interface, which might be on a separate card, on the sound card, or more likely, built into the system board. Technically, there are different varieties of ATA interfaces. The acronym IDE is most often associated with the implementation designed to work with the ISA/AT bus. This type of interface is sometimes called the IDE or EIDE interface. Other ATA/IDE interfaces exist for the 8-bit XT bus, the Micro Channel bus, and others.

Disk drives are attached to the ATA interface with a single cable, plus a power connection. Drives are daisy-chained when a second drive exists on the ATA channel.

SCSI interfaces and drives are still faster than ATA. This is due mainly to SCSI use of faster mechanical and electrical components.

BIOS

166

Page 167: HISTORY AND DEVELOPMENT OF LINUX22

Most BIOS today can auto-detect the hard drive. It uses the DriveID command to configure the hard drive in BIOS. For ATA hard drives, you will probably then be prompted to choose between LBA (the default for large drives), Normal (for operating systems that don't use the BIOS), or Large (for drives that support ECHS).

Next, you need to set or verify the drive type. This is most often set to User. The heads and sectors should have been auto-detected, so leave them alone. The PIO Mode should have been set to 3. Finally, disable block mode (so you don't waste disk space).

Installing ATA Hard Drives

When you install a hard drive, you should place the drive in an available bay in your system. High-speed drives generate a lot of heat, so if possible, keep them away from other components. Since power supplies have magnetic fields around them, keep drives away from there. The best place for a drive is near the front of the machine, away from other components.

The installation of specific disks varies with the type of disk and system. For most ATA hard disks, you need to complete five basic steps:

Follow the steps below to learn how to install ATA hard disks:

If ATA support is not embedded on the system board, configure and install an ATA controller (expansion) board.

Configure and install the hard disk.

Attach cables to the installed disk.

Set the CMOS disk type.

When needed, complete the controller board and disk configuration.

More specifically, you will need to:

Locate an available bay. You might need to install drive rails or a mounting bracket if the bay is a larger size than the drive.

Slide the drive onto the rails or into the bracket. The connectors need to be facing the rear of the system. When it is in, screw it in to hold it to the rails or bracket.

Attach the ribbon cable with the red stripe on Pin 1 (the pin closest to the power connector).

If you are adding a second drive, use a connector on the ribbon cable that is still open. There are usually two connectors per cable, with one being at the end and one in the middle.

Plug the keyed, 4-wire power connector from the power supply into the drive.

If you install the ribbon cable backward, errors will occur and the drive won't work. It might seem like the drive is dead.

Configuring and Installing the ATA Controller Board:-The ATA controller resides on the actual ATA disk. If ATA support is not embedded on the system board, you need to configure an ATA controller board by identifying and setting IRQs and addresses as you would for any other expansion board. Likewise, these settings can be made by jumpers, switches, or software configuration utilities, or any combination, and some computers can auto-configure the board. The following animated tip describes some of the board settings that you might need to configure via jumpers.

167

Page 168: HISTORY AND DEVELOPMENT OF LINUX22

When you physically install the controller board into the system, make sure that it is completely seated in the expansion slot. Otherwise it won't work, and can potentially be damaged.

Configuring and Installing the ATA Drive:-To configure the ATA disk, you need to specify the disk mode as single drive only, master, or slave. (Some controller boards will auto-configure the ATA bus.)

When you are installing only one ATA disk, configure the disk as single drive only. When you are installing two ATA disks, configure the boot disk as master.

When you are installing two ATA disks, configure the non-boot disk as slave.

When the hard disk is configured, physically install it into the computer.

TIP: Some drives treat single and master the same, and only have a choice between master and slave. If it is the only drive in the system, you would choose master in this situation.

Attaching Cables to the Installed Drive:_Connect the power cable and the cable that connects the controller board hard disk. Make sure that you use a 40-pin cable, and verify that the cable is less than 0.5 meters long. Do not use floppy-disk drive cables for hard-disk connections, and do not reverse cables-always use the Pin 1 designations on the cable, controller, and disk, to properly orient the cable.

Setting the CMOS Drive Type:-Most systems automatically recognize and configure a new hard disk and save those settings in the CMOS. Disk types are numbered according to the characteristics of the hard disk, such as number of cylinders and heads, capacity (in MB), and sectors per track. Check the hardware documentation for the ATA disk for these values so that you can determine which disk type to assign to the new hard disk.

For some disks, you also need to determine write pre-compensation, which deals with the timing problems associated with the disparity of track sizes. (Cylinders near the center of the disk have shorter tracks than those near the edge of the disk.) Newer disks do not usually need to have write pre-compensation defined; when you do need to determine this value, divide the maximum number of cylinders by two.

Setting the CMOS disk type is usually accomplished by one of the following methods:

168

Page 169: HISTORY AND DEVELOPMENT OF LINUX22

Completing the Configuration:-Some ATA hard disks and controllers cannot be configured until after they have been installed into the computer. For these systems, run any software configuration programs necessary to complete the configuration process. Settings that might be software-configurable include board-configuration parameters, such as IRQ, DMA, Base Memory, or Base I/O address, and BIOS configuration parameters for the disk itself.

Follow the steps below to learn how to replace an ATA hard disk drive.

Disconnect the power connector from the rear of the drive. This connection is usually very tight, so you might need to pull hard, being sure to pull straight.

Observe the data cable connected to the drive. The red stripe on the cable is on Pin 1 of the drive. This is usually located on the side closest to the power connection on the drive. If you put the cable in backwards, it will usually fit, but the drive won't work.

Disconnect the controller cable from the rear of the drive.

Remove the screws that mount the drive in the chassis bay. These are sometimes located in awkward places, and you might need to remove other components to get to them.

Slide the drive out of its bay.

Examine the controller cable connectors and the jumper block for master/slave configuration on the rear of the drive. Verify that the drive is set as master or single (if there is a second drive connected to the same channel it should be set to slave, and the first drive to master).

You are now ready to install the replacement ATA drive in your computer. Insert the ATA drive into its bay.

Mount the drive to the chassis using the appropriate screws.

Connect the controller cable to the rear of the drive. Make sure the colored stripe on the controller cable lines up with Pin 1 on the drive.

Connect the power connector to the rear of the drive.

Plug in the external cables, and then boot the system to verify that the drive was correctly installed. If necessary, troubleshoot the problem.

169

Page 170: HISTORY AND DEVELOPMENT OF LINUX22

Troubleshooting ATA Hard Drives:-If you remove the second ATA hard disk from a computer with two ATA drives installed, verify that the disk that remains in the computer is set as single. The Master/Slave setting should be used only when there is more than one hard disk in a system; otherwise, a disk-controller error will occur when you restart the computer.

If you need to move an ATA drive from one computer to another, you likely won't run into problems. However, especially if there is a great difference in age between the computers, you might run into problems. The BIOS of another computer might not support LBA or Large (ECHS), or might not be set up for it. In that case, data on the hard drive would be lost if you install it in that system. You can change the mode for a hard drive (from LBA to Large, or vice versa), but this poses a risk of data loss. Typically, you should set the mode only when you first install the disk. If you do need to change it, make sure you have a working backup of all of the data on the disk before doing so.

TIP: If you move a drive from slave to master, the slave drive won�t be bootable (in most cases anyway), and you�ll need to install the operating system and make it bootable. If you need to do this, you should make and verify a backup (or two) before doing this.

1. How do ATA drives connect to the computer?

Ans: The ATA drives connect to the computer through the ATA drive interface, which might be on a separate card, on the sound card, or more likely, built into the system board.

2. What is the typical BIOS setting for drive type on an ATA hard drive?

Ans: User.

3. List the basic steps to install an ATA hard drive.

Ans: If necessary, configure and install an ATA board. Configure and install the hard drive. Attach cables to the installed drive. Set the CMOS disk type. When needed, complete the controller board and disk configuration.

4. Can you plug an ATA data cable in backwards? What happens? How can you properly orient the data cable?

Ans: Yes, you can, but the drive won't work. If it is the boot drive, you'll get dire-sounding messages about your system, and it won't boot. To fix the problem, turn the cable around. You can tell the proper orientation by lining up the stripe on the cable with Pin 1 on the drive. Pin 1 is most often located on the side closest to the power connection on the drive.

5. Where is the ATA controller located?

Ans: On the ATA drive itself.

6. What are the three disk modes and when do you use them?

Ans: Single: if there is only one drive connected to the ATA interface card. Master: if there are two drives connected to the ATA interface card, and this is the first drive (the boot drive), or if there is no Single setting. Slave: if it is the second drive connected to the ATA interface card.

7. You have two drives in your system. The first drive fails, and you have enough room on the second drive to meet your needs. What do you need to do?

Ans: Remove the first drive from the system. Change the disk mode on the second drive from slave to master. Install the operating system.

Installing SCSI Disk Drives:-The setup and installation of SCSI disks varies for the type of SCSI disk involved, so you should check with the manufacturer for specific setup instructions before you attempt to install a SCSI disk. The following is a general procedure for physically installing a SCSI hard disk:

170

Page 171: HISTORY AND DEVELOPMENT OF LINUX22

Plan the SCSI bus. If the system board does not have embedded SCSI support, configure and install the host bus adapter

(HBA).

Configure and install the hard disk.

Attach cables to the installed disk.

Set the CMOS type to 0, Not Installed, or SCSI.

When needed, complete the disk's configuration and termination.

A SCSI chain.

Planning the SCSI Bus:-Creating and following a comprehensive installation plan is more likely to enable you to install the disk without encountering problems. Plans should include how to handle termination, SCSI addressing, and cabling.

Termination. Proper termination is essential for the SCSI system to work correctly. Some disks and controllers provide active termination, which is a feature that provides termination when it is required, so no physical intervention is needed when you add devices to or remove devices from the bus. Internal, external, and mixed SCSI disk configurations are all terminated differently, as described in the following table.

Configuration Description

Internal (multiple disks inside the PC)

Termination should be on the HBA and on the last disk in the SCSI chain.

External (multiple disks in a separate cabinet)

Termination should be on the HBA and on the external cabinet itself, instead of the last disk. This enables you to chain more disks without reconfiguring the termination scheme.

Mixed (multiple disks in the PC and in an external cabinet)

Termination should be on the last internal disk and on the external cabinet. No termination is needed on the HBA because you are using both ports (internal and external).

Also, make sure that the terminating power, which ensures stable current for the data signals on the bus, is set up correctly for the specific hardware setup, by following the vendor's recommendations.

171

Page 172: HISTORY AND DEVELOPMENT OF LINUX22

Addressing. Make sure that all SCSI IDs are set correctly by using jumpers or software configuration utilities. Usually, the HBA uses the ID 7; remaining devices use 0 through 6, where 0 is the lowest priority device (such as the primary or first hard disk) and 6 is the highest priority device (such as a CD-ROM or tape drive). This keeps the faster devices from dominating control of the bus.

Cabling. Make sure that you have the right type and number of cables for the installation. Verify that the connectors are correct for each component. Do not use floppy-disk drive cables for hard-disk connections, and do not reverse cables-always use the Pin 1 designations on the cable, controller, and disk to properly orient the cable. For external devices, use impedance-matched cables to minimize potential problems. Do not use HVD devices on single-ended chains.

You should sketch the layout of the SCSI bus to assist you in configuring the boards and disks. This sketch can also assist you in troubleshooting problems that might arise later

Configuring and Installing the HBA:-If the system does not have an embedded HBA, you will need to configure and install one into the computer. To configure an HBA:

1. Set the SCSI address according to your SCSI bus plan. 2. Set termination according to your SCSI bus plan.

3. Configure the controller's IRQ, Base Memory address, Base I/O address, and DMA channel, as necessary.

Record the specific revision levels of hardware, software, and firmware that you are using because this information can help you fully describe future problems to the HBA and disk manufacturers. When you physically install the HBA into the system, make sure that it is completely seated in the slot.

Configuring and Installing the SCSI Drive

To configure the SCSI disk, set the SCSI address and termination according to your SCSI bus plan. On some disks, you will also need to set jumpers. For other disks, you might need to use software to configure the disks, or the disks might be self-configuring. When the hard disk is configured, physically install it into the computer or external cabinet.

Attaching Cables to the Installed Drive

Connect the power cable and the cable that connects the hard disk to the HBA. For external disk subsystems, use impedance-matched cable to provide stability for the SCSI bus.

Setting the CMOS Drive Type

For the system to be able to recognize and use the new hard disk, you need to identify the disk for the CMOS. For SCSI hard disks, set the disk type to 0, Not Installed, or SCSI; no other CMOS settings are necessary; BIOS handles any other setup and operation issues.

Completing the Drive's Configuration and Termination

Some SCSI hard disks cannot be configured until after they have been installed into the computer. For these systems, run any software configuration programs necessary to complete the addressing and termination process.

Follow the steps below to learn how to install a SCSI drive.

Set the SCSI ID of the hard drive you're installing. Refer to the documentation or the label on the drive to determine how to set the drive ID.

Terminate the drive if it is at the end of the chain. Again, refer to the documentation.

172

Page 173: HISTORY AND DEVELOPMENT OF LINUX22

Insert the SCSI drive into its bay.

Mount the SCSI drive to the chassis using the appropriate screws.

Connect the SCSI controller cable between the SCSI host adapter and the SCSI drive.

Connect the power connector to the rear of the SCSI drive.

Power on the computer.

Press Ctrl+A at the SCSI BIOS message.

Use the menu in the SCSI BIOS utility to examine the configuration of your host adapter card and the SCSI drive you installed.

Use the menu in the SCSI BIOS utility to format the SCSI drive you installed. This is a low-level format.

Exit the SCSI BIOS utility and shut down the computer.

Troubleshooting SCSI Hard Drives:-Keep the following points in mind as you troubleshoot SCSI hard drives:

The vast majority (up to 95 percent) of problems with SCSI disks are due to incorrect ID settings and improper termination.

Some 386 system boards cannot support 16-bit memory transfers, so you will need to use ESDI instead of SCSI with these systems. Check with the system manufacturer to verify that 16-bit memory transfers are supported.

When a SCSI system is booted or reset, SCSI controllers generally need to renew all SCSI device connections before activating the devices, causing a delay during POST.

SCSI cables should be handled carefully to minimize problems. Do not roll SCSI cable on itself, run long lengths of it next to metal, or run it past power supplies.

SCSI disks are usually shipped with the parity jumper setting enabled. Verify that your system configuration requires this setting to be enabled, and disable it if it is not required for the system.

SCSI buses can be connected through parallel printer ports and PC Card connections, enabling portable computers to take advantage of SCSI technology. You can attach up to seven daisy-chained SCSI devices and still use the printer port if you have a parallel-to-SCSI adapter that supports this piggyback configuration. Of course, the limitations of the printer port reduce the normal data transfer rate for SCSI devices, but because most laptops and notebook computers cannot normally use these devices, the lower data rate can be an acceptable trade-off for increased functionality.

If you intend for a SCSI disk to be bootable after you install it, you must configure the BIOS to Enabled, by using jumper settings or software configuration.

Verify that all SCSI devices have unique SCSI ID numbers.

If you are installing an additional SCSI hard drive into a computer where only one connector is available on the SCSI cable and the cable itself is terminated, remove and replace the cable with one that has multiple connectors.

1. List the steps for installing a SCSI hard drive.

Ans: Plan the SCSI bus. If necessary, configure and install the HBA. Configure and install the hard drive. Attach cables to the installed disk. Set the CMOS type to 0, Not Installed, or SCSI. If necessary, complete the disk's configuration and termination.

2. When planning the SCSI bus, what should your plan include?

173

Page 174: HISTORY AND DEVELOPMENT OF LINUX22

Ans: How to handle termination, SCSI addressing, and cabling. Sketching the layout of the SCSI bus can help you in configuring the boards and disks, as well as with troubleshooting in the future.

3. Indicate where each of the following should be terminated: Internal (multiple disks inside the PC), External (multiple disks in a separate cabinet), Mixed (multiple disks in the PC and in an external cabinet).

Ans: Internal On the HBA and on the last disk in the SCSI chain. External On the HBA and on the external cabinet itself. � �Mixed On the last internal disk and on the external cabinet. �

4. List the steps to configure an HBA.

Ans: Set the SCSI address according to your SCSI bus plan. Set termination according to your SCSI bus plan. Configure the controller's IRQ, Base Memory address, Base I/O address, and DMA channel, as necessary.

5. How can you minimize SCSI cable problems?

Ans: Handle them carefully, don't roll SCSI cable on itself, don't run it for long lengths next to metal, don't run it past power supplies.

6. You want to add a second SCSI drive to your system. The SCSI cable has only one connector and the cable itself is terminated. What do you need to do to install the second drive?

Ans: Replace the cable with one that has multiple connections.

1. What is a form factor?

Ans: The physical size of a device as measured by outside dimensions. With regard to a disk drive, the form factor is the overall diameter of the platters and case, such as 3.5 inches or 5.25 inches, not the size in terms of storage capacity.

2. What is the difference between ATA and SCSI hard drives?

Ans: Most PCs have two ATA adapters: a primary and a secondary. A maximum of two devices can be installed on each adapter. ATA devices are typically used in consumer-level PCs. SCSI controllers can support up to either 7 devices or 15 devices on a single controller, depending on the SCSI standard employed on the controller. SCSI disks are typically used on high-end workstations and server class machines.

Lesson 5 FireWire Ports

Lesson Objectives

In this lesson, you will:

Describe the major characteristics of FireWire. Explain a hot swap.

Introduction:-FireWire, the IEEE specification 1394, was approved by the IEEE (Institute of Electrical and Electronics Engineers) in 1995. FireWire was pioneered by Apple. Apple was later joined by Microsoft, Philips, National Semiconductor, and Texas Instruments in the 1394 Trade Association.

IEEE 1394 is similar to USB in many ways, but much faster. FireWire and USB are both hot-swappable serial interfaces. However, FireWire has a higher bandwidth with faster data transfers than that provided by USB.

174

Page 175: HISTORY AND DEVELOPMENT OF LINUX22

Two Levels of Interface:-There are two levels of interface in IEEE 1394, one for the backplane bus within the computer and another for the point-to-point interface between device and computer on the serial cable. A simple bridge connects the two environments.

The backplane bus supports data-transfer speeds of 12.5, 25, or 50 Mbps. The cable standard supports speeds of 100, 200, and 400 Megabits per second. This is about four times as fast as a 100BaseT Ethernet connection and much faster than the 12 Mbps provided by USB. Future speeds will include 800 Mbps, and 1,200 Mbps.

The 1394b specification plans to use a different coding and data-transfer scheme that will provide 800 Mbps per second, 1.6 Gbits per second, and even higher speeds. This high speed makes IEEE 1394 a viable solution for connecting digital cameras, video cameras, printers, TVs, network cards, and mass-storage devices to PCs.

FireWire Cables

Electrical contacts are inside the structure of the connector of an IEEE 1394 cable. This helps prevent shock to the user or contamination of the contacts by the user's hands. These connectors are derived from the Nintendo® GameBoy® connector. Field-tested by children of all ages, this small and flexible connector is very durable. These connectors are easy to use even when the user must blindly insert them into the back of machines. There are no terminators required, or manual IDs to be set.

IEEE 1394 uses a six-conductor cable which contains two pairs of wires for data transport, and one pair for device power. The cable can be up to 4.5 meters long.

The design is similar to a standard 10BaseT Ethernet cable; each signal pair is shielded and the entire cable is shielded. Cable power is specified to be from 8 V DC to 40 V DC at up to 1.5 amps. It is used to maintain a device's physical layer continuity when the device is powered down or a malfunction occurs. This is a unique and very important feature for a serial topology. It also provides power for devices connected to the bus. As the standard evolves, new cable designs are expected to allow longer distances without repeaters and with more bandwidth.

FireWire Chips

Every IEEE 1394 connection contains two chips per device: a physical layer and a link layer semiconductor chip. The physical interface (PHY) is a mixed-signal device that connects to the other device's PHY. All PHY chips use the same technology, whereas the link is device-specific allowing IEEE 1394 to act as a peer-to-peer system as opposed to USB's client-server design. Therefore, an IEEE 1394 system doesn't need a serving host or a PC.

FireWire supports both asynchronous and isochronous transport. Asynchronous transport is the traditional method of transmitting data between computers and peripherals, data being sent in one direction followed by acknowledgement to the requester. Asynchronous data transfers place emphasis on delivery rather than timing. The data transmission is guaranteed, and retries are supported. Isochronous data transfer ensures that data flows at a preset rate so that an application can handle it in a timed way. Isochronous data transfers operate in a broadcast manner, where one or many 1394 devices can listen to the data being transmitted.

Up to 63 channels of isochronous data can be transferred simultaneously on the 1394 bus. Because isochronous transfers can take up only a maximum of 80 percent of the 1394 bus bandwidth, there is enough bandwidth left over for additional asynchronous transfers.

IEEE 1394's scalable architecture and flexible peer-to-peer topology make it ideal for connecting high-speed devices: everything from computers and hard drives, to digital audio and video hardware. Devices can be connected in either a daisy-chain or tree topology.

The 1394 bus bridge isolates data traffic within each work area. IEEE 1394 bus bridges allow selected data to be passed from one bus segment to another.

Because the 1394 cable is powered, the PHY signalling interface is always powered, and data is transported even if a PC in the chain is powered off. Over 1,000 bus segments may be connected by bridges, thus providing a large growth potential. An additional feature is the ability of transactions at different speeds to occur on a single-device medium. For example, some devices can communicate at 100 Mbps while others communicate at 200 and 400 Mbps.

175

Page 176: HISTORY AND DEVELOPMENT OF LINUX22

IEEE 1394 devices can be added to or removed from the bus while the bus is in full operation. Upon altering the bus configuration, topology changes are automatically recognized. This Plug and Play feature eliminates the need for address switches or other user intervention to reconfigure the bus.

FireWire uses memory-based addressing, rather than channel addressing, which views resources as registers or memory that can be accessed with processor-to-memory transactions. This makes for easy networking. A digital camera can easily send pictures directly to a digital printer without a computer in between. Using IEEE 1394, the PC might become just a very intelligent peer device.

IEEE 1394 peripherals will be more expensive than SCSI, IDE, or USB devices. This is because two pieces of silicon instead of one are needed. This will make it too expensive for low-speed peripherals. However, it will probably catch on in higher-end applications like digital video editing. So far it is mainly used in digital camcorders, where it is known as iLink.

Device Bay:-Compaq, Intel, and Microsoft proposed an industry standard called Device Bay. It combines the fast interface of IEEE 1394 and the USB interface. It offers a bay slot to slide in peripherals such as hard disks or DVD-ROM players. Other devices that use IEEE 1394 include ZIP drives, scanners, and CD-RW drives.

Largely because of its support of isochronous data transfer, FireWire has become the preferred technology used for video capture. Used as a hard-disk interface, it offers several advantages over SCSI. It can be just as fast as high-end SCSI, and it is much easier to install.

SCSI devices require a pre-assigned ID and both ends of the bus must be terminated; IEEE 1394 dynamically assigns addresses and doesn't require terminators. FireWire devices are hot-swappable, without the need to power down the PC during installation. IEEE 1394 makes for trouble-free Plug and Play installations because there are no addresses or DMA channels to worry about.

1. What are the major characteristics of FireWire?

Ans: FireWire, also known as IEEE 1394 or iLink, supports up to 63 devices with a maximum bandwidth of 400 Mbps.

2. What is a hot swap?

Ans: To change out a device without needing to power down the PC during installation or removal of the device.

176

Page 177: HISTORY AND DEVELOPMENT OF LINUX22

Lesson 6 Documenting Work Performed on a System

Lesson Objective

In this lesson, you will:

Explain why work performed on a system should be documented.

Overview:-It is important to document changes you make to your system. This is true in configuration, hardware, and software changes. It will be helpful when you go to troubleshoot a problem in the future as well as just simply knowing what is in your system and how it is configured.

The following form is an example of how you might document configuration changes to your system. Notice that it includes information on the original configuration and the updated configuration.

A sample configuration documentation form.

1. Why should work performed on a system be documented?

Ans: So the configuration is known in case troubleshooting needs to be done later.

CHAPTER 17 Troubleshooting Linux Systems

Lesson 1 Understanding a Practical Troubleshooting Model

Lesson Objective

In this lesson, you will:

List the steps in the generic troubleshooting method.

Introduction:-Before getting too deep into the troubleshooting mode, you should check some of the obvious causes of errors or problems. Obvious causes are frequently overlooked, and looking for more complicated reasons can waste time.

177

Page 178: HISTORY AND DEVELOPMENT OF LINUX22

User error is a common reason for errors or things not working. Make sure the user follows the procedure for doing the task. Sometimes, the user follows the procedure and it works, but the user expects different results and thinks the procedure has failed. In this case, explain the expected results to the user to avoid confusion in the future.

Check that all components are in place, that they are right, and that they are connected correctly. Sometimes a loose connection can cause unexpected results. Another common mistake in this category is that the user will attempt to install a new component, but the component is installed incorrectly.

If the user is having trouble accessing files or applications on the network, make sure the correct rights have been assigned. Sometimes the user is expecting to be able to change data in a file, but he or she has been given rights only to view the contents of the file. Check to make sure which set of rights the user should have been given. Another common reason users cannot access files or applications is that they failed to log in correctly (they typed the wrong password or user name, and so on) as the appropriate account, and they did not realize it, tried to do their job, and only then found they could not access files.

Often, simply rebooting a user's system fixes whatever was wrong. If this happens frequently, you will need to look further into the cause. Other times, the user is just not telling you all the actions that led up to the system not working, so rebooting clears out everything back to the startup state and things are fine again.

Useful Tools and Materials to Take to a Trouble Site:-The tools that you will find necessary will depend on the type of problem you are facing, as well as the type of site at which you work. For example, if you work at a small, single-location site, you might not need to bring many items with you to the trouble site. Returning to your desk might take only a couple of minutes and may be easier than carrying a large supply of rarely used materials. However, if you work at a large site, spread across a city or region, you should carry as much with you as possible to minimize the number of return trips you will need to make.

The following list suggests some items that may be appropriate to bring with you. They are not listed in any particular order.

A Basic Troubleshooting Model:-Some companies have developed troubleshooting processes that are systematic and logical. Following these guidelines will help you find and correct problems on your network quickly and efficiently.

One troubleshooting model divides the troubleshooting process into four steps:

178

Page 179: HISTORY AND DEVELOPMENT OF LINUX22

Troubleshooting can be a difficult process. It is not likely that anyone can develop a complete and accurate cookbook approach to troubleshooting, because troubleshooting is often done through intuitive guesses based on experience.

The first method we'll examine simply attempts to create processes that help when you have no experience on which to base your troubleshooting techniques. Keep in mind that even experienced troubleshooters will often have a blind spot and can overlook an obvious problem. This systematic troubleshooting model will help prevent a blind spot from interfering with your ability to find a solution to your trouble. Some basic steps that you should always take, before troubles even arise, are to train your users (to prevent user error), keep an inventory of spare working parts, and have good backups of important data.

Gather basic information. This step involves both gathering information long before trouble happens, and gathering information about trouble that is occurring. This step can include a number of items, such as:

Determine the symptoms of the problem, and determine who is affected. Have a baseline of your network's performance and operating conditions. Compare the current trouble

with those baselines to see if there is a correlation.

Find out if this system worked previously. Determine what has changed since then.

Develop a plan of attack. In this step, you are planning how you will isolate and fix the problem. This step can include a number of items, such as:

Use the basic information you have gathered and your background knowledge to formulate a plan of attack.

Prioritize the likely causes of the problem and your solutions to them.

Document your plan of attack for later reference. If your plan worked now, it might work later. If it did not work, you might want to use a different plan next time you have a similar problem.

Execute the plan/isolate the problem. In this step, you are actually troubleshooting. The goal here is to find the cause of the trouble. This step can include a number of actions, such as the following:

By this stage, you have developed a hypothesis about what is causing the trouble. Divide that hypothesis into small steps that can be individually tested.

Following your hypothesis, make one change at a time. If your changes do not correct the problem, undo them. You should document your changes as you proceed so that you can back step as described here.

Use either a forward-chaining or a backward-chaining method to uncover the source of the trouble. Forward-chaining entails starting from the server or source device and working toward the workstation. Backward-chaining means working from the workstation to the source device.

Use only replacement parts and testing equipment that have been tested and found to be working.

179

Page 180: HISTORY AND DEVELOPMENT OF LINUX22

By the end of this step, you should have solved the problem. If not, your starting assumptions might have been incorrect. Repeat the first three steps again, following a different hypothesis about the cause of your problems.

Document the solution. A problem is solved only when the user is convinced that the problem is solved. This has been described as the "Golden Rule of Troubleshooting." Make sure that the user feels that you have solved his or her problem before you consider it solved.

Documentation is the key to solving future problems, getting equipment upgrades, and preventing financial losses from network troubles. This step can include a number of items, including the following:

Record the exact nature of the problem in your log book. And, just as important, record the solution to this problem, plus the method you followed to isolate this solution.

Make plans or changes that will prevent future occurrences of this or similar problems. For example, if the failure was due to a poor BNC connection on a coaxial cable, you might want to use different connectors, use different installation procedures, or switch to twisted-pair wiring.

The Collect, Isolate, and Correct Method:-Another popular troubleshooting methodology is Collect, Isolate, and Correct. It provides an alternative to the troubleshooting method described previously here. The Collect, Isolate, and Correct method emphasizes different steps in the troubleshooting process. Ultimately, it achieves the same goal as other troubleshooting methods, which is to solve your problem.

The Collect, Isolate, and Correct method divides the troubleshooting process into three large stages, each with a number of steps. These are the Collect stage, the Isolate stage, and the Correct stage.

The Collect stage begins the troubleshooting process. In this stage, you gather information, gather user reports, document the process, and keep track of known problems. The steps involved in the Collect stage might include:

Document the troubleshooting process. Gather user reports of the trouble.

Gather error messages and view the relevant error logs.

Make sure that the user is following proper procedures. You might want to check the order in which the user performs certain steps.

Perform software diagnostics. This step can be performed remotely, before you go to the user's site.

Gather the necessary test equipment and tools to take to the customer's site.

Gather working replacement parts. Test these parts to ensure that they work. Have them available to use when problems appear.

Monitor the performance of your network and develop baseline statistics. Compare current conditions to your baseline statistics and prepare for problems when parameters greatly exceed your baselines.

Track known problems and bugs by consulting with other experts and with online sources, and by reading periodicals and trade magazines. Attend local users' groups to stay informed.

Maintain an accurate log of the configurations of your equipment, your network, and your users' environments.

The key to this stage is to gather a sufficient amount of high-quality information, rather than simply a large quantity of information. The experience you gain from troubleshooting your systems will help you determine what data you need to maintain.

Some of the steps in the Collect stage are done long before trouble arises on your network. Being prepared is the best way to quickly and easily solve problems when they do appear.

180

Page 181: HISTORY AND DEVELOPMENT OF LINUX22

The Isolate stage begins the active troubleshooting process. This stage relies on the proper completion of Collect stage items. The steps involved in the Isolate stage might include:

Plan your attack on the trouble and document your chosen method. Follow your plan. Follow a hierarchical troubleshooting process. Start with the big picture. Check to see how many users

are affected by the same problem. Start with the server, or those items that affect all of the users experiencing problems. After eliminating the server, check the network or intervening networking devices. Do not waste time checking each individual station if many users are affected; the problem is unlikely to be at the end-users' stations.

Start with the easiest problem first. Check to see that the power cord is plugged in before you check to see if the internal power supply is burned out. Check for obvious and logical problems before looking for strange or unlikely problems.

Follow a sequential method to troubleshoot. Complete one testing or isolating process before beginning another.

Document the steps you follow to isolate the problem. Keep track of any changes you need or want to make before you make those changes.

Ask isolating questions (as described earlier) to narrow the range of possibilities for the cause of the problem.

Make sure that proper versions of software and hardware are being used. Keep a detailed record of versions, upgrades, and known problems. This record will help you troubleshoot problems.

Challenge your own assumptions. Better yet, do not make assumptions when you are troubleshooting. If you find yourself saying, "Of course, that cannot be the problem," you might need to challenge your assumption and try changing that anyway. This is especially true when you seem to have exhausted all other possibilities.

Swap parts as necessary to determine the cause of the problem. This will help you to find faulty components quickly and easily. However, swapping parts will not necessarily help you find problems arising from the interaction between two or more parts that you are swapping.

The Isolate stage is a balancing act between a methodical series of steps and a best-guess attempt at solving problems. In some cases, an intuitive reaction will lead you quickly to the source of the trouble. In other cases, you will need to methodically proceed with the troubleshooting process to discover the root of the problem.

One way to proceed logically to isolate a problem is to create a bubble diagram. A bubble diagram displays the possible causes for a problem in a logical fashion. The figure below displays a bubble diagram related to a network failure.

181

Page 182: HISTORY AND DEVELOPMENT OF LINUX22

Once you have created the bubble diagram, you can use it to create a prioritized list of the potential causes of your problem. Such a list might be organized from easiest-to-solve to hardest-to-solve. Alternatively, you might want to order your list from most to least likely to be the cause of your problem. The Isolate stage is often completed nearly simultaneously with the Correct stage.

The Correct stage involves the steps that actually fix the problem, as well as preventive measures. The steps involved in the Correct stage might include:

Document any attempts you make to solve the problem. Note the conditions before and after you have implemented your correction.

Take one step at a time. Make only one change; then test to see if the problem has been solved. If so, you have found the problem. Document your solution and take the necessary steps to complete the trouble call. However, if your step did not fix the problem, undo your changes. Make a change only if you can undo it.

Test your final solution for full functionality. Ask the end-users to test as well. Their perception of "fully functional" may not match yours. It is better to discover further problems immediately than to get another trouble call.

Take any steps you can to prevent future troubles. For example, if you noted a potentially faulty coax connector on the station cable, even if that did not turn out to be the cause of the trouble, you would be wise to fix it while you are at the user's site. This will save you the time of returning later to fix a problem you were already aware of.

Document the problem and its solution. This will aid you in troubleshooting similar problems in the future.

Develop standards to prevent problems. For example, develop a standard file-server naming scheme so that when a new server is added, it is not given the same name as an existing server.

Determine if this problem is made worse by your disaster recovery plan. For example, if solving this problem involves restoring data from tape, was the backup data available? Should your disaster recovery plan be modified to prevent similar problems in the future? If so, fix and document your disaster recovery plan.

The bubble diagram and the prioritized list from the Isolate stage help you set a plan for solving the trouble. Follow your plan. Proceed down your list of potential causes, step by step, from top to bottom. Document your progress, and do not skip steps.

182

Page 183: HISTORY AND DEVELOPMENT OF LINUX22

Ultimately, the troubleshooting process that you follow will be a mix of these steps, plus methods of your own. Remember that a logical, methodical approach to troubleshooting usually leads to quicker solutions. Sufficient and proper documentation of setups, configurations, topologies, and histories proves invaluable to the troubleshooting process.

Discussing Troubleshooting Methods

1. Discuss the generic troubleshooting method described in the previous topics. Would it work for your site?

Ans: Answers will vary.

2. What tools and materials do you feel are appropriate to bring with you to a trouble site?

Ans: Answers will vary.

3. How would you go about gathering information about the hardware and software on the system you are troubleshooting?

Ans: Answers might include: df, du, top, ifconfig, ps, sysinfo, cat proc, among others.

4. Draw a bubble diagram for the situation in which a workstation cannot connect to the network (assume that this station has worked properly in the past). Then, create a prioritized list, ordered by the likelihood of your items being the cause of the problem.

Ans: Answers will vary. Refer to the bubble diagram for a network problem.

5. Discuss the Collect, Isolate, and Correct method to determine the pros and cons of the method. Would it work for your site?

Ans: Answers will vary.

6. Discuss other troubleshooting methods that you would follow. How are they different, and either more or less effective, than the methods presented here?

Ans: Answers will vary.

Applying Troubleshooting Methods:-Now that you have seen some of the troubleshooting models that have been developed, let's see how to apply them. You need to figure out if the problem is the user, the equipment, the system, the software, the network, or some other problem.

Log Files:-Linux keeps log files on many different operations. These include boot, cron, htmlaccess, mail, messages, netconf, secure, spool, and xfer, among others. These are stored in the /var/log directory. Other applications can add their own log files to this or other directories. For example, when you install the HTTP and Samba packages, directories are created under the /var/log directory, and log files specific to those packages are kept here.

System activities are logged by the syslogd daemon. The syslogd daemon is usually started at boot time. The /etc/syslog.conf file is used to configure where the information it gathers is stored. The following graphic shows a portion of a syslog.conf file.

183

Page 184: HISTORY AND DEVELOPMENT OF LINUX22

A sample syslog.conf file.

Let's examine the layout of a syslog.conf line. The kind of messages to be logged are specified in the first field. The log location is specified in the second field. The first field is known as a selector field and the second field is the action field.

The selector field is composed of a facility and a priority separated by a period. The facility is specified using any of the following keywords: auth, auth-priv, cron, daemon, kern, lpr, mail, news, syslog, user, ucp, and local# (where # is 0 through 7). The priority severity can be specified using one of the following keywords (listed by increasing severity): debug, info, notice, warning, err, crit, alert, or emerg. All messages at least as severe as the specified priority are logged. An asterisk can also be used to indicate all facilities or all priorities. The keyword nonecan also be used to specify no priority for the facility.

These log files can be useful in locating the source of problems. Check the log files periodically to make sure they aren't filling up your system. You can back them up before deleting the older portions of the files if you want.

Locating Troubleshooting Resources:-There are lots of places for you to get help with your troubleshooting. These include co-workers, trade magazines, Web sites, documentation manuals, and man pages, to name a few. Usually, the Linux distribution that you are using has a Web site with support or technical documents to help you in resolving issues you encounter.

Some HOWTOs contain a section on troubleshooting the topic being covered. There are also FAQs that address some common problems. Most distributions maintain documents on their Web site that describe problems others have encountered and the solution to the problem.

Documenting Solutions:-Remember, a problem isn't resolved until the customer is happy. In order to improve your response time in the future, document the solution so you know how to fix the problem. It might not be the same solution next time, but this will give you a place to start. Also, sometimes you have actually solved the problem, but the user was expecting a different outcome, so they still don't think you've solved the problem. If the customer says you didn't resolve the problem, you can prove to management that you did.

A sample documentation form is shown in the figure below. You might need more or less information on your form.

1. Examine the form below. This is a very simple form used to capture information about the problem and solution.

184

Page 185: HISTORY AND DEVELOPMENT OF LINUX22

A sample documentation form.

2. How would you change the form?

Ans: You might need more or less information than is included on this form.

3. Create a documentation form that you could use at your company

Ans: The form might resemble that shown in the figure, or it might include additional fields for operating system, hardware, application affected, versions of operating system and applications, or other information.

4. Would you implement the form as an online request and resolution using a specific application or as a Web-based form, or would you just make it a hard-copy form? What issues might you encounter using either method?

Ans: These forms are commonly implemented using a database application, sometimes with a Web-based interface. If you need to work off-site, you might need hard copies of the information, or a subset of the information at least. If it is implemented only as a hard-copy based solution, it makes it more difficult to locate the solutions, and time is always an issue when resolving user problems. You should also maintain a hard copy of the data. If the system is down, you wouldn't be able to access the data online.

1. What are the steps in the generic troubleshooting method?

Ans: Gather basic information; develop a plan of attack; execute the plan/isolate the problem; and document the solution.

Lesson 2 Troubleshooting Equipment Problems

Lesson Objectives

In this lesson, you will:

List some of the environmental factors that can affect system performance. Define API.

185

Page 186: HISTORY AND DEVELOPMENT OF LINUX22

Introduction

Many network problems can be traced to issues with power, cabling, and the environment your computers exist within. We'll start with power problems.

Power Problems:-Computer systems require a steady supply of electricity, often referred to as a clean power source. Interruptions (brownouts and failures), overvoltages (spikes), or undervoltages (sags) can cause your systems to fail. The most common of these power problems is power sags, or short-term undervoltages. Sags are usually caused by heavy loads placed on the electrical system. For example, a motorized device on the same circuit as your computer could cause a sag when the motor starts. Power problems can be cured, in most situations, by the use of an uninterruptible power supply (UPS). UPS devices come in at least two varieties, standby and online.

Cable-Related Problems:-According to Network Computing Magazine, 70 to 85 percent of all network problems are cable-related. Problems include segments that are too long, breaks in the cable, and bad connectors. One of the easiest ways to solve coax cable problems is to use the divide and conquer method. In this method, you divide the cable in the middle and test the resistance in both directions. The half that has a resistance other than 50 ohms is the half with the cable problem. Divide that cable segment in half, and test the resistance of each of the new halves. Repeat this procedure until you have found the problem. A time domain reflectometer (TDR) is a specialized tester that can tell you the distance to, and the type of cable failure. The TDR sends a pulse down the cable and determines the time it takes for reflections of that signal to return. The end of the cable should, in theory, give no reflection (which is why a terminator is used). A cable fault, such as a short, will reflect some or all of the signal back to the TDR. Based on the operational parameters of the cable, the TDR determines the distance to, and the type of cable fault. Cable testers, which combine the functions of a TDR, an ohm meter, and other meters, can give you additional helpful information about your cables. A cable tester, or a TDR, should be in the toolkit of every network administrator.

Environment-Related Problems:-Physical or environmental factors can affect your network. Following is a discussion of some of these factors: magnetism, air quality, power cycling, and temperature.

Magnetism (for example, from motors or equipment) can erase data or interfere with the proper operation of your computing equipment. Electromagnetic fields are not stopped by walls or most intervening materials: distance is the key to minimizing their effects. A magnetic field decreases by the square of the distance from the source (strength = distance2 * strength at the source). Magnetized paper clips, note holders, and similar items should be removed from your workspace, if possible. Such items, should they come near disks, can erase important data. To minimize potential damage, educate your users about the harmful effects of magnets. Be careful to place your computing equipment away from sources of magnetic or electromagnetic interference. Do not place an internetworking device near a motorized device. A large office copier, for example, will emit a magnetic field. Do not place your wiring closet on the other side of a wall from such a copier.

Airborne particles can be damaging to computing equipment. The solid particles in cigarette smoke and dust particles are large enough to be damaging to high-precision devices such as hard drives. A deposited layer of such particles can also act as an insulator, trapping damaging heat inside chips or components. Your computing equipment should be located in a room with a filtered air source. Additionally, the air pressure inside the computer room should be higher than the outside environment to

186

Page 187: HISTORY AND DEVELOPMENT OF LINUX22

prevent air of questionable purity from entering the room when the doors are opened. Specialized, hardened equipment is available from vendors such as Texas Microsystems. These systems are designed to withstand harsh environments. If you need to locate servers in such environments, the additional costs will be offset in the prevention of downtime.

As computing equipment is turned on, power needs are higher than at normal operating modes. Such needs will create temporary strains on the components as either too much or too little power is supplied to them. Additionally, components that have not been on for a while are cool in comparison to their operating temperatures. After they have been on for a few moments, they begin to heat up. Heat causes expansion, which can damage the microscopic electrical connections in chips and components. In other words, turning on a computer can be a damaging procedure. You should minimize the power cycles that a device will have to experience. Some manufacturers even rate the life expectancy of a device in terms of the number of power cycles the device can withstand. Equipment should be left on when possible to avoid damage from power cycling.

The operating temperature of a device can also affect its life. Most computing devices are rated to work properly within a given range of temperatures. Adjust the temperature of your computing environment to closely match the ranges described by the manufacturers of all of your computing devices. Make sure your equipment has reached the ambient temperature before you turn it on. For example, if you need to move a device from one location to another, you should let it warm up (or cool down) to match its new location. Equipment should be moved as little as possible, especially when the moving involves temperature changes. A problem known as chip creep can occur if equipment is repeatedly moved from cold to warm surroundings. The expansion and contraction caused by the temperature changes can actually cause chips to loosen in their sockets. If you move equipment and it begins to exhibit problems, you might want to check that all chips and components are firmly seated.

In summary, you should control the environmental conditions that affect the operational life of your computing devices. In many situations, that means locating servers and important internetworking devices in a special room. Such computer rooms are common in mainframe environments, but LAN-based computing environments often face similar needs.

Troubleshooting Supported Hardware:-Whenever possible, you should use hardware only from the Linux supported hardware list or hardware compatibility list. You can find this list at most distribution Web sites or at http://linuxdoc.org/HOWTO/Hardware-HOWTO/index.html in the Linux Hardware Compatibility HOWTO.

Although Linux can run in low memory situations, to have a productive production server requires significant memory to run correctly. In fact, many problems can be solved simply by adding more RAM or swap partition spaces.

Hardware failure can also lead to problems with your server. A failed hard drive, adapter board, motherboard, or other component will likely cause the server to crash. Because server problems affect many users, you should take steps to prevent such problems.

Purchase high-grade components for your system. To avoid unnecessary downtime, purchase name-brand components from reputable vendors. Avoid bargains when shopping for servers.

When your budget will allow, have spare parts readily available in the event of a hardware failure. A spare NIC, hard drive, drive controller, and SIMM will be invaluable when one of your server components fails. Do not wait until you experience a failure to order replacement pats. You could be down for weeks if the part you need is in short supply.

1. What are two issues the HOWTO author describes in the Introduction of this Hardware HOWTO?

Ans: Alpha and Beta drivers. The fact that the list can never be complete or totally up-to-date. Binary-only drivers are compiled only for a specific kernel version. Old information might still be included that is out-of-date.

2. Is the 3Com 3C319 Velocity ISA Token Ring network card supported?

Ans: Yes.

3. What kernel added USB support?

Ans: It was added beginning with kernel 2.2.18.

187

Page 188: HISTORY AND DEVELOPMENT OF LINUX22

4. Is the Adaptec AIC-7810 SCSI controller supported?

Ans: No.

Removing and Replacing Hardware Based on Symptoms of a Problem:-There are lots of common problems that you will encounter over and over again if you stay in the PC support business long enough. The following are some of the symptoms that you might encounter relating to hardware and some possible solutions to those problems.

Power Supply Problems:-Sometimes you get some weird things happening that you just can't seem to figure out. The computer stops working and reboots itself or while you are trying to boot it hangs, but then you try it a few more times and it finally boots. This might be due to a power supply problem.

TIP: Never use a PC where the power supply fan has stopped working as the system can quickly overheat and damage chips and other system components.

Other symptoms you might see that could indicate power supply problems include:

Some ideas you can try to resolve problems related to the power supply include moving other equipment to a different electrical circuit, verifying that the power supply is outputting the appropriate amount of power (and if necessary, changing the power supply), monitoring the voltage, and using a line conditioner.

System Board Problems:-If your system is unstable and the power supply wasn't the problem, you should probably check your system board and the memory installed on the system board. Symptoms might include instability of the system or missing memory next.

Verify that the power connections are secure to the system board and that the CMOS battery isn't low or dead. If CMOS settings aren't retained, then they will be lost and the system won't know what components it should be finding. You can also check to see if there is an updated BIOS for your system to see if that will rectify the problem.

If memory that you know is installed isn't reported during the memory check, you should verify that the memory is firmly seated. Verify also that DIMMs or SIMMs are of the same size and speed.

Video Problems:-If you hear sounds coming from the system, but you don't see anything on the screen, you probably have a video problem. It could be as simple as loose video or power cables between the system and the monitor. Make sure the power is turned on at the monitor. Next, if the power is on, check the brightness and contrast settings on the monitor�they should usually be about in the middle of the settings. These might be set using an on-screen menu, buttons, or knobs on the front or back of the monitor.

TIP: If you can�t figure out what the problem is, try taking a known good video card and placing it in the system and connecting the monitor to it to see if it then works.

If all of the above check out, but you still can't see anything, it's time to open the system and check the video card. Verify that it is fully seated in the slot, then try it again. Also verify that the chips on the card are fully seated.

188

Page 189: HISTORY AND DEVELOPMENT OF LINUX22

If you are replacing the video card, make sure that there are no resource conflicts. These include IRQ, DIP switches, and the like. If you have a PCI card, try moving the video card to another PCI slot.

Problems such as flickering, wavy lines, out of focus, and wrong colors can be very frustrating. Flickering can be caused by bent pins on the monitor cable, an incorrect refresh rate, or interference from another monitor or other device. Color problems can also be related to bent pins. It is likely though that this problem is due to insufficient video RAM.

Keyboard and Mouse Problems:-Many people take it for granted that the keyboard and mouse work. You are more likely to expect problems with hard drives or other components. However, the keyboard and mouse get a lot of use (and abuse). Since these components are relatively inexpensive, it is usually faster and cheaper to replace than repair them.

TIP: Don�t use rubbing alcohol to clean key contacts as it leaves residue on the contact.

Troubleshooting Drives:-The three most common drive types you will encounter on your system are probably the floppy drive, the hard drive, and a CD-ROM drive. Some issues are common to them all. These include:

If a floppy disk can't be read, take the disk out and make sure the shuttle window moves freely. Try using another floppy disk and see if the system can read or write to that disk. Also, be sure you mounted the floppy disk and that you are referring to it using the correct path. Most systems mount it to the /mnt/floppy directory, but others mount it to the /floppy directory.

A POST error message beginning 17xx indicates a hard drive problem. Either the hard drive or the drive controller weren't found during boot. This can be due to CMOS problems or hard drive or controller problems. After making sure that all cables are

189

Page 190: HISTORY AND DEVELOPMENT OF LINUX22

securely connected, if you still have a problem, try a new controller card. If that fixes the problem, you're all set. However, if you still can't access the drive, you'll need to do some more serious troubleshooting. This includes checking the partition table with FDISK (or another partition tool). If your hard drive contains information that you must try to recover, do not rebuild the drive until you attempt to recover the data. This is often done by taking the drive to a data recovery service.

For both hard drive and CD-ROM volumes, verify that they are correctly mounted. If a volume isn't mounted you won't be able to access data on the drive. You have seen a number of tools you can use to check the status of the filesystem and possibly repair the filesystem if it has been damaged. These include most notably fsck, but also du, df, and lsof.

Sound Problems:-Sound cards can also be a source of frustration. Make sure that there are no resource conflicts. The sound cards often use two IRQs, one of which is often also used by network cards.

If you aren't getting any sound, make sure the speaker cables are plugged into the Out or Speaker port of the sound card, that the volume is turned up on the speakers, and that the speaker power supply is connected to a working electrical outlet and plugged in to the speaker system. If the speakers work, but there is background noise, make sure that the speaker cables aren't wound around other electrical cords. They will pick up the electromagnetic frequencies in the power cords and transmit this as a humming or high-pitched noise through the speakers. Try moving the speakers and untangling the cables from other cables and cords.

Modem Problems:-Your modem connection is only as good as your phone lines are. If you have old lines in your area, you'll likely have problems connecting or staying connected. Keep your phone cables untwisted and if you are still having problems, remove other equipment such as credit card machines or fax machines off the line when you are trying to use the modem.

If your modem still won't respond, try the following:

Verify that the phone cord is connected to the wall jack and to the wall jack port on the modem. Verify that you have a dial tone by plugging in a phone and lifting the receiver.

If you are using an external modem, verify that the power supply is connected to the modem and a working electrical outlet.

Verify that there are no resource conflicts and that the modem is configured to match the serial port the modem is set to use/connected to.

Printer Problems:-If your printer doesn't work, you need to check first whether it is correctly identified on your system. Then, check if other print jobs work (can other people send jobs to the printer?), whether lpd is running (check using lpc), and try sending a print job logged in as root. If your system is also configured as a DOS/Windows system, see if you can print from that side of your system.

If you still haven't narrowed down the problem, you can begin to suspect a hardware problem. Try printing a test page using the controls on your printer. Check the documentation for how to do so on your printer. Verify that the power is connected and that it is turned on. Also, check that the cable is securely attached between the PC and the printer. Try using a different printer cable to see if it resolves the issue. Try connecting the printer to a different PC. If this fixes the problem, you can suspect that the parallel port is the problem. Check that there are no IRQ conflicts. The first parallel port (usually referred to as lp0) uses IRQ 7 and the second parallel port (usually referred to as lp1) uses IRQ 5.

Network Problems:-Network cards are important in today's networked world. If you can't connect your system with other systems, it is often difficult to accomplish things. The network card must match the medium being used; for example, an Ethernet network needs Ethernet network cards and Token-Ring networks need Token-Ring network cards.

Make sure there are no resource conflicts. Often sound cards and network cards want to use the same IRQs. If you have a second parallel port in use, make sure that your network card isn't using IRQ 5. Verify that the cable is properly connected. For example, make sure you didn't accidentally plug the network cable into the modem.

190

Page 191: HISTORY AND DEVELOPMENT OF LINUX22

TIP: In addition to these hardware problems, there is always the problem that the network itself might be experiencing problems such as cable, network device, or server problems.

Removing and Replacing Hardware

1. A symptom is listed in the left column. In the middle column, record the possible problem, and in the right column, record what you might try to do to resolve the problem.

  Symptom  Possible Problem

  Possible Solution

  You are getting occasional   memory problems and other   intermittent weird problems   that don't seem to be related   to anything in particular.

   

  You hear sounds coming from   the system, but don't see   anything on the screen.    

  Monitor flickers.    

  Mouse jumps around on the   screen.    

  Can't access floppy disk data.    

  No sound is coming through   your speakers.    

  Can't dial out.    

  Can't connect to the network.    

Ans:

  Symptom   Possible Problem   Possible Solution

  You are getting occasional   memory problems and other   intermittent weird problems   that don't seem to be related   to anything in particular.

  Power Supply   Moving other equipment to a   different electrical outlet;   verifying that the power   supply is outputting the   appropirate amount of power   and, if necessary, changing   the power supply; monitoring   the voltage; using a line conditioner.

  You hear sounds coming from   the system, but don't see   anything on the screen.

  Video   Check power and video   cables. Make sure the power   is turned on at the monitor.   Check brightness and contrast   settings. Check the video   card, including that it (and the   chips on the card) are fully   seated.

  Monitor flickers.   Video   Check for bent pins,   interference from another   monitor or device, incorrect refresh rate.

  Mouse jumps around on the   screen.   Mouse System   Dirty rollers.

  Can't access floppy disk data.   Drives   Verify that the drive is   mounted, and that you are   using the correct directory that it was mounted to. If you   still can't access the data,   verify that the shuttle window   moves freely. If you can't read   any floppies, verify that the power cables are   firmly connected to the drive.

  No sound is coming through   your speakers.   Sound System   Verify that there is no   resource conflicts with the   sound card. Verify that the   speakers have power and that   the cord is plugged into the   Out or Spkr port of the sound   card.

  Can't dial out.   Modem   Verify that the phone cord is   connected to the wall jack   and to the wall jack port on   the modem. Verify that you   have a dial tone. If using an   external modem, verify that   the power supply is   connected and that the   modem is turned on. Verify   that there are no resource   conflicts with the modem.

  Can't connect to the network.   Network  Check for resource conflicts,   that you are using the   appropriate network card for   your network, and that the   network cable is plugged in.

Troubleshooting Application and User Problems:-So far, we have looked at problems that occur on the network or with the equipment. Now, we will look at problems that might occur in applications and at the user end.

Application Problems:-Application configurations can lead to as many, if not more, problems at the workstation than can operating-system problems. These problems might appear at installation time or with later trouble calls. Some applications might conflict with each other, while others will have problems working across the network. Users might create problems by installing unauthorized software or by installing or configuring their software incorrectly.

191

Page 192: HISTORY AND DEVELOPMENT OF LINUX22

Some companies solve these problems by requiring that all software be approved and installed by a central service group. This policy also has the benefits of preventing license-violation problems and virus infections.

Software Installation Problems:-Usually, the problems you run into when installing Linux software are related to the installation media, corrupted files, or out-of-space situations. The following animated tip describes some of the problems you might encounter.

User-Related Problems:-While many will never admit it, users often create their own problems. Changing configurations, installing or removing software, or other similar actions can cause problems for your end-users.

One of the biggest user-created problems is that of accidentally erased files. A sound backup policy that is documented and distributed to your end-user community will help to alleviate problems from lost files. You should have one such utility readily available.

Users might even damage their own hardware. For example, a user might spill liquids onto his or her keyboard. Educating your end-users can help to prevent such problems.

Security:-Security is closely related to troubleshooting. Poor security can lead to damage or loss from disgruntled employees, hackers (usually persons seeking access to your data for the challenge of getting it, although some actually seek to cause damage or downtime), or competitors (corporate spies). The following sections describe some factors that affect the security of your data and equipment. One of the ways in which your computing environment must be secured involves controlling access to your equipment. Allowing free access to your computing equipment can be an easy way for people to cause damage or data loss, or gain access to data for which they are not authorized. If you use a computer room, it should remain locked at all times and only authorized personnel should have keys. This principle extends to wiring closets or other locations where internetworking devices are located.

Viruses:-Viruses are programs designed to replicate themselves. Viruses normally inflict damage to your data or programs, display messages, or slow performance. A Trojan horse is a program, similar to a virus, whose actual purpose differs from its stated purpose. A Trojan horse, for example, might mimic the features and functions of a valid executable program. In doing so, such a Trojan horse might be able to gather information that could be used later to compromise your data. Because users are rarely, if ever, logged in as root, and because users have a limited permission set on the system, viruses aren't as big of a problem in the Linux OS.

Determining if a Problem is User- or Hardware-Based:-Now that you have seen some of the user and application problems that you might encounter, let's look a little deeper at separating those problems from hardware problems. Often on the surface, it might appear that the hardware is malfunctioning, but it is really a user problem. For example, if a user says they can't print, it might be because they are trying to print to a printer they don't have access to, or that they forgot to turn on the printer.

192

Page 193: HISTORY AND DEVELOPMENT OF LINUX22

Another example is not being able to log in. A user might call the help desk saying that no matter what they do they can't log in. You don't know of any network problems, and no one else has called in to say that they can't log in. You should check to see if the user is entering the wrong password or user name. Also, if the user typed the login information incorrectly too many times, and if you configured the system to lock users out if this happens, they might be locked out for a while.

Some things require you to be logged in as root in order to do them. If you aren't root, it makes it look like files are missing or the drive is corrupted.

Sometimes you have to handle user problems gently. You don't want to alienate the user by telling them that they made a "stupid" mistake. You need to often walk them through the task step by step. If the user experiences the same problem on a regular basis, help them to record the steps so they can refer to them later or suggest that they attend training. If this still doesn't help, make the user's manager aware of the continuing problem.

Another issue you might encounter is due to users not having the rights they expect to have to a particular file or directory. If they try to edit a file to which they have only read rights, they won't be able to save the file after making changes to it. This is often the rights that the user should have; they shouldn't be able to change the file, but they try to anyway. If the user was supposed to be able to change the file, you would need to give them the appropriate rights.

Other times, it might appear that there is a software problem, but it is really a hardware problem. For example, in one company, the print queue was routinely disabled so that no more jobs could be sent while other work was being done. The users eventually got used to not being able to print during these times. However, one time, the printer was actually physically not working and users just assumed that the queue was disabled. Eventually, when the jobs would have been expected to be printed, it was found that the printer was in need of repair.

1. How might you approach users so that you don't hurt their feelings while trying to figure out if a problem is user error rather than equipment malfunction?

Ans: Answers might include: walking users through the process; pointing out that other users are able to perform the function, so you will need to come visit their system to verify that there are no equipment problems on their end; then while you are there, perform the task yourself, then show them how to do it.

2. You have a user who calls every day with the same problem. How can you help this user remember how to perform the task and free up your time from repeating how to do it every day?

Ans: Provide training, write out the steps, let the user's manager know that this is occurring.

3. A user opens the sales file from the dept550 computer in vi. After making changes, the user tries to save the file, but gets a message that the file is Read-only. The user calls and says that the hard drive is broken. What should you do to rectify the situation?

Ans: his occurred because the user does not have write (w) rights to the file. If he or she should be able to write to the file, add write rights or have the user save the file to another filename in a directory where he or she has appropriate rights. Then, explain to the user why the error message occurred.

4. A user is unable to log in to the system. What issues should you check in resolving this problem?

Ans: Check that the user is using the correct login name and password. If there are many systems, make sure that the user is connecting to the appropriate system where the user is defined.

5. A user is unable to print. What should you check to resolve this problem?

Ans: Check that the user has rights to the printer, that the printer is properly configured, that the printer is on line, that the queue and printer are configured to receive jobs, that the cable is good and is securely connected on both ends, and that there are no problems with the printer (physically or configuration-wise).

193

Page 194: HISTORY AND DEVELOPMENT OF LINUX22

6. A user is unable to send or receive email. What should you check to resolve the problem?

Ans: Check that sendmail is properly configured, that the user has network connectivity, and that there are no problems with gateways or other systems through which the email would need to travel.

When your system was created, you were given the option to create a rescue disk. Hopefully you did so then. If not, you can create it later. The rescue disk can be used to boot the system in the event that the system kernel becomes unbootable. The kernel may become unbootable due to changes in hardware or problems in the recompiling or configuration of the kernel or kernel modules.

If you need to create a rescue disk, insert the floppy disk but don't mount it. The dd command writes raw data to the disk, which it can't do if the drive is mounted. Logged in as root, enter dd if=/boot/vmlinuz of=/dev/fd0 bs=8192.

Another way to create a boot disk is to use the mkbootdisk command. This command needs to know the version of your kernel. The last part of vmlinuz-2.2.14-15mdk (2.2.14-15mdk) is your kernel version. If your kernel doesn't have any version information in the filename, pick the latest kernel version from the /lib/modules directory. Logged in as root, enter mkbootdisk --verbose --device /dev/fd0 2.2.14-15mdk. Using this method, you have the option of using a "rescue disk," along with this boot disk at boot time. A rescue disk contains various utilities to fix problems in Linux.

After creating a rescue disk, test the boot disk out by rebooting the computer with the disk still in the drive. This is an important step; otherwise you won't know whether it will work when you need it. If you're locked out of Linux, and require a boot disk to get back in or the boot disk you have doesn't work, check out the rescue disk images at www.linuxdoc.org/HOWTO/Bootdisk-

HOWTO/premade.html.

Follow the steps below to learn how to boot from a rescue disk.

1. Shut down your system.2. Insert the rescue disk into the disk drive and power on the system.

3. Investigate any potential issues and fix them.

4. Remove the disk and restart your system. It should now boot normally.

Troubleshooting ATA and SCSI Devices:-Drives are the component most susceptible to damage. They are highly mechanical with moving parts that need to be within very high tolerances to work properly.

The two major categories of drives are ATA (formerly known as IDE) and SCSI. ATA devices are based on the ISA 16-bit bus. The ATA bus supports just two devices�master and slave. The SCSI standard supports 7 or 15 devices depending on the implementation. SCSI supports much faster transfer rates than ATA devices. However, SCSI can be more difficult to install and configure, but with some practice it shouldn't be too hard.

The following are some questions you should ask yourself about the drive to determine if the drive is damaged, misconfigured, or so on.

194

Page 195: HISTORY AND DEVELOPMENT OF LINUX22

SCSI Device Problem Possible Solutions

Does the drive spin up? If no, be sure that the power connection and the interface cable are firmly plugged in to the drive.

Is there LED activity? Verify that the SCSI ID setting is unique.

Can the computer recognize the drive? Verify the SCSI drive has been enabled in the host adapter setup program.

The following are links to hard disk related sites. You might find them useful in finding hard disk solutions.

URL This site contains

http://www.nyx.net/~sgjoen/disk.html Information on how to use multiple disks and partitions for a Linux system.

http://metalab.unc.edu/LDP/HOWTO/mini/Hard-Disk-Upgrade.html Information on how to copy a Linux system from one hard drive to another.

http://metalab.unc.edu/LDP/HOWTO/mini/Ultra-DMA.html Information on how to use Ultra-DMA drives and interfaces with Linux.

http://metalab.unc.edu/LDP/HOWTO/mini/Partition-Rescue.html Information on how to rescue your Linux partition if it was deleted by MS-DOS.

http://metalab.unc.edu/LDP/HOWTO/mini/Partition.html Information on how to plan and layout a Linux filesystem. It covers disk hardware, partitions, swap space sizing and positioning considerations, filesystems, and filesystem types.

http://www.linuxdoc.org/HOWTO/Large-Disk-HOWTO.html Information on how to configure drives containing over 1024 cylinders.

http://metalab.unc.edu/LDP/HOWTO/Root-RAID-HOWTO.html Information on how to implement raid on Linux.

195

Page 196: HISTORY AND DEVELOPMENT OF LINUX22

The following is a list of symptoms, problems and potential solutions to issues you might encounter during installation.

Symptom Problem SolutionLocating Disks, Cannot find disk. How to find what dive letter

corresponds to what disk/partitionRemember Linux does not use drive letter but device names.

Cannot partition disk Most likely wrong input to the command line for fdisk or similar tool.

Remember to use /dev/hda rather than just had. Also do not use numbers behind hda, those indicate partitions.

Cannot format disk Strictly speaking u format partitions not disk.

Make sure u add the partition number after the device name of disk, for instance /dev/hda1 to the command line.

This next set of issues you might encounter during booting.

Symptom Problem Solution

Boot fails; numbers keep scrolling up the screen.

Possibly corrupt disk. Try another disk; you might have to re-install. Check for loose cables and possible data corruption.

Get LI and then it hangs. You use LILO to load Linux but LILO cannot find your root.

Read the LILO HOWTO.

Kernel panics; a message displays something about missing root filesystem.

The kernel does not know where the root partition is.

Use rdev or (if applicable) LILO to add information to the kernel image where your root is.

System boots but get into a root shell in single user mode.

Something went wrong in the later stages of booting and the system has come far enough to let you open a shell to repair the system.

Locate the problems from the boot log. Note that filesystem can be in read-only mode. Remount read-write if you have to. Often the reason is that the /etc/fstab contained an entry that was mismapped such as trying to mount a swap partition as your normal file space.

This next set of problems occurs while the system is running:

Symptom: Swap: Short on memory. Problem: Swap space is not available.

Solution: Type free and check the output. If you get the following, then the system is running normally.

total used free shared buffers cached

Mem: 46920 30136 16784 7480 11788 5764

-/+ buffers/cache:   12584 34336      

Swap: 128484 *9176 119308      

If the line with Swap: contains zeros, either you did not mount the swap space (partition or swap file) or the swap space was not formatted.

Symptom: No space available. Problem: An undersized partition has caused overflow in some areas.

196

Page 197: HISTORY AND DEVELOPMENT OF LINUX22

Solution: Examine your partition usage using the df command and locate problem areas. Normally the problem can be solved by removing old junk but you might have to repartition your system.

Symptom: No room.

Problem: Running out of inodes has caused overflow in some areas, often in areas with many small files such as news spools.

Solution: Examine your partition usage using df -i and locate problem areas. Normally the problem is solved by reformatting using a higher number of inodes. See the mkfs man page and the related man pages.

Crash Recovery:-Sometimes hard disks crash and can result in scrambled data. Often data can be recovered from these catastrophes. You can send the drive to a professional data recovery company or try to recover data yourself. Attempting to recover data yourself can cause more damage and is higher risk than if you send it out to a professional data recovery company.

If a disk stops rotating or fails to spin up, you should immediately turn off the system. Try disconnecting the drives and power up the machine. You can then use a multimeter to check whether there is power. Unseated connectors can cause all sorts of problems.

If you try to recover from hard disk problems yourself, you should check all connectors and then re-apply power and see if the drive spins up and responds. If it still is dead turn off the power before the operating system boots. Some drives have a delayed spinup, so make sure you aren't being fooled by this when you are checking that the drive spins up.

Some people have been known to remove the drive then give it a firm tap on the side so that the disk moves a little with respect to the casing. This can be very risky, but help in unsticking the head from the surface, allowing the platter to move freely. This sometimes works because the motor power is not sufficient to unstick a stuck head on its own.

The lubricant can harden or drain out of the bearings if a drive has been turned off for a while after running for long periods of time, or if it has overheated. In this case, warming the drive slowly and gently up to normal operating temperature will possibly recover the lubrication problems.

If the drive still does not respond, one last thing experienced hardware technicians can try is to replace the circuit board of the drive with a board from an identical model drive. This is extremely risky, and is not recommended.

Often the information stored on a drive is worth far more than the media itself. For this reason, you should strongly consider using a professional recovery company that has advanced equipment and information from drive manufacturers on how to recover a damaged drive.

How to Rescue Your Linux Partition if MS-DOS Deleted It:-All of the installed operating systems need to share the disks. When the system is started, the BIOS can scan only the first disk. A partition table is located in the Master Boot Record (MBR) at the start of this disk along with the boot loader. If any of the operating systems you install don't work with the MBR, then problems occur. When you install another operating system, automatic partitioning often leads to problems.

To resolve this problem, you will almost always lose the most recently installed operating system, and possibly all of the installed operating systems. To begin the recovery, you need a disk (floppy or cd) from which Linux can start by itself with fdisk available. The rescue disk from your distribution should be able do this for you. You also need your documentation in which you recorded the fdisk -l content. Now that you have these tools you need to:

197

Page 198: HISTORY AND DEVELOPMENT OF LINUX22

There is a good chance that lilo was also damaged so you will need a boot disk or booting from a cd (choose the option "booting the installed partition"). If you previously booted with lilo, as soon as you are logged in as root, enter lilo to re-install the boot loader. Hopefully, all of Linux should be there�give it a try. If Windows was also installed, try to start it as well.

Some Other Drive and Controller Problems:-The following rollover shows the boot messages you might receive regarding your drive partitions. This is what you should see when the kernel detects and recognizes the partitions on your system. If they aren't detected, you will see different messages. Sometimes the partitions aren't recognized for a variety of reasons, some of which are found in the following rollover.

Promblem SolutionUnsupported drive or controller Replace with hardware found on the supported hardware listConfiguration problem with the drive or controller For SCSI controller, reconfigure IDs. For ATA drives, verify master and

slave are properly set.SCSI controller not detected Specify boot information at startup.Hard Drive geometry not recognized Specify drive geometry at boot prompt. For example, enter linux

hd=cyl,head,sectors where cyl specifies the number of cylinders, heads specifies how many head r on the drive and sectors specifies the number of sectors on the drive.

SCSI is used for lots of different devices including hard drives, CD drives, tape drives, and scanners. Sometimes the device or controller isn't recognized. You might need to load a module into the kernel for it to be recognized by the system.

1. Your ATA device can't be detected by FDISK.

Ans: Run fdisk /status to check the drive.

2. Your SCSI drive doesn't spin up.

Ans: Check that the power cable and the drive interface cable are firmly plugged into the drive.

3. You get a kernel panic message.

Ans: Use rdev or LILO to add information to the kernel image where your root is.

198

Page 199: HISTORY AND DEVELOPMENT OF LINUX22

4. Short on memory.

Ans: Use the free command to check the output.

5. Hard drive geometry not recognized.

Ans: Specify drive geometry at boot prompt. For example, enter linux hd=cyl,heads,sectors where cyl specifies the number of cylinders, heads specifies how many heads are on the drive, and sectors specifies the number of sectors on the drive.

Troubleshooting Peripheral Devices:-When troubleshooting peripheral devices such as printers, monitors, scanners, modems, cameras, tape, and other storage devices like Zip or Jaz drives, one of the first things you should check is that the power cord is plugged in on both ends and that data cables are properly connected between the device and the system. Next, you should make sure the problem is not OE�operator error.

Some of the configuration settings you might check include IRQs, I/O Addresses, SCSI IDs, and if necessary, if it is enabled in BIOS. Check any configuration files related to the device and check the manufacturer's Web site to see if a similar problem has been reported. If it has, there is most often a solution posted there as well.

When a user complaint comes in regarding peripherals, there are several things you can check right away. These include cables, power, and resource conflicts.

Be sure that the correct cable was used and is plugged firmly into the correct port. For instance, a parallel cable will fit into a SCSI port (and vice versa), but it won't work. The mouse and keyboard ports and cables are identical. You just need to get the mouse or other pointing device plugged in to the port that the system has configured to be the mouse port and the keyboard plugged into the port that the system has configured to be the keyboard port.

Next, verify that there are no bent pins on the cable. The pins are made of very soft material, and can easily get bent or broken if the cable isn't plugged in straight. This can affect the transmission of data.

Make sure the pinouts are correct for the device you are using. This is especially true for serial cables which can be configured to use certain pins for specific purposes. A standard RS-232 cable (the default serial configuration) uses only pins 2,3,4,5,6,7,8, and 20. For this reason, the 9-pin serial cable was developed, which uses the following pinouts.

Another thing you should check is that the peripheral isn't conflicting with other hardware. Conflicts can arise when the IRQ/DMA, or I/O port addressed is used by two devices. The peripheral might not work or might work intermittently. Change

199

Page 200: HISTORY AND DEVELOPMENT OF LINUX22

the conflicting setting in the device configuration or use jumpers or configuration software for the device to eliminate the conflict.

Some devices require you to add drivers to your system. In some cases, you might need to recompile the kernel; in other cases, you'll need to load additional modules.

If you are using USB devices, make sure you have a recent enough kernel that includes USB support. USB support was added in kernel 2.2.18.

1. A user tried to plug in his new monitor, but couldn't quite reach and ended up bending a pin in the cable when he reached around and finally got it plugged in. He didn't tell you this, but called saying that the monitor was showing wavy lines and distorted images. How would you know that the cable was damaged?

Ans: One of the things you should check is whether the cable is firmly plugged in. To do this, you might unplug the monitor and plug it in again. You should examine the pins at this point. You might also notice it when you go to swap out the monitor for another monitor.

2. When a user boots her system, she gets a message that there is no keyboard attached. She calls and says that they need a new keyboard. What should you check before purchasing a new keyboard?

Ans: You should verify that the keyboard is plugged into the keyboard port and not to the mouse port.

3. A user is getting intermittent problems after installing a sound card. The sound card is using IRQs 5 and 7. He or she also has a printer on lp0 and a network card using IRQ 5. What is the reason for the problem and how can you resolve it?

Ans:As you know from the lesson entitled "Working with Hardware," lp0 uses IRQ 7,so there is a conflict there. The network card is also conflicting with IRQ 5.Reconfigure the sound card to not use IRQ 7 and reconfigure the network card to not use IRQ 5.

Supporting Portable Systems:-Portable systems can range from desktop replacements, to notebooks, to laptops. They all have battery power and range from quite heavy to very light. Portable computers currently fall into three categories, determined by the general uses of each:

Desktop replacement. The largest of the portables, it generally weighs over 6.5 pounds and usually has the most features, including large screen, large hard drive, CD-ROM drive, multimedia capabilities, modem, and printer. It is expensive; however, it can serve as both a desktop and a portable without many compromises.

Notebook. It usually costs less than a desktop replacement because it has fewer features. It is used primarily as a satellite to a network or desktop system, such as a college student or sales representative might require. It usually has a smaller display, slower processor, smaller hard drive, and slower peripherals.

Sub-notebook. It weighs less than five pounds; the ultralight weighs in at less than three pounds. To keep weight down, it has a minimum of features including a small display and small keyboard. Manufacturers are attempting to increase its functionality while maintaining its convenient size. Battery life tends to be good. The sub-notebook is built primarily for inputting text and retrieving data from a remote computer.

Portable computers can use battery power for all their functions. Batteries limit the length of time users can work on the computer, and they are expensive to replace or to keep as backups. For these reasons, many users rely on an AC adapter in place of the battery whenever regular electric power is available.

PC Cards:-The Personal Computer Memory Card International Association (PCMCIA) is an alliance of members who promote interchangeability and compatibility among portable computers. The alliance defines the standards for the PC Card, which offers additional memory and peripherals to portable computers. PCMCIA also defines the standards for Socket Services and Card Services, the software elements of the PCMCIA specification. The PCMCIA association developed the standards for PC Cards. These are the credit-card sized cards that can be used for memory, storage space, network cards, modems, and other purposes.

200

Page 201: HISTORY AND DEVELOPMENT OF LINUX22

PC Cards currently come in three types. Each is about 75 mm long and 55 mm wide; they differ only in thickness. A thinner card can be used in a thicker slot, but a thicker card can't be used in a thinner slot. A Type I slot can hold one Type I card. A Type II slot can hold one Type II card or two Type I cards. A Type III slot can hold one Type III card or a Type I and Type II card. Each card has features that fit the needs of different applications:

Type Thickness Description1 3.3mm These slots have one row ofsockets and are primarily to and memory, such as RAN & ROM.11 5.0mm These solts have two rows of sockets & typically used for memory, I/O devices such as data/fax

modems, NIC, LA adapters & SCSI connections. These cards usually have a pop-out connector for an RJ-11 or RJ-45 connector.

111 10.5mm These slots have three rows of sockets & are most commonly used to install hard disk drives or supportadapters for external CD-ROM, DVD & Tape drives.

Extended cards allow the addition of components that must remain outside the system, such as antennas for wireless applications. At startup on a portable computer, Card and Socket Services are loaded into memory. This software comes with the PC and with the cards. These two layers of software detect and support a PC Card when it is inserted into the portable. They also manage hot-swapping and pass changes in events to higher-level drivers written for specific cards.

Socket Services interacts with the BIOS to identify the number of sockets available. It can be built into the BIOS or added through software. When the system is turned on, it also detects when a PC Card is inserted or removed. Socket Services works with Card Services above it, and also communicates directly with the PC Card's controller chips.

Card Services automatically assigns system resources when Socket Services has identified that a PC Card has been inserted. Card Services manages system resources required by the PC Card such as IRQs, memory, and I/O addresses. This software management interface also works in conjunction with upper-level software, such as hardware drivers, that might need to be loaded to work with the PC Card.

Many portables support hotswappable devices. This means that you can switch devices without the need to power down the system prior to removing or inserting the device. Some systems have only one bay that is used for both the CD-ROM drive and the floppy drive. Changing from CD-ROM drive to floppy drive on some systems can be done on the fly; for other systems, you still need to power down then restart the system in order for it to be recognized.

The pcmcia file stored in /etc/pcmcia/config is a PCMCIA card configuration database. It is read at startup by the cardmgr utility. It defines what resources are available for use by Card Services, describes how to load and initialize device drivers, and describes specific PCMCIA cards.

The stab file is created by cardmgr and contains identification and device driver information for PCMCIA cards. Each socket is described by one header line, followed by one or more device driver lines. The header gives the card name as given in /etc/pcmcia/config. Device driver lines consist of a series of tab-separated fields.

201

Page 202: HISTORY AND DEVELOPMENT OF LINUX22

The file is updated by cardmgr whenever a card is inserted or ejected, and when cardmgr receives a SIGHUP signal. The stab file will normally be created in either /var/state/pcmcia or /var/lib/pcmcia, but if neither directory is available, it will be found in /var/run.

Utilities to Help Support Portable Systems:-A suite of PCMCIA utilities can be installed to provide support. Some of the most frequently used utilities include:

The cardinfo utility displays the current configurations of all PCMCIA sockets in the system. For each card, the display includes the card name, the card state, IO port and interrupt settings, and the names of any devices associated with that card. Each socket also has a menu of commands for manipulating the socket state. The socket state includes a row of abbreviated state flags.

Flag Indicates That

CD A card is detected in that socket.

Vcc The socket is powered up.

Vpp The programming power supply is active.

WP The card is write protected.

202

Page 203: HISTORY AND DEVELOPMENT OF LINUX22

Below the socket status data is a log of card status change events. The following events are logged:

card insertion and removal. user insert and eject requests.

suspend and resume.

socket resets.

The reset button below the socket displays sends a SIGHUP signal to cardmgr, causing all sockets to be re-initialized from scratch. Cardinfo is setuid root so that it can create temporary device files for accessing the PCMCIA sockets. An ordinary user will not be able to access any of the socket control functions.

The cardctl utility is used to monitor and control the state of PCMCIA sockets. If a socket number is specified, the command will be applied to just one socket; otherwise, all sockets will be affected. Cardctl is also used to select between multiple PCMCIA configuration schemes. The current scheme name is passed to the device option scripts as part of the device address, so that the scripts can use it to choose between different setups. If cardctl is executed by root, all commands are available. If it is executed by an unprivileged user, only the informational commands are accessible. The card control commands are listed in the following rollover.

Command Descriptionstatus Displays the current socket status flags.config Displays the socket configuration, including power settings, interrupt & I/O window settings & configuration

registers.ident Displays card identification information, including product identification strings, manufacture ID codes &

function codes.suspend Shut down & then disables power for a socket.resume Restores power to a socket & re-configures for use.resert Send a resert signal to a socket, subject to approval by any drivers already bound to the socket.eject Notifies all client drivers that this card will be ejected & then cuts power to the socket.insert Notifies all client drivers that this card has just been inserted.scheme If no scheme name is given, cardctl will display the current PCMCIA configuration schene. If a scheme name is

given, cardctl will unconfigure all PCMCIA devices & reconfigures for the new scheme.

The cardmgr utility monitors PCMCIA sockets for card insertion and removal events. When a card is inserted, cardmgr looks up the card in a database of known cards. If the card can be identified, appropriate device drivers will be loaded and bound to the card. When a card is ejected, that card's drivers will be shut down and unloaded if possible. Based on the contents of the PCMCIA card configuration database, cardmgr may also execute arbitrary commands when appropriate cards are either inserted or removed. All insertion and removal events, device driver loads and unloads, and startup and shutdown commands are reported in the system log file. Warnings and errors will also be logged. Current card and device information for each socket is recorded in /var/state/pcmcia/stab or /var/lib/pcmcia/stab. Normally, when a card is identified, cardmgr will send a beep to the console. A beep is also generated when a card is successfully configured. A beep of lower pitch is generated if either of these steps fails. Ejecting a card produces a single beep. When cardmgr receives a SIGHUP signal, it will reload its configuration file. When cardmgr receives a SIGTERM signal, it will shut down all sockets that are not busy and then exit, but drivers for busy sockets will stay loaded. If the PCMCIA_OPTS environment variable is set, its contents will be parsed after the main card configuration file is read.

Power Management:-Freedom from the wall outlet means depending on another source of power, in this case, batteries. The portable computer has methods for managing power, usually a software battery monitor, which reports the reserve power of the battery. The management system may also detect when the computer isn't being used and put it in a suspend mode to conserve power. Conserving the battery's power and extending its life are much preferable to replacing the battery.

Battery life is a major factor in judging a portable's value for the user. Most batteries will typically last anywhere from two to six hours, although this varies depending on how you are using the computer. The weight and expense of backup batteries make choosing the right battery an important decision. Several types of batteries are used, as listed in the following rollover.

203

Page 204: HISTORY AND DEVELOPMENT OF LINUX22

Battery Type DescriptionNICAD Portable computer battery made of nickel & cadmium with a 3-4 hour life. NIMH Environmentally friendly battery made Nickel Metal Hydride for portable computer. Li-lon Lithium battery with along life.Lithium Polymer Portable computer battery using a jelly-like material.Zinc Air Portable computer battery that uses a carbon membrane that absorbs oxygen.

Advanced Power Management

Advanced Power Management (APM) is an application programming interface (API) from Intel and Microsoft for battery-powered computers. It provides several power-saving options, including shutting off the display or hard drive, suspending to RAM, suspending to disk, and slowing the processor.

Suspend to RAM. Also known as Sleep Mode or Instant On. The system writes data to memory and shuts everything down while keeping the data alive with a minute amount of power from the battery. The system is immediately accessible by using certain keystrokes. This method uses a small amount of power, so data could be lost if the battery dies.

Suspend to Disk. Also known as Hibernate. The system writes data to disk and shuts off completely; no power is used, so no data can be lost. The system, while not needing to be rebooted, turns on more slowly than Suspend to RAM.

Slowing the Processor. The system is on but not involved in heavy-duty calculations. The processor slows down to a point where it can still handle the user's needs, but does not waste energy trying to process data at an unnecessarily high rate.

Rather than rewrite the HOWTOs that already exist for implementing APM on laptops, here is a list of resources you might want to check out. Section 19.7, Power Saving Techniques, of the Linux Laptop HOWTO at http://linuxdoc.org/HOWTO/Laptop-HOWTO-19.html#ss19.7 lists other ways to save power. Also, you'll want to check out the Battery Powered Linux Mini-HOWTO at http://linuxdoc.org/HOWTO/mini/Battery-Powered.html.

In order for any of the APM options described in these documents to work on your system, your BIOS needs to be APM compliant. Also, you need to have your kernel compiled to support APM. This might have been configured when you installed Linux; otherwise, you'll need to recompile the kernel to add APM support. Although not required, you might want to download the apmd package. This is a set of user-level programs to control the APM system found in all modern laptop computers and most modern desktops. apmd communicates with the Linux kernel APM layer, which takes care of all of the hardware-dependent portions of APM.

1. Of the techniques listed in this document, which are you most likely to implement on your laptop?

Ans: Answers will vary.

2. According to this document, what are some of the things BIOS can take care of by itself?

Ans: The document lists reducing the cpu clock, turning off the hard disk, and turning off the display's backlight.

3. How do you activate APM support in Linux?

Ans: Recompile the kernel to add APM support.

4. Why do you need to recompile the PCMCIA drivers after enabling APM support?

Ans: The precompiled PCMCIA drivers that come with most Linux distributions have APM support disabled, so that the BIOS can't instruct your card adapters to turn off.

204

Page 205: HISTORY AND DEVELOPMENT OF LINUX22

5. What can you do if your system doesn't support APM?

Ans: You can use hdparm -S to define your hard disk's standby period. This will already help a lot because hard disk activity consumes a lot of power.

1. What are some of the environmental factors that can affect system performance?

Ans: Magnetism, air quality, power fluctuation, and temperature.

2. What is an API?

Ans: Application Programming Interface. An extension to a programming language that defines an interface to an operating system. If an application is written for a particular API, it need only be recompiled to run on any other operating system that provides that API.

Lesson 3 Troubleshooting System Problems

Lesson Objectives

In this lesson, you will:

Explain how the chkconfig utility is used. List some of the commands used to troubleshoot problems.

Introduction:-Throughout this course you have already seen many tools and techniques that can be used in troubleshooting system problems. You used some of them to test the configuration after setting up a service and you used others as you obtained information about what was running on your system. These types of commands are also useful in tracking down problems when they occur.

Troubleshooting Configuration Files:-Another thing you will probably have to do is to examine and edit configuration files based on symptoms of a problem. You can use special system utilities in addition to the tools and techniques you already have learned.The configuration files you examined earlier can be the source of problems (or perceived problems) sometimes. You might need to change settings defined in configuration files to get your system working the way you need it to. For example, if a user can't access the FTP server, it might be because they aren't listed in the ftpaccess configuration document. Sometimes this is as it should be�the user shouldn't be able to access the FTP server; other times, you need to add the user to the list of users who can access the FTP server. If an nfs volume isn't available, make sure that you ran exportfs to export it after adding it to the exports file.

Utilities such as chkconfig and testparm can also be useful in checking configuration files. The pgrep command is also available on some distributions and can be useful in troubleshooting.

The chkconfig utility can be used to update and query runlevel information for system services. It can be used to:

205

Page 206: HISTORY AND DEVELOPMENT OF LINUX22

See the chkconfig man page for more specific information on using this command.

The testparm command is part of the Samba suite. It tests the syntax of the smb.conf file. If there are any sections that contain incorrect or missing information, you will be notified of this by the testparm command. If it doesn't find any problems, Loaded Services File OK is displayed; otherwise, it lists the errors so that you can fix them. It will also display a dump of your service definitions after this. This is a long listing of default services and the services that you defined.

Configuration Files:-Most configuration files are located in or below the /etc directory. They usually have the file extension .conf, .cfg, .config, or .cf. While the default settings are often appropriate, on some systems, you might need to modify these files.

1. Where are most configuration files located?

Ans: In or below /etc.

2. List two commands you can use to check configuration files.

Ans: chkconfig can be used to check system services and testparm can be used to check the configuration of the Samba configuration file smb.conf.

3. What is the pgrep command used for?

Ans: The pgrep command is used to look up or signal processes based on name or other attributes you specify.

The LILO Boot Process:-LILO boots itself in two stages, each of which is composed of several smaller processes. As the boot process progresses, additional letters of the four-letter prompt are displayed. When LILO has fully loaded itself, it displays the LILO: prompt.

During the first stage of boot, LILO moves itself into a memory address and sets up the stack. It then loads the secondary boot loader, and transfers control to it. Once the secondary boot loader has been started, it continues the boot process and displays the LILO: prompt.

If LILO does not successfully load, it will freeze at a certain point in its display. The following animated tip shows each of the steps of the display and boot process, and potential troubleshooting points at each step.

206

Page 207: HISTORY AND DEVELOPMENT OF LINUX22

1. When LILO has fully loaded itself, what is displayed?

Ans: The LILO boot prompt.

2. What happens during the first stage boot?

Ans: LILO moves itself into a memory address and sets up the stack. It then loads the secondary boot loader, and transfers control to it.

3. If only the letters LI of the LILO boot prompt are displayed, what happened? Why?

Ans: The first and second stage boot loader loaded, but the second stage boot loader couldn't execute. This is most often caused by a geometry mismatch.

4. If the second stage boot loader can't be loaded, what is displayed?

Ans: L followed by a two-digit error code.

Starting and Stopping Processes to Locate and Correct Problems:-As covered earlier in the course, both services and processes can be stopped and restarted. This sometimes can be used to fix problems. You can use the ps command along with the grep command to locate processes that you need to check on. You can then kill the process if necessary.

The pgrep command is used to look up or signal processes based on name or other attributes. It looks through the currently running processes and lists PIDs that match the criteria you specify. Following are two examples. The command pgrep -u root sshd lists only processes called sshd and that are owned by root. The command pgrep -u root,daemon lists all processes owned by root or daemon.

The pkill command can be used in conjunction with the pgrep command to stop processes. Starting and stopping processes is just one more way you can attempt to troubleshoot problems. When you see a certain symptom, such as a process taking too long, you should check on the process using ps or pgrep; then if necessary, end the process using kill or pkill. Then, you should examine the process (the script or other command sequence associated with that process) and check for any problems. After fixing any problems, you should try running the command or script again. Check on it periodically to see if it is working properly.

Using System Status Tools to Examine System Resources:The fsck command is used to check and optionally repair Linux filesystems. The fsck program tries to run filesystems on different physical disk drives in parallel to reduce the total amount of time to check all of the filesystems. The exit code returned by fsck is the sum of the following conditions:

207

Page 208: HISTORY AND DEVELOPMENT OF LINUX22

0: No errors 1: Filesystem errors corrected

2: System should be rebooted

4: Filesystem errors left uncorrected

8: Operational error

16: Usage or syntax error

128: Shared library error

fsck is a front-end for various Linux filesystem checkers. The filesystem-specific checker is searched for in /sbin first, then in /etc/fs and /etc, and finally in the directories listed in the PATH variable. See the man page for information on the options available for this command.

The setserial command can be used to set and report the configuration for a serial port. This information includes the I/O port and IRQ the serial port is using. It can also specify whether the Break key should be interpreted as the Secure Attention Key.

Follow the steps below to learn how to use system status tools.1. Insert a Linux-formatted disk in the drive, but don't mount it.2. Enter fsck /dev/fd0. Hopefully, you found no errors.

3. Remove the disk and replace it with a DOS-formatted disk.

4. Run fsck again. This time you should have gotten some errors.

5. Enter setserial /dev/ttyS0 to display the configuration information for the first serial port (in DOS terms, known as COM1).

6. Display the serial port information for the rest of the serial ports. Compare the similarities and differences between each one. ttyS0 and ttyS2 have the same IRQ and ttyS1 and ttyS3 have the same IRQ, but they all have different Port numbers. Some might also have a UART number.

Tools for Fixing Filesystem Problems:-Using the command fsck -r /dev/filesystem (where filesystem is the filesystem to repair) interactively repairs the filesystem. You will be prompted to confirm actions. If you are simultaneously checking multiple filesystems, you shouldn't use this option. You should repair a single filesystem at a time.

The du command is used to display an estimated file space usage. With no arguments, du reports the disk space for the current directory. Normally the disk space is printed in units of 1024 bytes, but this can be overridden using the Block size option. The -c option lists the total of all the files and the -h option adds a letter to indicate k (kilobytes) or M (MB). These are useful options in making it more readable. By default, it just does the current directory (and its subdirectories), so if you want the count for the entire filesystem, go to the root of the filesystem (/) then enter du -ch and you'll get a total for everything.

The df command is the opposite of du. The du command showed how much space was used. The df command shows you how much is available.

208

Page 209: HISTORY AND DEVELOPMENT OF LINUX22

Results of the df command.

The fstab file contains descriptive information about the various filesystems. It is only read by programs and not written to by them. The system administrator is responsible for creating and maintaining this file. Each filesystem is described on a separate line.

A sample fstab file.

The first field specifies the device to be mounted. The second field specifies the mount point for the filesystem. The third field specifies the filesystem type. The last two fields specify whether the filesystem contents need to be dumped and how and when the filesystem is checked on reboot.

The stat command displays status information about a file or filesystem. Using the -f option with stat displays information about the filesystem the file is located in rather than on the file itself. The syntax of the command is stat filename or stat -f filename.

Output from the command stat /.

Output from the command stat -f /.

Notice that when you are getting information on a specific file (or in the above case a directory), the last access, modify, and change date and time are listed. This can be useful in tracking down what happened when to a particular file.

The sync command is used to flush filesystem buffers. This writes any data buffered in memory out to disk. The kernel improves performance by keeping data in memory to avoid slow disk access. However, if your system crashes, data can be lost and the filesystem might also be corrupted. Using sync to write everything to disk can help minimize the potential problems.

Follow the steps below to learn how to fix filesystem problems.

Insert a Linux-formatted disk in the drive.

209

Page 210: HISTORY AND DEVELOPMENT OF LINUX22

Examine the fsck man page, then return to the command line. Be sure to examine the status codes. Error 0 indicates that there were no errors found. Error 2 indicates that the filesystem should be rebooted.

Enter fsck -r /dev/fd0 to repair the filesystem. You should get a 0 or a 2 as the returned value.

Enter fsck.ext2 /dev/fd0. It should have been clean.

Change to your home directory, and then enter du -ch to display a usage summary for your home directory. The c option specifies that the results are totaled up for you and the h option adds the letter after the number to make it more readable. The following graphic shows the last few lines of the output from this step. Notice that the k and M are very useful here in telling the size of the files and directories.

Enter df to list the free space on all mounted filesystems

Identifying Some Useful Troubleshooting Commands:-Some other commands that might come in handy in troubleshooting problems include ping, traceroute, netstat, route, and lsof. Let's look at how these might be used in your bag of troubleshooting tricks and tools.

Troubleshooting with ping and traceroute:-If you have a client who is unable to access another system, you might try using ping and traceroute to troubleshoot this problem. ping can be used to determine if the other system is running and traceroute can be used to determine how far down the line the problem is occurring that is preventing the user from accessing the other system.

If the other system is running, you should receive a response right away when you ping it. Try issuing the ping command from another system to see if you can reach the other system. Then, have the client who is experiencing the problem try pinging the other system. They will probably get the message Destination Host Unreachable. Then have the client issue a traceroute command to the other system to see how far the system gets before receiving the Destination Unreachable error message. Using the IP address of the last successful connection, you'll know where to begin troubleshooting the problem, and hopefully even which device is causing the problem.

Troubleshooting with netstat and route:-If a user is having trouble using a TCP/IP-based program, such as an SMTP messaging system or an FTP server, you might consider checking out this problem using netstat -a. For example, if you find that users can't send or receive messages from the email server, enter netstat -a to find out if the system is listening on the expected port. Then, you can check to see if the messaging system is up, or if it needs to be restarted.

The -a option is used to check active connections. A good TCP connection usually has no bytes in the send or receive queues.

You can also check Ethernet NIC error counts. If the error count is up, check to see if this indicates a problem (or it might just be a very busy network with lots of collisions). You can also check routing tables for network routing problems through netstat.

The route command is used to manipulate the IP routing table on your system. By itself, with no options, it displays the current routing table. If for some reason route can't display it, the same results can be had using netstat -rn.

The lsof Command:-The lsof command lists all open files belonging to all active processes. You can specify that it lists only certain files to make the output more manageable if you want. The -U option specifies only UNIX socket files are listed or -N specifies only NFS files are listed. The -u username option specifies to list only the open files for the specified user.

1. A client calls from the California office saying that he or she is unable to connect to the server ICANY in New York. This server is on a routed IP network. This is the second client from California who has called with this problem. No users from other sites have called. What should you do?

Ans: Try pinging the server from your system. If you are able to successfully reach the server, ask the client to do the same and see if he or she gets a response that the server is available. (He or she will most likely get a Destination Host Unreachable message.) If the client can't connect, have he or she enter traceroute icany to see how far they can reach before receiving the error message. You'll then be able to figure out which device is causing the problem, because the next device that would be encountered on the route between the client and ICANY is the problem device

210

Page 211: HISTORY AND DEVELOPMENT OF LINUX22

2. You're a network administrator and have been receiving complaints that users aren't able to post files to or download files from the FTP server. What might you do to determine the status of the server?

Ans: You could log in to the FTP server and enter netstat -a to see if it is listening on Port 21. You might also try to telnet into the system to see if you get a "ready" message.

3. You tried to display the route table, but you got an error message. What is another command you could try to use that would display the same information?

Ans: netstat -rn

1. What is the chkconfig utility used for?

Ans: The chkconfig utility can be used to update and query runlevel information for system services. It can be used to add new services for management; remove services from management; list current startup information for services; change the startup information for services; and check the current startup state for a particular service.

2. What are some of the commands used to troubleshoot problems?

Ans: Commands might include: fsck, setserial, du, df, stat, sync, ping, netstat, route, traceroute, and lsof.

Lesson 4 Troubleshooting Application and Package Problems

Lesson Objective

In this lesson, you will:

List some causes of RPM archive errors.

Introduction:-You might be called on to determine the reason an application failure occurs on the server. This might be problems with a Web page, accessing servers through telnet, your FTP server, POP3 services, or SMTP services.

The following animated tip shows various services and the related components you would need to check when problems occur.

If any of the configuration files for these services becomes corrupted, or gets renamed or deleted, you will have problems. You can use your troubleshooting skills as well as RPM validation tools to check for problems. Invalid parameters within the files can also lead to problems.

If the files that load the service are not loaded into memory, the service won't be available. Users won't be able to access the service (for example, Web pages won't be available if the httpd daemon isn't loaded). You'll often realize you have a problem when users start logging complaints with your support team or help desk. You should then use your troubleshooting skills to evaluate whether the problem is with the user, the network, or the services on the server.

211

Page 212: HISTORY AND DEVELOPMENT OF LINUX22

Common Server Configuration Errors:-Incorrect configurations represent one of the biggest classes of errors found on a normal network. This type of error could include installing or setting up a program or piece of hardware incorrectly, executing commands in the wrong order, or missing steps altogether.

Configuration problems can result from a limited understanding of the processes involved. Read the documentation for your software and hardware thoroughly before attempting to install them. This will minimize your configuration-related problems. Even so, configuration problems can still occur. For example, you might forget to mount a drive before attempting to access software from it. You might attempt to load a driver that is not present on the current partition. Your startup files might attempt to load modules in the wrong order. When you are having problems, or when you are installing new components, carefully watch the console as the system boots. If error messages are displayed as the system is booting, investigate them immediately.

If possible, compare the files you load automatically during the boot process with those from another working system. Keep copies of the working version of those files, or keep printed records of the files' contents. These backup files or printed records should be kept in the log book detailing your server.

1. What issues do you need to be concerned with regarding configuration files?

Ans: That the files aren't corrupted, renamed, or deleted, and don't contain invalid parameters.

2. How might you detect problems in configuration files?

Ans: Using RPM validation options, using your troubleshooting skills to evaluate whether the configuration file for the affected application has been corrupted or tampered with, and if applicable, using tools such as chkconfig or testparm to check on the configuration files.

3. A user calls in to the help desk saying that he or she can't access the Samba share on the Linux system. One other user calls right after the first user, but no other users call in about this problem. How would you go about determining what and where the problem is?

Ans: Using your troubleshooting skills, determine whether the problem is with the hardware (a problem with a router or other networking device) or the operating system; check that the daemons are loaded on the server, whether the configuration has changed, and if there is an invalid parameter in the configuration file (use testparm to check); and determine if the users are correctly trying to access the share.

Identifying Common Package Problems:-When you go to install a package, you might have any one of several problems. These include dependencies, library errors, and version conflicts. Let's look at why you might get such an error and how you would go about resolving it.

Some packages can't be installed unless you install another package. This is referred to as a dependency.

When an RPM package is created, you can specify an option called conflicts. If a package is known to not work with another package, the Conflicts tag can be added to the package. When you go to install the package, if it finds the conflicting package installed on your system, it will print a conflict message that says it won't work with this other package installed on the system. For example, qmail doesn't work (without custom setup) on machines with sendmail installed. To override this message, use the --nodeps option.

Let's look at RPM library errors. By default, RPM uses the rpm executable and a dynamically loaded library. This means that if the executable and the library are out of sync, then RPM will not be able to run. This is extremely rare. Another problem you might encounter is RPM archive errors. That is, you run rpm -i xxx and it fails. There are several issues you should look into if this fails:

212

Page 213: HISTORY AND DEVELOPMENT OF LINUX22

The RPM Finder Web site at www.rpmfind.org can be useful in locating packages. This saves you time and helps you locate packages.

1. A user wants to use the new Zorgon database application. What would you need to do to make it available to the user?

Ans: Locate the application on CD, the Web, or elsewhere. You can use a web site such as rpmfind.org to help you locate it if it is available as an RPM package. Extract and install the package (rpm -i -p zorgon.rpm). If it is available as a tarball, unpack the distribution using gunzip -c zorgon.gz | tar xvf zorgon.tar. Change to the directory where it was untarred to then read the README or INSTALL documentation, then carry out the instructions found in the file.

2. A user needs to use sendmail, but has been asked by their management team to evaluate qmail. You know from your research that these two packages conflict. How can you install both packages on the user's system?

Ans: You can configure qmail to work along side sendmail or you can install qmail with the --nodeps option to override the conflict error message.

3. You downloaded the zorgon.rpm from the Web and attempted to install it on the user's system. When you did so, you encountered RPM archive errors. What are some of the issues you should look into in attempting to resolve the problem?

Ans: Corrupted RPM archive file. Programs already installed, or missing parts of installed programs. Missing dependent programs, libraries, and so forth, or you need an updated version of these programs, libraries, and so forth. Corrupted RPM installed program database (which can lead to the previous point and much wringing of hands when you discover that all of the installation information has disappeared).

1. What are some causes of RPM archive errors?

Ans: Corrupted RPM archive files; programs already installed or missing parts of installed programs; missing dependent programs or libraries having older versions of these programs or libraries; having a corrupted RPM installed program database.

Lesson 5 Troubleshooting the Linux Operating System

Lesson Objective

In this lesson, you will:

213

Page 214: HISTORY AND DEVELOPMENT OF LINUX22

Define a core dump and explain how it can be useful in troubleshooting a problem.

Introduction:-Another area you will probably need to address is troubleshooting and keeping the operating system itself up to date. This can involve anything from recompiling the kernel to evaluating core dumps.

Like any complex operating system, Linux needs to be configured to meet your exact needs. Incorrect configurations can lead to problems. The daemons installed in your system need to be compatible. Also, due to its complexity, some problems exist with the operating system itself.

Forgotten root Passwords

If you forget your root password, at the Linux boot prompt, enter linux single to boot into single user mode. At the # prompt, enter passwd root to specify a new root password. You can then reboot the system into normal mode and log in using the new password.

Recompiling the Kernel:-Eventually, administrators will need to recompile the kernel for a variety of reasons. To add or remove device drivers, you will need to recompile the kernel. You should remove device drivers that you don't use in order to free up memory for other applications. If a new kernel is released that you want to use on your system, you will need to recompile to update the kernel to this new version.

If you want to update your kernel version, you can download an official kernel source from the Internet. It is stored as a gzip tar file. After downloading (or obtaining the kernel from another source), you need to unpack it. From the /usr/src directory, move

the directory linux to linux.old (or some other name). Then, enter tar -xvf kernel.tar.gz. (kernel will be the version of the

214

Page 215: HISTORY AND DEVELOPMENT OF LINUX22

kernel you are about to install; for example, v2.2.0.) This will create a new linux file containing the new sources.

TIP: In some distributions, instead of being named linux, the directory will be named after the distribution; for example, RedHat.

Rebuilding the Kernel:-To rebuild the kernel, either with new sources or just to add or remove drivers, you need to complete the following steps. You should run all of the following commands from the /usr/src/linux directory.

Follow the steps bellow to learn how to rebuild the Kernel

Run make config. You will be prompted with a series of questions about the drivers to be included in the kernel. Press the Enter key to accept the default; enter y or n to answer yes or no to questions. Some questions require you to enter a number or other value; some questions require an m as the answer compiled as a loadable kernel module instead of being compiled directly into the kernel.

Run make dep. A series of commands is run that gathers source file dependencies and adds information to the various makefiles. It walks through the directory tree to gather this information. This should take about 5-10 minutes to complete.

Run make clean. This command makes sure that all object files created from previous kernel builds are removed from the source tree. This is a good practice so that you will be creating your kernel from scratch and no old files will be accidentally included in your new kernel.

Run make zImage. This command actually compiles the kernel. It might take only a few minutes, or it could take several hours. It is best to do this when there aren't users on the system because it slows things to a crawl. The amount of RAM is key to determining how fast the compile occurs; fast and slow processors don't have much impact on the speed�it's a matter of having enough RAM for it to occur quickly.

Copy the new kernel image to a boot disk or configure LILO to boot the new kernel from the hard drive.

You can string these commands together with semi-colons so that they run one after the other. However, if you do so, you should check on the progress periodically in case an error occurred so that the next command couldn't run

1. What are some reasons you might need to recompile the kernel?

Ans: To add or remove device drivers, thus freeing up memory for applications; to update to a new kernel; to fix problems.

2. If you are upgrading to a new kernel, what do you need to do?

Ans: Obtain the new kernel from an official source such as the distribution web site for your Linux distribution; move the linux subdirectory tree to another name such as linux.old; untar the gzip file you obtained using tar -xvf kernelversion.tar.gz.

3. List the main steps to rebuild the kernel.

Ans: Run make config. Run make dep. Run make clean. Run zImage. Copy the new kernel to the boot disk or point LILO to the new kernel on the hard drive.

4. How can you automate rebuilding the kernel somewhat?

Ans: String the commands together with semi-colons.

215

Page 216: HISTORY AND DEVELOPMENT OF LINUX22

Core Dumps:-When an application crashes, a copy of what was in memory (a memory image) is placed in a core file in your directory. Another name for a core file is a core dump, because a dump is a copy of what's in one location copied to another location. The name of the file containing the dump is core.

In some systems, core files are not written by default. To enable output of core files, enter ulimit -c unlimited. This code can be added to the .bashrc file so it is always available. If you want to limit the size the core file can take up, change unlimited to the maximum size. This may not be as useful in troubleshooting though, becuase you might not have all of the data that was in memory when the crash occurred.

The GNU Debugger, gdb, enables you to step through programs written in C, C++, or Modula-2 to track down where the program is broken. This can be useful in figuring out what is wrong with an application and causing a core dump to occur. This utility can be downloaded and installed on your system to assist you with your troubleshooting. For more information, refer to the documentation that comes with the utility.

The following rollover lists some of the reasons for core dumps.

Reason Occours Whenmemory violations An attempt is made to read or write to memory the programs does not have access to.segmentation faults Attempting to write data into a null pointer. Often occurs when pointers are not initialized.bus error Data is not correctly aligned. Usually does not occur on intel systems, but more common on

SPARC architecture.floating point exceptions Divide by zero or calculation averflow occurs.

The core file can be quite large. If you get enough core dumps on your system, your drive space can get eaten up quickly. If you can't figure out the problem yourself, you should send it to someone who can figure out what the problem is. You will most often send it to the program's creator for examination. Then you should remove the file from your system. If you resolve the issue yourself, don't forget to remove the file after you are done.

1. What is a core dump?

Ans: A core dump is a copy of memory dumped to a file named core.

2. What are some causes of core dumps?

Ans: Some causes of core dumps include memory violations, segmentation faults, bus errors, and floating-point exceptions.

3. For some reason, core dumps have been disabled on your system. How would you re-enable them?

Ans: With the command ulimit -c unlimited or specify a maximum size of the core file.

4. Why might you not want to limit the size of core dumps?

Ans: If the core dump is larger than your file size, then you won't get all of the information that was in memory, so you won't have an accurate picture of the situation when it occurred. Valuable information might be missing.

1. What is a core dump and how can it be useful in troubleshooting a problem?

Ans: A core dump is a copy of memory dumped to a file named core. This file can give clues as to what was happening when the problem occurred.

CHAPTER 18 Preparing for a Linux Installation

216

Page 217: HISTORY AND DEVELOPMENT OF LINUX22

Lesson 1 Gathering Installation Information

Lesson Objectives

In this lesson, you will:

Explain where to find information about your hardware for an installation. Explain where to find information about your network.

Introduction:-Before you install Linux, you should gather information about the hardware and network on which you will be installing your system. Much of this information is available in your system documentation.

You should also check the hardware support list for your version of Linux to be sure it is supported. If it is not, you might run into problems installing Linux. If you still want to install it, you might need to write your own driver software to make it work.

On newer systems, the Linux installation program often automatically identifies your hardware. It is still a good idea to gather the information ahead of time just in case it doesn't figure out what you have.

One way to gather information is to view the CMOS or diagnostic information available at system boot time. Cold boot your system and display setup or diagnostic information. This is displayed in different ways on different systems. For example, on most Compaq systems, when the block cursor moves to the upper-right corner of the screen, press F10. On some systems, when the View Setup/Diag message (or a similar message) is displayed, you press Delete (or the key indicated in the message).

On systems running Windows 95/98, you can use the System Properties window to gather information about your system. Display the Device Manager page, and then verify that the View Devices By Type option button is selected. Expand each item to view information about the device. Click on the Properties button to display information such as device type, manufacturer, hardware version, and resource settings (IRQs and so on).

Access to manuals that came with the equipment can often be one of the best ways to find out about components. Manufacturer's Web sites also often contain valuable information about equipment.

If you don't have the documentation and you don't have an application or a utility to provide this information, you will need to open the case and look inside. Many cards, boards, and components have manufacturer and model information printed on them. However, they probably will not have a guide to interpreting the jumper settings.

If your workstation will be connected to a network, you'll also need information about the network address to be assigned to your computer. Some systems will have a permanent network address and others will obtain a network address each time they access the network. Contact the system or network administrator to find out how to set up your system.

1. List at least three ways of gathering information about the hardware on which you will be installing Linux.

Ans: Opening the case and looking at components to find chipset, brand, version, and so on; using Windows 95/98/NT System Manager information; searching manuals for the components.

2. What other information will you need besides information about the hardware? Where will you get this information?

Ans: Network address information, including static IP address or DHCP information; domain name; host name. You can gather this information or it should be available from your network administrator.

Hardware Information

1. In this exercise, you will gather information about your computer system. To do so you can use any of the resources discussed above (plus any others you might have available). Record your findings in the following table.

  Component   Comments   System Contains

217

Page 218: HISTORY AND DEVELOPMENT OF LINUX22

  Hard drive   Hard many devices are   installed? (If more than one   drive is installed, record the   information for each drive and   then identify the order of the   drives.) Is it IDE or SCSI? (If   it is IDE, check your computer   BIOS to determine if it is   accessed via LBA or large   disk mode.) How large is the   dirve? How many cylinders   are contained on the drive on   which Linux will be installed?

 

  Hard disk controller   IDE? SCSI? Manufacturer?  

  Memory   Amount of RAM installed?  

  CD-ROM  Interface type: IDE, SCSI,   other? (If it is not IDE or   SCSI, you will need to record   the make and model.)

 

  SCSI adpater   Make and model?  

  Network card   Make and model?  

  Mouse   Mouse type: Serial, PS/2 bus   Protocol: Microsoft, Logitech,   MouseMan, other? Number of buttons? (If it is serial, you will   need to record the serial port   to which it is connected.)

 

  Display adapter   Make and model? Chipset   used? Amount of video RAM?  

  Monitor   Make and model? Horizontal   refresh rate range? Vertical   refresh rate range?  

  Sound card    

  Game controller    

Gathering Network Information:-Network information is best gathered from your network administrator or the group responsible for assigning IP addresses. You will need this information only if you are installing from or connecting to a network.

The following information discusses IP addresses in general. You might have a fixed or static IP address that is assigned to your machine permanently. Alternatively, you might have a dynamically assigned IP address from a DHCP server, which might or might not change each time you boot your system.

Hosts and networks are identified by IP addresses. An IP address consists of four numbers separated by dots, as in the address 155.40.104.49.

You can tell a lot about an Internet host by looking at its address. In general, the numbers on the left side of the address (for example, the first two numbers�155.40) identify the network on which a host resides, and the numbers on the right side of the address (104.49 in this example) identify the host itself.

If your network is private (not connected to the Internet), you can use virtually any network address for a network. But if you want to connect to the Internet, you must be sure that your network address is unique. To do this, you must apply for a registered address. Internet addresses are centrally maintained to guarantee that no addresses are duplicated. The simplest way to get an IP address is through an Internet Service Provider (ISP).

Address Classes:-The Internet was designed to support five types, or classes, of networks, with the following three being the most common:

These classes are implemented by using varying portions of the four numbers in the IP address to identify networks and hosts. For example, a Class A IP address uses only the first number of the IP address to identify the network address and the remaining three numbers to identify hosts. This network class can support a lot of hosts.

218

Page 219: HISTORY AND DEVELOPMENT OF LINUX22

In contrast, a Class B IP address uses the first two numbers of the IP address to identify the network and the remaining two numbers to identify hosts. This means there can be more Class B networks on the Internet than Class A networks, but it also means that a Class B network can support fewer hosts than a Class A network.

TIP: Note that although the host address portion of the IP address must be unique, the network address portion must be the same for all hosts on the same segment of the network.

Class C networks use the first three numbers to identify the network, and the last number to identify hosts. Thus, they support fewer hosts than Class A or Class B networks, but there can be a lot more Class C networks than Class A or B.

To keep IP addresses unique on the Internet, certain ranges of addresses have been reserved for Class A, B, and C networks. You can examine the first number of the IP address to determine what type of network an IP address refers to. The following animated tip lists the ranges of network addresses for each network class, shows how many networks are available for each class, and shows how many hosts can be on each type of network.

Some IP addresses have special uses and cannot be assigned to networks and hosts. For example, the IP address 127.0.0.1 is reserved for testing purposes. It identifies you your network and host. The command is used to determine if TCP/IP is �functioning properly. It pings yourself.Host Addresses:-The host portion of the IP address is used to uniquely identify each computer on a network segment, just as your house number uniquely identifies your house on your street. The host address must be unique for each network address. For example, you could use 130.4.67.8 and 130.4.45.34 for two hosts in your network. They have the same network address (130.4), but unique host addresses (67.8 and 45.34). All TCP/IP-based systems must have unique host addresses, including all computers, network cards within routers, and printers with network cards.

TIP: Note that although the host address portion of the IP address must be unique, the network address portion must be the same for all hosts on the same segment of the network.

Private Network Addressing:-If you have a private network (with no registered Internet addresses), you can use the following address blocks reserved for private networks:

219

Page 220: HISTORY AND DEVELOPMENT OF LINUX22

The Default Gateway Address:-The host address assigned to an IP router's network card is particularly important because this address is configured as the default gateway for all computers on that network segment. The default gateway address is the network segment's access point to all other remote networks, and therefore, the connection to the Internet.Rules for Host Addressing:-The following guidelines apply when assigning the host portion of an IP address:

Each host address must be unique to the local network.

The host address numbers cannot all be 0. Zero always refers to the network address. For example, if the network address is 100 (Class A), and the host bits are all 0, then the resulting IP address is 100.0.0.0. This IP address is invalid for a host because it is reserved for the network address.

The host address bits cannot be all 1s (a decimal value of 255 for each byte). If all host address bytes are set to 255, the transmission is thought to be a broadcast�a message sent to all hosts on the network.

The following animated tip outlines the range of valid network addresses.

Obtaining a Registered IP Address:-If your network is strictly private and does not connect to the Internet, you can select any IP network address you want. However, if your network connects to the Internet, you must register its IP address. The Internet Corporation for Assigned Names and Numbers (ICANN) is a non-profit corporation responsible for IP address allocation, protocols, domain name management, and other functions previously performed by IANA and InterNIC. ICANN and its representative agencies usually assign large blocks of addresses to large Internet Service Providers (ISPs). These ISPs distribute the addresses to smaller ISPs who then pass them on to users.

TIP: Direct Internet connections require registered addresses.

You can get an IP address from an ISP, or if you need a large block of addresses (because you are an ISP, for example), you can apply to one of the following national registries:

220

Page 221: HISTORY AND DEVELOPMENT OF LINUX22

The registry assigns the network portion of an IP address to your company. You usually will be able to select your own host addresses for the assigned network address.

To find an ISP, check in your local Yellow Pages under "Internet Service Providers," or enter "Internet Service Provider" in a search engine such as Yahoo!, Google, or HotBot.

IP Version 6:-The IP protocol has been largely unchanged since the 1970s. It has begun to show its age. Among other problems with IP4 is its limited number of IP addresses. More addresses are needed to keep up with the incredible demand for Internet access.

For this reason�and several others�a new version of IP, called IP Next Generation (IPng) or IP Version 6 (IPv6) is being implemented on the Internet. IP Version 6 will enable ICANN to assign a greater number of addresses. IP Version 6 includes an entirely new packet structure that is incompatible with previous versions of IP.

Dynamic Host Configuration Protocol (DHCP):-IP addresses can be assigned manually, automatically, or dynamically. A DHCP server can be set up to hand out IP addresses on an as-needed basis. This can be helpful to administrators in maintaining a fixed set of IP addresses.

Manual Allocation:-The administrator visits each host (or tells you the number) and assigns a permanent IP address. Hosts can be either workstations or servers. Smaller organizations that have plenty of IP addresses for workstations and servers often use this method. When IP address assignments need to change, this method requires higher maintenance by the administrator.

Automatic Allocation:-By using automatic allocation, the DHCP server assigns a permanent IP address to the host. The administrator doesn't need to visit each machine. While this method reduces the amount of administrative time, it does require an adequate supply of IP addresses.

Dynamic Allocation:-By using dynamic allocation, the DHCP server assigns a temporary IP address to the host. The administrator doesn't need to assign the IP addresses and a limited number of IP addresses serves a larger organization. When the workstation boots, it requests an IP address from the DHCP server, along with other information, such as DNS server IP address, gateway IP address, and subnet mask. The DHCP server takes an address from a pool of IP addresses and gives it to the workstation to use temporarily. The administrator can configure how long you lease the address.Domain Names:-Many people who use the Internet would not know an IP address if they saw one. Most Internet users, however, are familiar with addresses that look like this:

www.yahoo.com or http://www.yahoo.com

A URL such as http://www.yahoo.com is much easier to recognize than one such as 204.71.200.74 even though both (at least at the time this was written) refer to the same host.

To make Internet addresses easier to work with, the Domain Name System (DNS) was developed. DNS translates between meaningful host names and IP addresses.

To connect to a site (and thus a server), you could type an IP address into a browser's Location field, but because strings of numbers are generally harder to remember than names, names are usually used. Also, a name can stay the same if an IP address changes, so the name will always take you to the correct site.

221

Page 222: HISTORY AND DEVELOPMENT OF LINUX22

DNS Hierarchy:-DNS organizes networks and hosts in a hierarchical tree structure, much like a company's organizational chart. The structure begins at the root and is followed by the top-level domains that are divided into categories, such as .com and .org.

The top-level domains contain other domains that represent organizations (such as ZD, GO, Novell, and Netscape). These can be further divided into subdomains. (Domains nested in other domains are sometimes referred to as subdomains.) Typically, subdomains are further divided and branch out to include more domains and subdomains. To identify a single computer, you string all of the domain and subdomain names together, separated with periods, as in: roch.go.com. Top-level domains include those found in the following rollover.

Internet Domains Used ByINT(international) International organizations, organizations created by international trearies.GOV(Government) U.S. government agengies.MIL(Military) U.S. military.COM(Commercial) Corporations.EDU(Educational) Educational institutions.NET(Network) Inetrnet Service Providers (ISPs).ORG(Organizations) Miscellaneous other organizations, such as non-profit & religious organizations.XX Contries. Two-letter codes for each country, for example, NZ (New Zealand) & GR (Greece).

Following are some examples of Country code domain names.

Two-letter Code Country

AU Australia

BI Burundi

BR Brazil

CA Canada

222

Page 223: HISTORY AND DEVELOPMENT OF LINUX22

DE Germany

GR Greece

IE Ireland

JP Japan

KR Korea

NZ New Zealand

UK United Kingdom

US United States

DNS Names

DNS names must be unique. A period is used to separate the labels (names in the path). However, there is no period at the beginning of the name. There is a period at the end of the name, but people often omit it. Domain names are not case-sensitive and can be as long as 255 characters. (However, sometimes a filename at the end of the domain name is case-sensitive.) Each label cannot exceed 63 characters. An example of an absolute or fully qualified domain name (FQDN) for the ROCH domain is roch.go.com

Acquiring a Domain Name:-Having a domain name enables you to provide others with an easy-to-remember address for your Web site. Without your own domain name, you might need to provide a URL that contains an IP address, such as 24.93.10.298/widgets/home.htm, or that includes an ISP's domain name, such as home.rochester.fastbird.com/widgets/home.htm. With your own domain name, these long URLs could be shortened to something like www.webwidgets.com.

To get a domain name, you can usually go through your ISP. However, not all ISPs offer that service. In that case, you must apply for a name through one of the domain name registrars. For more information, visit a domain name registry service such as http://nsiregistry.com, www.networksolutions.com, or www.register.com. Use your search engine to find a list of other registrars.

Making the Connection:-There are many different ways to connect a computer to the Internet. Although the general ingredients are the same, the specific ingredients vary wildly, depending on the approach you choose. In some cases, the entire Internet connection is sold as a single, slick product that is neatly packaged, with a simple plug-and-play installation process that obscures the technical details from the installer or end-user. In other cases, you almost need a degree in Electrical Engineering to make the connection. In general, every Internet connection involves:

1. If your network consisted of 200,000 individual computers worldwide, what class of IP address would you need to directly connect each computer to the Internet?

223

Page 224: HISTORY AND DEVELOPMENT OF LINUX22

Ans: Class A: one network with many hosts.

2. What is the network address of 127 used for?

Ans: An alias for this network, it is typically used for testing the configuration of TCP/IP.

3. If you plan to connect your network to the Internet, what are the restrictions for assigning your IP addresses?

Ans: You must obtain valid IP addresses from an ISP. You can't choose your own network address. You must choose a unique host address for each machine on the Internet.

4. How do you calculate the available number of host addresses for a Class B address?

Ans: 2 raised to the number of bits available to vary. Because Class B addresses have 2 bytes or 16 bits available for the host address, the formula is 216-2 or 65,534.

5. Why is a host address of 255 not allowed?

Ans: The 255 address is used to identify broadcasts on the network.

6. Why is a host address of 0 not allowed?

Ans: The 0 address is used in combination with the network address to identify network segments for routing purposes.

7. What is DNS?

Ans: The Domain Name System (DNS) is a shared database system that assigns or translates host names to IP addresses for computers on an internetwork, and, more specifically, the Internet.

8. What are some examples of top-level domains?

Ans: Answers might include int, gov, mil, com, edu, net, and org.

9. Create a fully qualified domain name for the R&D department of the GNS corporation.

Ans: gns.com or rd.gns.com might be possible answers.

10. What is DHCP?

Ans: The Dynamic Host Configuration Protocol is used to centrally administer the assignment of IP addresses, as well as other configuration information such as subnet masks and the address of the default gateway. IP addresses are assigned to clients dynamically.

Gathering Network Information

If your workstation is connected to a network, you will need an IP address to access the network. Your instructor will let you know whether you are using static or dynamic IP addresses. If your computer is currently configured to access the network, you can use the Windows 95/98 winipcfg /all command to view the current settings. If your system is currently configured as a Linux system, you can use the ifconfig, netconfig, and linuxconf commands to gather information.

1. If you will be using a fixed IP address, record network information in the following table.

224

Page 225: HISTORY AND DEVELOPMENT OF LINUX22

  Network Component   Value

  IP Address  

  Netmask  

  Gateway IP Address  

  Name Server IP Address  

  Domain Name  

  Host Name  

2. If you are configured to automatically obtain an IP address using DHCP, record the current settings in the following table.

  Network Component   Value

  Current IP Address  

  Current Netmask  

  Default Gateway IP Address  

  DHCP Server  

1. Where can you find information about your hardware for installation?Ans: CMOS, Windows Control Panel, documentation, and on the hardware itself are some of the locations where you can gather information.2. Where can you find information about your network?Ans: Network information is best gathered from your network administrator or the group responsible for assigning IP addresses.

Lesson 2 Creating Installation Disks

Lesson Objective

In this lesson, you will:

Identify the utilities that can be used to create installation disks.

Introduction:-There are several sources from which you can install Linux. Depending on the source you are using, you will need to create one or more installation boot disks. If you are installing from a CD-ROM or from files copied to a DOS (or other) partition on your system, you will need to create an installation disk from the BOOT.IMG file. If you are installing from a network using FTP, HTTP, or NFS, you will need to create an installation disk from the BOOTNET.IMG file.

You can create disks from either a DOS/Windows or a Linux system. On a DOS/Windows system, these disks are created using the RAWRITE.EXE utility included in the DOSUTILS folder of the Linux distribution. The IMG files are located in the IMAGES folder.

To create a boot disk when using a hard disk installation, you would enter RAWRITE from the DOSUTILS directory. When prompted, specify that you want to write the ../Images/BOOT.IMG file to the A drive.

225

Page 226: HISTORY AND DEVELOPMENT OF LINUX22

The rawrite command prompts.

To create a boot disk when using a Linux system, use the dd command. The dd command is also included on the Linux CD. First, mount the CD-ROM as a Linux volume. Then, enter the command dd if=/mnt/cdrom/images/bootnet.img of=/dev/fd0 to copy the bootnet.img file to the disk.

PCMCIA Disk:-If the system on which you are installing uses PCMCIA or PC Card devices (such as modems, LAN adapters, or SCSI adapters), you will need to also create a PCMCIA disk. This is created from the PCMCIA.IMG image file.

Bootable CD-ROM:-If your system contains a bootable CD-ROM drive, and you are installing from a bootable CD, you won't need any boot disks unless you need the PCMCIA disk.

Follow the steps below to learn how to create a boot disk.1. Mount the Linux installation CD as a volume on your system (mount /dev/cdrom).2. Insert a blank floppy disk in the drive. If there is any data on the floppy disk, it will

be overwritten by the dd command.

3. Enter dd if=/mnt/cdrom/images/boot.img of=/dev/fd0 to write the boot.img file to the disk in the first floppy disk drive.

4. If you will be using any PCMCIA components during the installation, you will also need to create a disk from the PCMCIA.IMG file. PCMCIA cards are also known as PC Cards. These are usually used in notebook and laptop computers.

5. Unmount the CD-ROM.

6. Remove the CD-ROM and floppy disks from their respective drives.

TIP: Alternatively, you could shut down to DOS, then use the RAWRITE command to create a boot disk from the boot.img file. Another alternative if you don�t have the installation CD is to access the classlinuxsrvr using telnet or ssh and changing to the /var/ftp/pub/rh7/images directory, then entering dd if=boot.img of=/dev/fd0.

1. What utilities can be used to create installation disks?

Ans: The DOS utility is rawrite.exe and the Linux utility is dd.

Lesson 3 Partitioning the Disk

226

Page 227: HISTORY AND DEVELOPMENT OF LINUX22

Lesson Objectives

In this lesson, you will:

Explain what to do if your entire hard drive is one big partition, and you want to do a Linux workstation installation. Define FIPS.

Introduction:-Most operating systems, including Linux, use disk partitions. Partitions enable you to divide large disks into smaller, more manageable chunks. The overhead in maintaining extremely large partitions is sometimes excessive, so making several smaller partitions is more efficient. It also enables you to organize information with less chaos. Partitions are treated as if they were separate disks.

The MS-DOS program FDISK is used to configure partitions on a hard disk. It can be used to create or delete partitions, or display partition information for current partitions.

Partitions are identified using a partition table, which is stored in the boot record at the beginning sectors of the disk. This is created before any formatting is applied to the disk. Formatting applies a filesystem to the disk, which then enables you to write information to the disk.

The partition table can hold up to four partitions. To get around this limitation, you can define extended partitions with logical partitions within the extended partitions. The types of partitions defined by MS-DOS are listed in the following rollover.

Partition Type DescriptionPrimary Requried for DOS systems to boot from. There can be only four of this type of partition.Extended Does not contain any data. This partition type is ysed to hold logical partition. The extended partitions

contain its own partition table.Logical Created within an extended partition. There is no limit to the number of logical partition u can create in an

extended partition, but in all practicality, u should probably limit it to no more than 12 logical partition per disk drive.

Non-DOS Partition created by another OS such as Linux or NetWare.

Add up the Usage percentages. If you have one drive, and all of it has been partitioned, then adding up the numbers in the Usage column would equal 100 percent. (If you have more than one disk, you should be able to add up to 100 percent for each disk.) If some space has not been partitioned, you will add up to less than 100 percent. Compare the values in the Mbytes column to the size of the disk to determine how much available space you have to determine if you have enough space in which to install Linux. You'll need some free space (at least 900 MB) in which to install Linux.

227

Page 228: HISTORY AND DEVELOPMENT OF LINUX22

MS-DOS FDISK partition information.

5. Is there free space to create a Linux partition? (Compare the usage to 100 percent and the Mbytes column values to the total disk space.)

Ans: Answers will vary. With Linux already installed, you probably won't have any space free. You will need at least 900 MB of free space available to install Linux using the workstation class or at least 2 GB of free space available to install Linux using the custom option.

6. If you need to make room for Linux, and a non-DOS partition or other partition can be deleted, what could you do?

Ans: From the FDISK Options screen, use the Delete Partition Or Logical DOS Drive option. If all of the drive is being used for the MSDOS partition, you can delete and re-create it (after backing up all data so you can restore it) or use a non-destructive partitioning utility to change the size.

Removing Linux:-To remove Linux from your system, you can try using the fdisk utility, but chances are you will need a stronger utility. The DELPART.EXE command can be used to remove any partition from your system. Be sure to back up any data that you want to keep before running DELPART because the partition will be destroyed.

LILO inserted itself in your master boot record (MBR) when Linux was installed. To remove it, you will need to rewrite the MBR using the command fdisk /mbr.

Follow the steps below to learn how to remove linux.1. If you are in Windows, shut down to the DOS prompt. (Choose Start�>Shut

Down�>Restart In MS-DOS Mode, then click on OK.)2. Enter cd \utils to change to the C:\UTILS directory.

3. Enter delpart to open the DELPART utility, which can be used to delete partitions.

4. Acknowledge the warning message displayed when DELPART starts.

228

Page 229: HISTORY AND DEVELOPMENT OF LINUX22

Select the Unknown Partition.

Press the Delete key to delete the selected partition. When prompted as to whether or not to delete the partition, select Yes, and then press the Enter key.

Select the Extended Partition. Press the Delete key to delete the selected partition. When prompted to delete the partition, select Yes, and then press the Enter key.

Press Alt+F to access the file menu. With Save selected, press the Enter key to save the partition changes to disk. Select Yes to save the changes to the hard disk.

Press F3 to exit the DELPART utility. Press the Enter key to restart your computer. When the computer comes back up, access the DOS side of the system again. Enter fdisk /mbr to rewrite the master boot record. This removes LILO from the master boot record. Restart your system. It should now just boot up to a DOS prompt (or start Windows).

Repartitioning Strategies:-If you have neither enough free space nor a partition you don't mind having overwritten, then you can either add another drive on which to install Linux or repartition your existing drive. Most DOS-based systems have a single partition that includes the entire drive. This leaves you with no space in which to install Linux. You can either delete the existing partition and make it smaller to accommodate Linux, or use a partitioning utility to resize it.

229

Page 230: HISTORY AND DEVELOPMENT OF LINUX22

Unless you use a special utility, you will have to delete and then re-create partitions of the appropriate sizes. In recent years, several utilities have been developed that can move partition boundaries without destroying your data.

Destructive Repartitioning

Destructive repartitioning is a traditional method. You use the MS-DOS FDISK utility to delete the existing partition, and then re-create partitions. This means that you lose all of the data saved on the partition when it is deleted. Therefore, before deleting the partition, if you want to retain any of the information, you will need to back it up, delete and re-create the partitions, and then restore the information.

230

Page 231: HISTORY AND DEVELOPMENT OF LINUX22

Several third-party utilities are now available that allow you to move the partition boundaries without destroying the data currently stored on the partition. This is referred to as non-destructive repartioning. You still have to be extremely careful, and follow the utilities' documentation directions exactly to avoid inadvertently destroying your data.

Partition Magic from Power Quest is one such utility that can be purchased. Another commercial product is Partition-It from Symantec.

FIPS (the First non-destructive Interactive Partition Splitting program) comes with Red Hat Linux. This free utility comes with complete instructions on how to safely use it.

FIPS changes values in the partition table and boot sector without changing the formatting of the partition. This does not change the cluster size or the size of the FAT table. The smaller partition's FAT table will contain some unused portions, but that is okay with DOS. A new partition is created, new_primary_DOS. Linux utilities can then be used to repartition the new_primary_DOS partition as needed.

Partitionless Installations:-Red Hat Linux 7.0 introduces the partitionless installation option for someone who wants to try out Linux without installing it completely. All it requires is a formatted DOS FAT partition with enough free space for a workstation installation. However, it doesn't have all of the options available that a full workstation installation would have, and you need to use a boot disk every time you want to run Linux.

Discussing Repartitioning Strategies

1. Before repartitioning your system, what should you do first?

Ans: Create and verify at least one (preferably two) backups of the complete system. This way, if you do a destructive repartition, you can restore the information. If you do a non-destructive repartition, you will have a good backup in case anything goes awry during the procedure.

2. Have you ever used a repartitioning utility? If so, share your experience with the class.

Ans: Answers will vary.

Using FIPS to Adjust Partition Sizes:-Before you can use FIPS to adjust the size of your DOS partition, there are several things you must do first. If you aren't careful, you can still cause problems and lose data. For this reason, you should do the following before splitting the partition.

Before You Split the Partition

You need to move all data to the beginning of the disk by using a defragmentation program such as DEFRAG or Norton Speed Disk. You should also check your hard disk for errors using SCANDISK or Norton Disk Doctor.

If you use a Windows swap file, you will need to uninstall it (from the Windows Control Panel in the 386Enhanced section) before running FIPS. This is because defrag programs cannot move the swap file. You can then re-install it after using FIPS.

Create a bootable floppy and copy RESTORRB.EXE, FIPS.EXE, and ERRORS.TXT to this disk. Be sure to test that you can successfully boot from this disk. When you actually run FIPS to split the partition, you will be prompted to copy your root and boot sectors to this disk for safekeeping in case anything goes wrong with the split.

Make sure to disable any utilities that write to the disk when rebooting or booting. FIPS requires that no changes be made until everything has been written, and it also requires a reboot, so you will want to disable any programs that write to disk. Also, be sure to disable Smartdrive or other disk cache programs.

What FIPS Does

231

Page 232: HISTORY AND DEVELOPMENT OF LINUX22

The first thing FIPS does is check the partition table, boot sector, and FAT for any problems. If anything doesn't look right, FIPS will not continue and will end with an error message alerting you to what it found.

Next, it gives you the chance to create copies of the current root and boot sector on floppy so that if anything happens, you can restore them using the RESTORRB.EXE utility included with FIPS. This can also be used to reverse the partition split.

You can then choose the new starting cylinder after FIPS checks for partition free space. FIPS then calculates the new partition table and boot sector values and checks them again before prompting you whether to write the new root and boot sector information to disk.

If you have multiple DOS drive letters, be aware that these most likely will change after creating the new partition. C will remain C:, but the rest, including your CD-ROM drive, might move up the alphabet by a letter.

FIPS Limitations

FIPS works only on DOS partitions with disk sector sizes of 512 bytes. 12-bit FATs will not be split by FIPS. Therefore, a partition will not be reduced below 4085 clusters because this would require writing the 16-bit FAT as a 12-bit FAT. It also does not currently work with extended DOS partitions. If you already have four partitions, you cannot use FIPS to further split the par.

FIPStitions; FIPS requires a free partition entry with which it can work.

After Running FIPS

Be sure that the changes FIPS made were written to disk before you write anything to disk. Reboot, and then use SCANDISK to check that the original partition, now shrunken, is still okay. You can test that FIPS correctly wrote partition information to disk by running FIPS -T. If no errors are reported by the time the cylinder selection screen is displayed, you are okay and can break out of the program (press Ctrl+C). If problems were encountered, you should restore the original information using RESTORRB.

After verifying the success of the change, you can reboot using your normal boot files (CONFIG.SYS and AUTOEXEC.BAT). You might also want to run some applications to make sure they still work correctly.

If you want to make the new partition into several smaller partitions, you first need to format it using the DOS FORMAT command.

The steps to use FIPS to adjust DOS partition size are:

1. Run SCANDISK to check your partition for errors before splitting it. 2. Run DEFRAG to move all data to the start of the partition.

3. Check to see if IMAGE or MIRROR were used to place copies of partition tables in the last sector of the disk. If so, delete the file.

4. Create a bootable floppy, and then from the DOSUTILS directory, copy RESTORRB.EXE, FIPS.EXE, and \FIPDOCS\ERRORS.TXT. (Check that you can boot from the floppy.)

5. Reboot using the bootable floppy.

6. Enter fips. FIPS will attempt to check which operating system you are running. If Windows or Desqview are detected, you will be prompted to boot from floppy.

7. Observe as FIPS detects your drives. If more than one disk is detected, you will be prompted to select which one to repartition.

8. Observe the partition table listing. FIPS displays the partition table after reading the root sector of the hard disk. You can identify the partitions by the size in MB.

232

Page 233: HISTORY AND DEVELOPMENT OF LINUX22

9. If multiple partitions are found, you will be prompted for which partition to split. FIPS reads the boot sector of the partition and displays the following information:

10. More checking is done, including checking that the information displayed matches the actual partition table; that both copies of the FAT are identical; and for other possible errors that would prevent successfully changing the partition.

233

Page 234: HISTORY AND DEVELOPMENT OF LINUX22

11. Enter the cylinder number where the new partition will begin. Use the arrow keys to change the number of cylinders in the new partition. (Right and left arrows increase and decrease by ones; up and down arrows increase and decrease by tens.) After adjusting, press the Enter key to continue.

12. 12. If you agree with the changes, type c, and then y. FIPS writes the changes to disk and exits. If you don't agree, re-edit the partition table.

13. 13. Reboot your system. Be sure not to write anything to disk before rebooting.

14. 14. Enter fips -t to test the partition. Select the drive and partition you modified. If no errors are displayed prior to the cylinder section, you successfully changed the partitions. Press Ctrl+C to end the test.

15. If testing resulted in errors, reboot from floppy, and then enter restorrb. When prompted, choose the configuration file to restore. Then, redo the partition split.

16. Remove the floppy disk and reboot normally. Make sure you can still access files on the original partition.

1. What should you do before running FIPS?

234

Page 235: HISTORY AND DEVELOPMENT OF LINUX22

Ans: Run SCANDISK and DEFRAG, and then check to verify that IMAGE and MIRROR aren't in use.

2. What files need to be copied to the disk used to run FIPS?

Ans: RESTORRB.EXE, FIPS.EXE, and ERRORS.TXT.

3. How do you specify the starting cylinder for the new partition?

Ans: When prompted, use the right or left arrow keys to increase or decrease the cylinder number by ones; use the up or down arrow keys to increase or decrease the cylinder number by tens.

4. How do you test the partition using FIPS?

Ans: After writing the changes to disk and rebooting your system, run fips -t, select the drive and partition you modified, and if no errors are displayed prior to the cylinder selection, successfully change the partitions so you can exit by pressing Ctrl+C.

Maintaining Multiple Operating Systems on Your System:-If you already have a DOS partition installed and you install Linux using the Workstation option, LILO will automatically be installed so that you can boot to either DOS or Linux. Other managers you can use include System Commander and LoadLin.LILO:-LILO (Linux Loader) is the most popular Linux boot loader. It enables you to boot from up to 16 different configuration images. These can be DOS, OS/2, Windows NT, UNIX, or Linux partitions, to name a few.

LoadLin:-LoadLin is a DOS utility from which you can launch a Linux kernel. This is useful if you need to boot to DOS first to use DOS drivers for hardware, because the hardware is not reset before launching Linux as it would be if you rebooted the system to launch Linux like you do when you use other boot loader software.

Maintaining Multiple Operating Systems

1. What are some utilities that can be used to boot your system to various operating systems?

Ans: Answers might include: System Commander, LILO, or LoadLin.

2. Which will you use if any? Why?

Ans: Answers will vary.

3. Which utility is installed by default when you perform a Red Hat Linux 7.0 workstation install?

Ans: LILO. 1. If your entire hard drive is one big partition, and you want to do a Linux workstation installation, what can you do?Ans: Back up your data, delete the partition, and then re-create a smaller partition leaving space free in which to install Linux. Use a non-destructive partitioning utility such as FIPS, Partition Magic, or Partition-It to resize the partition and make room for Linux. Use a partitionless installation.

2. What is FIPS?

Ans: The First non-destructive Interactive Partition Splitting program. Used to change values in the partition table and boot sector without changing the formatting of the partition.

CHAPTER 19 Installing Red Hat Linux 7.0 Using the Workstation Class

Lesson 1 Installing Red Hat Linux

Lesson Objectives

235

Page 236: HISTORY AND DEVELOPMENT OF LINUX22

In this lesson, you will:

List the Red Hat installation classes. List the Red Hat installation methods.

Introduction:-All you really wanted to do was install Linux on your system, but first, you had to go through all of that planning and research about your system. Now is when all of that up-front work pays off.

Installation Classes:-Red Hat Linux 7.0 offers three installation classes. Installation classes can be thought of as kinds of installations. The following table compares the three options.

Installation Class Automatic Partition Operations Minimum Disk Space Required

Boot Configuration

Workstation - Use this class when your system will be a Linux workstation (good for new users).

Removes any existing Linux partitions and creates: At least 16 MB swap partition. A 16 MB boot partition.

A / partition from the remaining space.

About 900 MB (1.7 GB recommended).

Dual-boot (configured using LILO) if a DOS partition already exists on the system.

Server system - Use this class when your system will be a Linux server.

Removes all existing partitions and creates: At least 16 MB swap partition. A 16 MB boot partition.

A / ("root") partition.

A /home partition.

A /usr partition.

A /var partition.

450 MB (1.7 GB recommended).

None. (Linux starts automatically because it is the only operating system installed after the Linux installation.)

Custom system - Use this class when you need complete flexibility.

None-they are added at your discretion. (Use Disk Druid or the Linux fdisk command to create the partitions you want in the sizes you want.)

250 MB (1.7 GB recommended).

You can determine whether to use LILO to boot your systems.

Other distributions don't have these classes. However, some of them do have different products for workstation and server installations. For example, there is TurboLinux Workstation and TurboLinux Server; there is also Caldera OpenLinux Workstation and OpenLinux Server (previously known as eDesktop and eServer).

1. What are the three Red Hat installation classes?

Ans: Workstation, server system, and custom system.

2. Which installation class gives you the most flexibility?

Ans: Custom system.

236

Page 237: HISTORY AND DEVELOPMENT OF LINUX22

3. When would you use the other two installation classes?

Ans: You should use the workstation installation class when you are installing a Linux system to be a workstation. This is also the easiest installation, so it is good for beginners. You should use the server installation class when you are installing a Linux system that will act as a file, print, application, Web, or other server.

4. What does each installation do to existing disk partitions?

Ans: The workstation installation deletes any Linux partitions it finds, leaving all other partition types alone. The server system installation deletes all partitions on the system. The custom system installation allows you to determine whether to delete, remove, overwrite, or leave existing partitions.

5. What partitions does each installation create?

Ans: The workstation creates swap, boot, and root partitions. The server system creates those plus the usr, home, and var partitions. The custom system allows you to determine what partitions to create and creates none on its own.

Figuring Out How to Boot:-Depending on your situation, you might need a boot disk. (This was created when you were preparing for your installation.) If you are installing from local CD-ROM or another partition on the local drive, you will need a DOS-bootable disk created from BOOT.IMG. If your CD-ROM drive is a bootable drive, you might not need any boot disk at all.

If you are installing across a network using NFS, FTP, or HTTP, then you will need a DOS-bootable disk created from BOOTNET.IMG.

If you are successful in booting, a boot prompt is displayed. There are several help messages displayed; the function keys listed with them enable you to get more information. If you do nothing for 60 seconds, the installation automatically starts. If you press one of the function keys, the help screen is displayed rather than auto starting. Usually, you will just press the Enter key to begin the installation.

The Red Hat 7.0 welcome screen and boot options.

Probing:-The Linux kernel attempts to detect your hardware during installation. If it doesn't properly detect your hardware through its probe, you'll need to restart the installation using the expert mode that disables hardware probing and lets you enter

237

Page 238: HISTORY AND DEVELOPMENT OF LINUX22

driver options during the installation. This will really require that you did your pre-installation research so you will know what to specify when prompted.

To install using expert mode, reboot; at the boot prompt, enter expert. This will load the expert image from the boot disk.

Documenting the Installation:-When you install a system, you should document it. This includes documenting the choices you make, when it was done, by whom it was done, what was installed, and other information.

You already started some of the documentation when you were preparing for installation. You gathered information about the hardware you are installing Linux on and information about network settings.

You might want to create a form where you can record information you entered or selected on a screen-by-screen basis as you work through the installation. Depending on your needs, you might base your documentation on some other information. The important thing is that you do record information about the choices you make during the installation.

Boot from the appropriate floppy disk or CD-ROM drive. Review the welcome message that is displayed, which describes your options upon booting.

Explore the installation function keys and the help displayed when you press each function key. Observe the descriptions in the following table. If you do not press any function key within 60 seconds, the system will begin to boot to Linux and to the installation process.

  Function Key  Description

  F1  Displays information about the main Linux   installation screen.

  F2  Displays information about general Linux   installation.

  F3  Displays information about the export mode of   installing Linux.

  F4  Displays information about entering additional   kernel settings.

  F5  Displays information about rescue mode.

When you are ready to continue, press the Enter key to begin the installation in graphical mode. If you get a second welcome message, read it and continue with the installation.

If you booted from a BOOT.IMG disk in the Choose A Language and Keyboard Type windows, select the appropriate choices, and continue. You can move up and down the lists using the arrow keys, Tab to move to the OK button, and press the Enter key, Spacebar, or F12 to get to the next screen.

238

Follow the steps below to learn how to start the installation.

Page 239: HISTORY AND DEVELOPMENT OF LINUX22

If you booted from your CD-ROM drive, your screens will look a little different. Select the appropriate Language Selection and Keyboard Configuration choices, and click on Next. Stop when you get to the Mouse Configuration window. The installation will be continued in the next set of steps.

Installation Methods:-Red Hat Linux refers to the source of your installation files as the installation method. If your source is local to your system, your choices are Local CD-ROM or Hard Drive. If your source is across the network, your choices are FTP,

NFS Image, and HTTP.

Installation Method screen.

Local installations are much quicker and you don't have to worry about maintaining your connection. On the other hand, installing across the network doesn't require that you have a CD-ROM drive or a large hard drive on which to install the local files. If you use a bootable Red Hat 7.0 CD-ROM disk, the first part of the installation goes a little quicker.

Follow the steps below to learn how to choose an installation method and class.

239

Page 240: HISTORY AND DEVELOPMENT OF LINUX22

1. At the Installation Method prompt, select a Local CDROM installation method. If you booted from the BOOT.IMG disk, your choices are Local CD-ROM or Hard Drive; if you had booted from BOOTNET.IMG, your choices would have been NFS Image, FTP, or HTTP.

2. If you are installing from a local CD-ROM, you will next be prompted to insert your Red Hat CD in the CD-ROM drive. If you booted from your CD-ROM, it will already be in the drive, but you are prompted anyway.

3. In the Mouse Configuration window, select the appropriate mouse type. If you choose a two-button mouse, the Emulate Three Buttons check box becomes checked automatically. Click on Next.

4. The next window displayed is another welcome screen. In the Online Help screen, read the Welcome To Red Hat Linux text displayed. Click on the Hide Help button and then the Show Help button. The Online Help screens can be very useful and should be read, but you can also hide them if you choose. Click on Next.

5. The Install Type screen is displayed. Install and Workstation are selected by default. Read Install Options in the Online Help screen. You can upgrade if you have Red Hat Linux 3.0.3 or later. This lesson focuses on the workstation portion of Linux. The lesson, "Installing Red Hat 7.0 with the Custom Class," covers installation

240

Page 241: HISTORY AND DEVELOPMENT OF LINUX22

using the Custom System installation class option.

6. Verify that Workstation is selected and click on Next.

7. Read the Automatic Partitioning screen information. You are going to accept the default, Automatically partition and REMOVE DATA. Click on Next.

8. If your installation detected a network card, you will see the Network Configuration screen next. Complete the form with the appropriate information. Click on Next.

241

Page 242: HISTORY AND DEVELOPMENT OF LINUX22

9. In the Time Zone Selection screen on the Location tab, click on the button next to View. A drop-down list appears with several choices. Click on a few of them and watch the graphic change. Move the mouse pointer over one of the interactive maps and observe as the bar in the middle of the screen changes. When you click on one of the yellow dots, a red x appears on the map and the location is selected in the city list at the bottom of the screen. You can also scroll through the city list to select a time zone. Select the appropriate time zone for your location and click on Next.

1. What are the Red Hat installation classes?

Ans: Workstation, server system, and custom system.

2. What are the Red Hat installation methods?

242

Page 243: HISTORY AND DEVELOPMENT OF LINUX22

Ans: Local CD-ROM, Local Hard Drive, FTP, NFS Image, and HTTP.

Lesson2 Configuring Linux

Lesson Objectives

In this lesson, you will:

Identify the program you can use later to configure your X Windows environment. Identify what you are prompted with when you see the Congratulations message.

Introduction:-As you continue with the installation, you will configure the root password, create an additional user, select packages, and create a boot disk. You will also configure monitor and video settings for X Windows. Depending on which things your system auto-detects, some of the next configuration settings might be presented to you in a different order than shown in the tasks. Don't worry�you'll get them all eventually.

The root Password:-You must assign a valid password to the root user during installation. You're prompted to type it twice to make sure you didn't make a typo. The password should be at least six characters long, and it shouldn't be based on a dictionary word. It is a good idea to include numbers, letters in upper and lower case, and special characters such as a dash (-) or underscore (_) to make it more difficult for someone to break in. Unlike in some previous versions, you can now create other user accounts during installation.

When you install Red Hat Linux 7.0, there is only one user created by default�root. This user has access to all parts of the system. The root user can read, modify, or delete anything on the filesystem. This user can also change who has access to files and devices. To protect yourself from making disastrous mistakes, it is strongly recommended that you create at least one other regular user during installation.

Package Selection:-Red Hat Linux is a modular operating system with over 800 individual packages available. The default installations of workstation and server system select the optimum packages for you. However, you do have the choice at installation of adding or removing individual packages. In the custom system installation, you pick and choose which package groups or individual packages to install. You can also add packages after the install as you need them. Boot Disk:-A custom boot disk can be created during installation. It is highly recommended that you create one at this time. This boot disk is useful if your system won't boot properly. It is also handy if LILO gets removed from your system by another operating system or if LILO doesn't work with your hardware configuration. If you have a severe system failure, it is used with a rescue disk to recover your system.

Follow the steps below to learn about account configuration, package selection & disk creation.

1. In the Account Configuration screen, you need to assign the root user a password. Enter the password of your choice, and then confirm it.

243

Page 244: HISTORY AND DEVELOPMENT OF LINUX22

2. Create a user account using your first name, an acceptable password of your choice, and your full name. Click on Add. Your user is added to the account list. You can also edit and delete user accounts at this time. Click on Next.

3. The Package Group Selection screen is displayed. GNOME is selected by default. Check Select Individual Packages, and click on Next. The Individual package screen comes up. Click on Show Help and read the screen.

244

Page 245: HISTORY AND DEVELOPMENT OF LINUX22

4. You are not going to install any individual packages at this time. Click on Back to return to the Package Group Selection screen. Make sure GNOME is still selected. Uncheck Select Individual Packages, and click on Next

5. Depending on whether your monitor was successfully detected, the next screen you see is the Boot Disk Creation screen. If your monitor wasn't successfully detected, the Boot Disk Creation screen will be presented later during the installation. It is recommended that you create a boot disk at this time. Insert a blank disk in drive A (also called /dev/fd0 in Linux terminology). Click on Next. The installation process then creates the boot disk for you. The command lilo is lower case, but when referring to the LILO process or the LILO prompt, it is written in upper case. As part of this process, the LILO boot loader is placed on disk.

245

Page 246: HISTORY AND DEVELOPMENT OF LINUX22

TIP: The command lilo is lowercase, but when referring to the LILO process or the LILO prompt, it is written in upper case.

PCI Probe and Monitor Settings:-If it is not autodetected, you may be prompted for your monitor type. Many models are listed, so hopefully you'll be able to just select your model from the list. If not, select custom and manually enter the settings as prompted. (You'll be glad you gathered hardware information up front if you are forced to do this.)

Behind the scene the installation probes your system to detect PCI entries and X Server (such as VGA or SVGA). The appropriate package is then installed.

The X Server is run by the Xconfigurator utility to test your configuration. When the messages appear on the screen, use your mouse to select the appropriate choices.

Follow the steps below to learn how to configure moniter setting.

1. If it wasn't autodetected, choose your monitor from the list. If your monitor is not listed, you'll need to choose a monitor from the list that best matches your model. You may specify horizontal and vertical sync rates and other specific settings, but be careful to enter only values that can be verified in the documentation for your display.

246

Page 247: HISTORY AND DEVELOPMENT OF LINUX22

2. The installation program probes for your video card, but again you can choose another video card from the list if need be.

3. Check Test This Configuration and observe as Xconfigurator tries out the settings you selected (either by choosing the monitor model or specifying custom settings). The screen will flash and you might be prompted as to whether you can see a dialog box. If you can see the dialog box clearly, click on Yes. If the dialog box is unclear or unreadable, click on No. Check Customize X Configuration and select a different resolution. Once you have an acceptable resolution selected, click on Next. You can run the program Xconfigurator later to specify that you want to boot to the GUI.

4. You can quit the installation at this point and nothing will be written to your hard drive. You also have the ability at this time to go back and edit information before installing. Click on Next. Observe the screen as the packages are installed. This might take a while depending on the number of packages to be installed.

247

Page 248: HISTORY AND DEVELOPMENT OF LINUX22

Finishing the Installation:-You're almost there. The next installation screen you should see is the Congratulations message. You will then be prompted to remove the boot media and CD-ROM and reboot your system.

As the system reboots, you'll notice that the LILO boot loader screen is displayed. Now you have what is called a dual boot system. Your choices are DOS (Windows) or Linux. You can use the up or down arrow keys to select one or the other. If you do nothing for a few seconds, the system will automatically boot to the default operating system, Linux. You can also press Ctrl+X for text base mode. A boot prompt is displayed. If you press Tab you will see your options. You can enter DOS or Linux to boot to either operating system.

Follow the steps below to learn how to finish up the installation.

If you made it to the Congratulations window, there's a pretty good chance you now have a working Linux workstation! The real proof will be when you reboot the system in a second. Remove all bootable media from the floppy and CD-ROM drives, and then press the Enter key or click on Exit. Your system will automatically be shut down and rebooted.

248

Page 249: HISTORY AND DEVELOPMENT OF LINUX22

Observe as the system restarts. The LILO boot screen is displayed. At the boot prompt, select dos to boot to the DOS side of your system. The two default configuration choices are Linux

and DOS. Restart your system, letting it automatically boot to Linux. The final test of whether you actually have a working Linux system is if you can log in. Log in as root. Page through the /var/log/messages, /var/log/dmesg, and /tmp/install.log files. These files contain information captured

during the installation. You might want to include hard copy (or copies of the files) in your installation documentation.

1. What program can you use later to configure your X Windows environment?Ans: Xconfigurator.

2. What are you prompted with when you see the Congratulations message?

Ans: You are prompted to remove the boot media and CD-ROM and reboot your system.

CHAPTER 20 Installing Red Hat Linux 7.0 with the Custom Class

Lesson 1 Why Use the Custom Class?

Lesson Objectives

In this lesson, you will:

Explain why you would use a custom installation. Define a custom class.

Introduction:-The Custom Class allows administrators to set up Linux systems with a particular set of packages and customize a variety of Linux system settings at installation time. Settings that can be customized using the Custom Class include:

RPM Package Groups Individual RPM Packages

The Custom Class Installation Process:-The Custom Class provides several steps during the installation process that are not present in the other installation classes. The full installation process consists of the steps contained in the following table. Steps denoted with an asterisk (*) are not present in Server Class installations.

Step Description

Install Methods You can use a bootable CD-ROM, a local boot disk, an NFS image, FTP, or HTTP.

Manual Disk Partitioning via Disk Druid or fdisk

Workstation and Server Class installations perform automatic partitioning. With Custom Class installation, you are prompted to create partitions using Disk Druid (the default) or the Linux fdisk utility.

Partitions Automatic partitioning created specific partitions. With a custom installation, you can create whatever partitions you want, in whatever size you want (until you run out of room, of course).

Choose Partitions to Format All new partitions need to be formatted and will be selected for formatting.

LILO Configuration* You will be prompted how you want LILO configured on your system.

Network Configuration If you have a network card, you will be prompted to configure static IP address information or DHCP.

Time Zone Selection Set your time zone by location or offset from UTC.

Account Configuration First, you are prompted for the root user's password. Then, you need to create at least one user in addition to the root user.

249

Page 250: HISTORY AND DEVELOPMENT OF LINUX22

Authentication Configuration*

MD5 (allows a stronger encryption algorithm to be used) and shadow passwords (a secure method of retaining passwords) are selected and should be left selected unless you choose to use NIS authentication (in which case, you'll need access to an NIS server).

Selecting Package Groups* Workstation and Server class installations pre-select the packages that will be installed, and you just select the GNOME or KDE desktop. Custom installation has the minimum suggested packages selected, and you can select or deselect these and other packages for installation. Package groups contain related packages to be installed.

Individual Package Selection*

In addition to selecting package groups, you can select or deselect specific packages within a package group for installation.

X Configuration: Monitor Configuration*

Hopefully a monitor has been autodetected for you; otherwise, select your model from the list. If your model isn't listed, select one of the Generic models that most closely matches your monitor.

X Configuration: Video Card Configuration*

Again, hopefully a video card has been autodetected for you; otherwise, select your model from the list, specify the amount of video RAM on the video card, and then test the configuration. If your video card isn't listed, select Unlisted Card and configure it, matching it with one of the video chipsets on the X servers.

About to Install This is a final opportunity to bail out of the installation. Nothing has been written to disk yet. Clicking Next will cause partitions to be written and packages to be installed.

Installing Packages At this point, all you need to do is wait. The packages are automatically installed. If installing from CD, you might be prompted to insert a second CD.

Create Boot Disk Insert a blank 3.5" disk in the drive to create a boot disk, which will be used to bring up the system in the event the system fails to start.

Reboot System After the installation has finished, you are prompted to remove any disks and reboot the system (you won't be able to remove CDs until after the reboot has started because they will still be locked in the drive).

1. Why would you use a custom installation?

Ans: Answers might include: If you need to create specific partitions of a certain size, if you need to install specific packages, if you need to create a server and install X windows, or if you need to retain existing partitions, you will need to create your server using the Custom Class option.

2. What steps are you able to configure when using a custom installation that you aren't prompted for in a server installation?

Ans: Partitioning, LILO configuration, authentication, packages to install, X configuration.

3. Will you use the custom option when you install your system? Why or why not?

Ans: Answers will vary. If workstation or server installation includes what you need, you might use those installation options; otherwise, you'll need to use the custom option.

1. Why might you use a custom installation?

Ans: A few reasons might be: If you have existing partitions that you don't want destroyed. If you want packages other than those installed by workstation or server class installations. If you want partitions of specific sizes other than those offered by server or workstation class installations.

2. What is custom class?

Ans: Custom class is the most flexible of the three Red Hat installation classes.

250

Page 251: HISTORY AND DEVELOPMENT OF LINUX22

Lesson 2 Installing Linux Using the Custom Class

Lesson Objectives

In this lesson, you will:

Identify the steps that should be done before beginning a Linux installation. Identify the preparatory steps for accessing the network when you are performing a network installation.

Introduction:-It is important that you gather information about the hardware, network addresses, and existing network requirements before beginning your Linux installation. Now that you've briefly examined why you might want to use the Custom Class, let's examine�in more depth�how you would go about using it.

Preparing for Installation:-Your Linux installation will go more smoothly if you prepare before beginning. You need to gather information about the hardware, network information (such as IP addresses or DHCP information), and user and password guidelines.

You should also check to make sure your hardware is compatible with Linux. Distributors, such as Red Hat, Inc., test whether Linux operates correctly with specific hardware. After testing, they produce Hardware Compatibility Lists (HCL) for each supported version. The lists include information about the hardware, but becauase the computer system configurations vary between what you might have and what they tested, the variations in manufacturing specifications aren't guaranteed compatible with any hardware. The HCL is a list of hardware that has been tested under specific conditions (usually under many conditions), and should be used as a guide, not as an absolute testament that the hardware will work perfectly straight out of the box because your system is probably configured slightly differently than the test systems).

Although most installations can now detect most of the hardware in your system, there are times you might be prompted for specifics about your hardware, especially on extremely new or old components for which drivers might not be provided. You'll also need to know the source for your installation. This might be from your local machine or across the network. To install across the network, you'll need to create a boot disk. From a DOS system, you can use the RAWRITE.EXE command; from a Linux system, use the dd command.

Documenting the Installation:-When you install a system, you should document it. This includes documenting the choices you make, when it was done, by whom it was done, what was installed, and other information.

You already started some of the documentation when you were preparing for installation. You gathered information about the hardware you are installing Linux on and information about network settings.

You might want to create a form where you can record information you entered or selected on a screen-by-screen basis as you work through the installation. Depending on your needs, you might base your documentation on some other information. The important thing is that you do record information about the choices you make during the installation.

Creating a Boot Disk with RAWRITE:-The RAWRITE utility is included on the Red Hat Linux CD-ROM in the DOSUTILS directory. When you run this command, you are prompted for the boot image you want to load. To install across a network, use the BOOTNET.IMG image file. Next, you are prompted for the drive containing the disk.

Creating a Boot Disk with dd:-The dd command is also included on the CD. First, mount the CD-ROM as a UNIX volume. Enter the following command to copy the bootnet.img file to the disk.

251

Page 252: HISTORY AND DEVELOPMENT OF LINUX22

Checking Free Space:-In order to install Linux, you need to have enough free space on your drive. A custom installation can take as little as 40 MB or as much as several GB depending on what you will be installing. You can check the partitions with the MS-DOS FDISK utility or other utilities. If you need to change the partition size, you can use the destructive repartitioning method whereby you delete the existing partition, and then re-create it in a smaller size or use a non-destructive repartitioning tool such as FIPS, Partition Magic, or Partition-It.

Follow the step below to learn about preparing for an NFS custom installation.

1. With your system booted to the DOS/Windows side of the system, enter cd \images to access the C:\IMAGES directory.

2. Insert a blank floppy disk in the drive.

3. Enter \dosutils\rawrite -f bootnet.img to create a bootnet boot disk. When prompted, enter A to specify the floppy disk drive you will use. When prompted, insert a blank floppy disk in the drive and press the Enter key.

4. Verify that you have at least 2 GB of free space on which to install Linux. Use the MS-DOS FDISK utility to see how much free space you have. If necessary, use a non-destructive repartitioning tool to create enough space on the drive to install Linux.

Performing the Installation:-You can install Linux from a bootable CD-ROM, from a disk or hard disk, or via NFS or FTP. To install from any other source than a bootable CD, you need to create a bootable disk using the appropriate image file.

Installing from an NFS Server:-An NFS server makes filesystems that are physically on one computer system available to other network computers. The filesystems appear to be local disks to the remote users on the other network computers. Let's install Linux from an NFS server.

Follow the step below to learn how to begin a custom installation.

Boot your system from the BOOTNET.IMG disk. If you don't make a selection on the Welcome screen after a few minutes, it will automatically start.

Choose the appropriate selections up until the Installation Method, where you will choose NFS Image.

If prompted, choose the appropriate network card. This is where your up-front research will pay off. If you're prompted for the make and model of the network card, you can simply refer to your notes.

252

Page 253: HISTORY AND DEVELOPMENT OF LINUX22

Due to differing hardware configurations, you may have a text-based screen at this point. Configure TCP/IP to use a static IP address, 192.168.100.10#, where # is your computer number. The Netmask is 255.255.255.0 and the Default Gateway (IP) is 192.168.100.1.

In the NFS Server Name field, enter the IP address of the server. In the Red Hat Directory field, enter /var/ftp/pub/rh7. Configure your mouse as appropriate. Read through the Welcome To Red Hat Linux panel on the System Installer screen, and then click on Next. In the Install Type panel, select Custom System, and then click on Next.

1. What are the steps that should be done before starting a Linux installation?

Ans: It is important that you gather information about the hardware, network addresses, and existing network requirements before beginning a Linux installation.

2. If you are performing a network installation, how do you prepare to access the network?

Ans: Create a boot disk that contains the images from the BOOTNET.IMG file.

Lesson 3 Partitioning the System

Lesson Objectives

In this lesson, you will:

Identify the minimum number of partitions that can be created. Explain what a partitionless installation is.

Introduction

253

Page 254: HISTORY AND DEVELOPMENT OF LINUX22

A custom installation doesn't make any assumptions about the name, type, or size of partitions you want on your system. You will be prompted about where you want to install Linux. You are prompted to define mount points for the disk partitions in which to install Linux. If necessary, you can also create or delete other partitions at this point in the process.

Planning Your Partitions:-Before you create your partitions, you should take some time to plan what partitions you need, what size they should be, and what you will name the mount point. Minimally, you need a 16 MB /boot partition and a root (/) partition. You will also need a swap partition of at least 16 MB or the same size as the amount of memory installed.

Once a partition is created and formatted, it becomes quite difficult to resize the partition. Careful planning is required to prevent the creation of a partition that will quickly be filled. For production servers, some time should be devoted to defining a partitioning scheme that will account for current and future needs.

Red Hat is currently recommending that you create just a 16 MB /boot partition, a swap partition equal to the size of RAM installed on your system, and the remainder of the disk space to the / partition. They recommend that you use this partitioning strategy unless you have specific requirements for other partitions.

You can create only up to four primary partitions or up to three primary and up to one extended partition. An extended partition allows multiple, logical partitions to be created inside the partition.

There are trade-offs in making only three partitions. Security, such as disk quotas, is often specified on a partition basis. If you want to limit users to a set amount of space in their home directories, you won't want to make your administrator work with these limits. On the other hand, if you have several smaller partitions, and a package needs to be installed on a certain partition, and you run out of room on that partition, you will need to delete and re-create the partition to change the size.

If a partition table gets corrupted, you might lose access to all of the files on the partition. You can minimize the loss of data by placing files on different partitions, so you don't lose everything if this happens.

A custom installation can be done in as little as 120 MB of disk space. However, you won't have a usable Linux system. You will want to allocate at least 2 GB as a more realistic minimum for a useful Linux system.

254

Page 255: HISTORY AND DEVELOPMENT OF LINUX22

Partitionless Installations:-Red Hat Linux 7.0 introduces the partitionless installation option. This option allows you to try out Linux without installing it completely. You still have to perform a complete installation to use this option. It also requires that you have a formatted DOS FAT filesystem installed on the system. This option doesn't create any Linux partitions. It edits an existing FAT partition with enough free space (900 MB for a workstation installation, 1.7 GB for a server or up to 1.7 GB for a custom installation) and names it /. Also, LILO won't be installed and configured. You will need to create a boot disk to access Linux. See the side bar on the partitioning screen for more information about this option.

1. The customer has a Windows 95 system and wants to try out Linux. She would like to be able to go back to Windows 95 on occasion because she has a custom application that currently runs only in Windows. She might also want to remove Linux from her system if it doesn't meet her needs.

Ans: She could perform a Workstation installation, which would retain her existing partitions and create several Linux partitions, or she could perform a custom installation. She would probably want to create swap and /boot partitions and one / partition. If she is using Linux 7, she could also use the partitionless option to just try it out.

2. Your customer wants to be able to easily back up the directories under /home and /projects on a daily basis. He or she will back up the rest of the system weekly.

Ans: This customer should probably have swap and /boot partitions, /home and /projects partitions, and the rest could be the / partition.

3. Your customer has created a Linux system using the server option. It created swap, boot, /var, /home, and / partitions. Now, when he tried to install an additional package, he was given an out of disk space message. What should he do?

Ans: He will either need to add another disk or back up the data and then recreate the partitions in the necessary sizes.

4. What would you suggest to someone who has a large hard disk and wants to just check out Linux without installing it completely?

Ans: You might recommend that he or she tries the partitionless installation.

Disk Druid:-Disk Druid is one of the partitioning tools included with Red Hat Linux. This has a graphical interface as shown in the figure below.

255

Page 256: HISTORY AND DEVELOPMENT OF LINUX22

The Partitions section of the window displays each disk partition on a separate line. The following animated tip describes the fields in the Partitions box.

You should create the swap, root, and /boot partitions as a minimum. You can also create other partitions during installation. The following table describes these partitions.

Partition Size Description

swap 16 MB or equal to the amount of RAM installed

Supports virtual memory. This partition is required on systems with less than 16 MB of RAM. On other systems, it is recommended that you create a swap partition. The partition size should be the same size as the amount of RAM installed or 16 MB, whichever is larger.

/boot 16 MB Contains the operating system kernel and bootstrap files. This needs to be in the first 1024 cylinders of the disk.

/ (also known as 600 MB-1.7 GB Contains the root of the filesystem. If you use only these three partitions, this is the partition that

256

Page 257: HISTORY AND DEVELOPMENT OF LINUX22

the root partition) will contain all files other than those in the /boot partition. 600 MB contains little free space after you install Linux. 2 GB is enough to install all packages included with Red Hat Linux 7.

If you want to resize a partition, you will need to delete the current partition and re-create it. Use the Delete button below the Partitions box to delete the partition, and use the Add button to add the partition.

The Partition Type column shows a description of the partitions on the system. These might include the following values.

Partition Type Value

Empty 00

DOS 12-bit FAT 01

DOS 16-bit <=32 04

Extended 05

DOS 16-bit >=32 06

OS/2 HPFS 07

Win95 FAT32 0b

Win95 FAT32 (LBA) 0c

Win95 FAT16 (LBA) 0e

Win95 Extended (LBA) 0f

The Linux fdisk Utility:-The Disk Druid utility is specific to Red Hat installations. A more generic utility, the Linux fdisk utility, is available throughout all Linux distributions. It is less intuitive than Disk Druid. However, you might want to take time later to become acquainted with it so you can use it if you need to.

TIP: It is strongly recommended that u use the DOS FDISK command for DOS/Windows partitions & the Linux fdisk command for Linux partitions.

The Linux fdisk command is a menu driven program for creating and managing partition tables. The syntax of the command is one of the following:

fdisk [-u] [-b sectorsize] device fdisk -l [-u] [-b sectorsize] [device ...]

fdisk -s partition ...

fdisk -v

A device name refers to the entire disk. The partition is a device name followed by a partition number. For example, /dev/hda1 is the first partition on the first IDE hard disk in the system. The device is usually one of the following:

Device name Where "a" can be Disk Type

/dev/hda a-h IDE

/dev/sda a-p SCSI

/dev/eda a-d ESDI

257

Page 258: HISTORY AND DEVELOPMENT OF LINUX22

/dev/xda a or b XT

IDE disks can hold up to 64 partitions. SCSI disks can hold up to 15 partitions.

The following table describes the fdisk options used in the above syntax statements.

Option Description

-b sectorsize

Specify the sector size of the disk (512, 1024, or 2048). Current kernels know the sector size. Use this option only on older kernels or to override the kernel defaults.

-l List the partition tables for the specified devices then exit. If no devices are listed, those defined in /proc/partition are listed.

-u List sizes in sectors rather than in cylinders.

-s partition List the size of the partition in blocks.

-v Print the fdisk program version number.

Follow the steps below to learn about partitioning ur system.

Verify that Manually Partition With Disk Druid is selected, and then click on Next. Click on Add to begin creating a partition. Display the Partition Type drop-down list and select Linux

Swap. Create a swap partition the same size as the amount of RAM installed. Click on OK.

Click on Add. Select the /boot mount point. Create a 16 MB Linux Native partition. Click on OK. Click on Add. Select the / mount point. Select Use Remaining Space. Click on OK. Observe the Partitions box in the Disk Druid window. The Requested size is usually close to the actual size. The /

mount point, however, is 1 MB requested and the size of your drive (minus the other partitions) is the actual size. Click on Next. Verify that both the / and /boot partitions are selected for formatting. Read the Online Help window. Click on Next.

258

Page 259: HISTORY AND DEVELOPMENT OF LINUX22

Continuing the Installation:-The next group of windows you are presented with are similar to those you see when you use the workstation or server installation classes.

LILO Configuration:-The next thing you are prompted for is how you want LILO configured. In most cases, you will want to install LILO. You need to determine whether you want LILO installed, where to install LILO, and which is the default boot image.

The default location to install the LILO boot record is the Master Boot Record (MBR) of the first disk. This works well if Linux is the only operating system on the disk or if you have Windows 95/98 installed. If you have Windows NT/2000 installed and are installing LILO, place it on the first sector of the boot partition rather than the MBR. You will also need to create a boot disk or configure the NT system loader to boot LILO from this location. Alternatively, for Windows NT systems, you might not want to install LILO. In either case, you will need to create a boot disk and configure the NT system loader to boot from the boot disk or the first sector of the root partition.

Use Linear Mode is selected by default. Only deselect this option if your drives can't be accessed using linear mode.

By default, Linux is selected as the default boot image. You can change it to DOS if you will usually be booting to the DOS/Windows side of your system.

You can specify whether to create a boot disk. It is strongly recommended that you do so. This disk can be used to boot instead of LILO if LILO becomes corrupted or if another operating system overwrites LILO. The boot disk can be used in the rescue mode in combination with the CD-ROM, the network boot disk, or the boot disk that comes with the Red Hat Linux box set.

Network Configuration:-The next thing you are prompted for is network configuration options. The first thing you have to do is choose whether to use a static IP address or DHCP. If a server on the network has been configured to give out dynamic IP addresses, and you are going to get your IP address from this DHCP server, configure the system accordingly. However, if your Linux box will require a static IP address (for example, if you are using it for a Web server, ftp server, or something that you always want to have the same IP address; or if you don't have a DHCP server to receive a dynamic IP address from), find out which IP address and subnet mask you should assign.

Configure each NIC you have installed in the system. A separate tab on the Network Configuration dialog box is provided for each network card. The naming convention for each card is eth#. This describes Ethernet cards and the # starts with 0 for the first card, and each subsequent card gets the next higher number. Therefore, most systems will have at least eth0. The next card will be eth1.

TIP: If your system doesn�t contain a network card, the Network Configuration dialog box won�t be displayed. Instead, you will go to the Time Zone Selection dialog box.

You need to specify if it will Activate On Boot. This is the default, and what you will want to select. This brings up your network interface when you boot your system.

259

Page 260: HISTORY AND DEVELOPMENT OF LINUX22

If there is a gateway address to reach other networks, specify the IP address of the gateway device. Specify the IP address of the primary DNS server. If you also have a secondary or tertiary DNS server, you can also specify the address of those servers.

Finally, you need to specify the Hostname for your system. If you leave this blank, your system will be known as localhost. Find out if your company has any naming convention that you are to follow for naming your systems.

Time Zone Selection:-The next window displayed is for setting your Time Zone. You can set the time zone by location or UTC (Universal Coordinated Time or Greenwich Mean Time) offset. To set the time zone using the Location tab, click on the map to select a time zone or choose from the list. The map shows the world by default. Use the View drop-down list to display smaller area maps: North America, South America, Pacific Rim, Europe, Africa, or Asia.

To set the time zone using the UTC Offset tab, select the offset required for your location. The UTC Offset list shows how many hours you are from UTC/GMT. You also have the option to specify Use Daylight Saving Time (US Only). If you know that your system clock is set to UTC, check the System Clock Uses UTC check box at the top of the window.

Account Configuration:-When the Account Configuration window is displayed, you can specify the root password and create a regular user. You are required to specify a password for root, and then create at least one user account. You can create additional regular users now if you want to, but in most cases, you will probably want to wait until after the system is up and configured before adding other users to it.

TIP: Be sure to follow good password practices and choose secure passwords using upper and lower case letters combined with numbers. Be sure to record the password and keep it in a safe place, out of sight of others.

Authentication Configuration:-MD5 and shadow passwords are selected by default. It is recommended that you use both of these options unless your network is configured to use NIS authentication. MD5 enables you to have passwords of up to 128 characters rather than the eight character or less passwords required without this option. Shadow passwords are stored in the /etc/shadow file, which is accessible only by root. This is a more secure password feature than the /etc/passwd file.

To configure the NIS option, you must be connected to an NIS (Network Information Service) network. The Enable NIS option enables you to run a group of computers in the same domain with a common password and group file. If you are using NIS, you need to specify the NIS Domain and NIS Server next. The NIS Domain specifies which domain or group of computers your system belongs to. NIS Server enables your computer to use a specific NIS server, instead of requesting any available NIS server to host your system.

The next option you can configure is to Enable LDAP. LDAP consolidates certain types of information within your organization. For example, all of the different lists of users within your organization can be merged into one LDAP directory. If you choose to use LDAP, you need to specify the LDAP Server and the LDAP Base DN. The LDAP Server specifies the server running the LDAP protocol. The LDAP Base DN enables users to look up user information by Distinguished Name (DN).

The final option on the Authentication Configuration page is to Enable Kerberos. Kerberos is a secure system for providing network authentication services. If you choose to enable Kerberos, you will need to configure:

Realm, which enables you to access a network that uses Kerberos, composed of one or more servers and its clients.

KDC, which enables you to access the Key Distribution Center (KDC), a system that can issue Kerberos tickets.

Admin Server, which enables you to access a server running kadmind.

Follow the steps below to continue the installation.

Observe and accept the default LILO settings. By default, LILO is installed in the Master Boot Record on the first hard disk drive. Linux is the default boot image. Click on Next.

In the Network Configuration window, verify that the settings selected are correct. You were prompted for these settings earlier during installation. Click on Next.

260

Page 261: HISTORY AND DEVELOPMENT OF LINUX22

Examine the Time Zone Selection window. You can specify the time zone by location or as a UTC offset. Display the View drop-down list. You can view the clickable map by World, North America, South America, Pacific Rim, Europe, Africa, or Asia. Click on Next.

Assign a root password. Add a user with your first name and assign a password. Click on Add. Click on Next.

Accept the default authentication configuration settings. By default, MD5 and Shadow Passwords are selected. Click on Next.

1. What are the minimum partitions you should create?Ans: The minimum partitions you should create are swap, /boot, and /.

2. What is the partitionless installation option?

Ans: The partitionless installation option allows you to try out Linux without installing it completely.

Lesson 4 Choosing Which Packages to Install

Lesson Objectives

In this lesson, you will:

Identify some of the packages you would install during a typical custom server installation. Define a package group.

Introduction:-One of the primary advantages to installing via the Custom Class is the ability to specify which packages are to be installed during the installation process. The Red Hat Installation application begins by providing a list of package groups that can be installed. These groups are listed in the following table.

Package Group Description

Printer Support Printing support including print filters, conversion utilities, and fonts.

X Window System X Window System, utilities, and applications.

GNOME GNOME Desktop Environment.

KDE KDE Desktop Environment.

Mail/WWW/News Tools Various Mail, World Wide Web, and News client applications.

DOS/Windows Connectivity DOS/Windows compatibility tools including the Samba client and file compression utilities.

Graphics Manipulation Applications for the creation and manipulation of graphical images.

Games Games and entertainment applications.

Laptop Support IrDA and wireless applications for laptops.

Multimedia Support Audio and video support.

Networked Workstation Applications for network configuration and access to remote network resources.

Dialup Workstation Dial-up applications such as PPP and minicom.

News Server InterNetNews (INN) server and utilities.

NFS Server NFS server and portmapper.

SMB (Samba) Server Samba (SMB) server and utilities.

261

Page 262: HISTORY AND DEVELOPMENT OF LINUX22

IPX/NetWareTM Connectivity MARS IPX/NetWare server and IPX utilities.

Anonymous FTP Server wu-ftpd FTP server and an anonymous configuration.

Web Server Apache Web server and various modules and utilities.

DNS Name Server BIND DNS name server and utilities.

SQL Server PostgreSQL RDBMS and development environment.

Network Management Workstation Various utilities for managing networks, including SNMP clients.

Authoring/Publishing Tools for publishing via SGML or the TeX publishing system.

Emacs The Emacs text editor (and more).

Development Compilers, debuggers, and tools for software development.

Kernel Development The source code for the Linux kernel and tools specific to kernel development.

Utilities Miscellaneous utilities for productivity and networking.

Everything Selects all of the package groups for installation.

Selecting Individual Packages:-Package Groups contain several packages. If you want to install only specific packages from within a package group, select Select Individual Packages. If you do so, then the next installation screen displayed will enable you to select the specific packages you want to install.

Unresolved Dependencies:-If you select packages that depend on other packages being installed that aren't yet installed (or selected to be installed), you will be prompted to resolve the dependencies. Your choices are:

Install packages to satisfy dependencies. Do not install packages that have dependencies.

Ignore package dependencies.

Install Packages To Satisfy Dependencies is checked by default. This will automatically resolve any dependencies and add the required packages to those you selected for installation.

Follow the steps below to learn how to select and install package.

Record the default package groups selected. Make the following selections: KDE, Games, Emacs, Development, Kernel Development

Select the Select Individual Packages option. Click on Next. The Individual Package Selection window is displayed.

Observe the window. The list at the left shows the packages you have chosen to install. Expand Amusements and select Games. In the Individual Package Selection window, help isn't displayed by default. Click on Show Help if you want to.

Observe the icons on the right. The packages to be installed have a red check mark on them. Select a package with a red check mark. Observe the description of the package in the lower window. Deselect Select Package For Installation. Continue doing so until just gnome-games is selected.

Expand System Environment, Base, and then double-click on mkkickstart. Click on Next. The installation checks dependencies in packages selected for installation. If it detects any unresolved dependencies, you will be prompted to resolve them.

262

Page 263: HISTORY AND DEVELOPMENT OF LINUX22

In the Unresolved Dependencies window, verify that Install Packages To Satisfy Dependencies is selected, and then click on Next. The screensaver package requires the fortune-mod package to be installed. This option will install that package to resolve the dependency and enable the screensaver to work properly after installation. Notice that the total install size has increased slightly.

Monitor and Video Configuration:-Because you chose to install the GUI environment, X Window System packages, you will be prompted to configure an X server. The utility used to configure X is Xconfigurator.

First, you are prompted to choose the monitor installed on your system. It might be autodetected. If not (or even if it was), you can choose a different monitor if you need to. There is an extensive list that includes most models. However, if your monitor isn't listed, you can use one of the Generic models. You are then prompted for the horizontal and vertical sync ranges. Be careful not to choose a model or specify settings that would overclock your monitor, which could potentially damage or destroy your monitor.

After you configure the monitor, you'll be prompted to configure the video card. Choose your video card from the list presented. If your card isn't listed, you can try to configure it after choosing Unlisted Card. Match your video card chipset with an available X server. Next, you need to specify the amount of video RAM on the video card. If you specify more RAM than actually exists, it might or might not cause a problem; it won't hurt anything, but you might not be able to start the X server.

After making the appropriate monitor and video card choices on the X Configuration dialog box, click the Test This Configuration button. This will verify that your system can use the settings you chose. You will see a small dialog box asking you if you can see it. Click on Yes. If you can't see it, you will be returned to the X Configuration dialog box in a few seconds and can try making other choices.

After you can see the dialog box, you will get a second dialog box asking whether you want the GUI to be the default. In most cases you will want to click on No. Some users might want their systems to boot directly into the GUI, but most administrators will need to work at the command line more often.

Follow the steps below to learn about monitor and video configuration

Select your monitor manufacturer. Expand the selection and select your model. Click on Next. Select your video card hardware from the list. Verify that the video memory detected is correct, and then

click on Test This Configuration. Click on Yes when prompted whether you see the window. If you don't get the dialog box to click Yes on, try selecting a different video card. If necessary, try one of the Generic video options. These options might not give you as good resolution, but should at least let you continue with the installation and have a usable X Configuration. After you have been able to test the configuration successfully, click on Next. The About To Install window is displayed.

In the About To Install window, read the Online Help, and then click on Next. The Installing Packages window is displayed.

Observe as the Partitions are formatted, and as the packages are installed.

Finishing and Checking the Installation:-After the packages are installed, you are prompted to create a boot disk. Remove any install disk that you might still have in the drive; the boot disk creation process will erase all data on the disk. After clicking on Next, there will be a short delay, and then the boot disk is created. Be sure to label it clearly.

If you happen to lose the disk after making it, don't worry. You can create a boot disk later using the mkbootdisk command. If you change your kernel, you might want to make a new boot disk. If you boot from disk and you change your kernel, you'll definitely need to create a new boot disk.

A boot disk can be extremely useful. If another operating system is installed and overwrites the MBR, you can use the boot disk to get to your Linux system.

After the boot disk is created, the Congratulations window is displayed. It contains information on what you need to do to prepare to reboot your system. Make sure you remove any boot medium that might still be in a drive.

263

Page 264: HISTORY AND DEVELOPMENT OF LINUX22

Follow the steps below to learn how to finish and check the installation.

1. When prompted, remove the boot disk and insert a blank disk. Click on Next. After you click on Next, the disk is erased and files are copied to it.

2. Remove the disk from the drive.

3. Read through the Congratulations screen. It explains what to do to reboot the system.

4. Press the Enter key to exit and restart the system.

5. Observe as your system reboots. The boot messages displayed can be useful in determining if the system successfully boots.

6. When the login prompt is displayed, log in as root and do a file listing. This will verify that you can log in and use the system.

7. Examine the log files. Page through the /var/log/messages, /var/log/dmesg, and /tmp/install.log files.

8. Log out, and then log back in.

9. Log out.

1. What are some of the packages you would install during a typical custom server installation?

Ans: Answers might include: Printer Support, X Window System, Gnome, Mail/WWW/News Tools, Multimedia Support, Networked Workstation, Dialup Workstation, Kernel Development, System Environment, DHCP, NFS Server, SMB Server, FTP, and Emacs.

2. What is a package group?

Ans: A package group is a group of related packages, including those that are dependents of other packages.

264