project of rhce

33
Ravi Narain Reg No:-800119695 A PROJECT REPORT ON RHEL 5 Submitted to HCLCDC Patna. RED HAT NETWORD SERVICES AND SECURITY ADMINISTRATION Submitted by Mr. Ravi Narain COMBO BATCH(Pat Com 002) Reg No:-800119695 Under the guidance Mr. Prashant kumar chaudhary. HCLCDC PATNA. 8 th Commercial Building North S.K.Puri 1

Upload: rashmi-naraina

Post on 07-Apr-2015

131 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Project of RHCE

Reg No:-800119695

A PROJECT REPORT

ON

RHEL 5

Submitted to

HCLCDC Patna.

RED HAT NETWORD SERVICES AND SECURITY ADMINISTRATION

Submitted by

Mr. Ravi Narain

COMBO BATCH(Pat Com 002)

Reg No:-800119695

Under the guidance

Mr. Prashant kumar chaudhary.

HCLCDC PATNA.

8th Commercial Building North S.K.Puri

Near Children Park Boring Road Patna.

1

Page 2: Project of RHCE

Reg No:-800119695

ACKNOWLEDGEMENTS

Before I get into think of the things’ would like to add heartfelt words for the people who where part of this PROJECTREPORT in numerous ways……

People who gave unending support.

We are highly indebted to Mr. Amit Kumar Center Manager of HCLCDC Patna, for his encouragement and for providing all the necessary facilities.

It is with great pleasure that we acknowledge the consolation and assistance of Mr. Prashant kumar chaudhary project guide. To him owe more than we can mention…..mostly for teaching us to see the silver lining in every dark cloud.

And finally my heartfelt appreciation to my colleagues. no word are sufficient to express my gratitude to my friend and seniors for their kind cooperation.

Mr. Ravi Narain

2

Page 3: Project of RHCE

Reg No:-800119695

CERTIFICATE

This is to certified that the project report on “RHEL 5” submitted by “Mr. Ravi Narain” as a partial fulfillment for requirement of HCLCDC Patna for the academic session 2007 is the

original work carried out by him under the supervision and guidance of Mr. Prashant kumar chaudhary trainer of HCLCDC PATNA.

HCLCDC Patna Center Manager

Place: Patna Guide

Date: 22/11/2008

3

Page 4: Project of RHCE

Reg No:-800119695

CONTENTS

Case Studies

01. What is Linux

02. Different flavors of Linux & Architecture different from Windows.

03. Compare the user/ group management in Linux & Windows.

04. File System Supported by Linux including file systems native to other OS.

05. Not all of the network driver are supported by Linux, so search the Web and

get the drivers in Rpm’s /binaries and make them work.

06. Configure Mail Server Sendmail.

Project

Add Physical memory to the system and modify the swap partition to make it active.

4

Page 5: Project of RHCE

Reg No:-800119695

LINUX

Linux has long been a contender in the corporate world to Windows . In addition, consumer interest is on the rise for this free, open source alternative to Windows or the Macintosh OS.

In the days before the graphical user interface (GUI), which was first made popular by Apple (Nasdaq: AAPL) and then cloned by Microsoft., the computing world was ruled by the command-line structure. Whether the operating system was Unix or DOS, graphics and audio capabilities were limited. Computer users typed commands at a prompt to run programs. Pointing devices did not exist and menus were rudimentary, text-based options lists.

Linux developed along similar lines as Windows in terms of GUI and performance capabilities with one major distinction -- upgrading from one Windows version to another was fairly seamless. Not so with Linux.

"Linux dominates the server market and is making big inroads into the embedded market (TiVo, cell phones, PDAs and routers)," Patrick Davila, co-host of "The Linux Link Tech Show", told LinuxInsider. "The last area for it to conquer is on the desktop."

All things considered, Davila sees Linux as a suitable replacement for Windows. "Linux is ready for the desktop for the majority of desktop home and business users. It's safer because it is not vulnerable to viruses and spyware, is more stable and is cheaper than running Windows."

Case Studies - 01

Different Flavors

Linux is not just a single operating system. It exists in several dozen versions called distributions. Unlike Windows, no one company has guided the development of Linux. Today, the Linux OS has many faces and is the product of much family cross-breeding.

Its open-source nature continues to contribute to different development paths. Each one is controlled by a unique community of code writers, voluntary technical helpers and users.

5

Page 6: Project of RHCE

Reg No:-800119695

The look and feel of the Linux desktop is controlled by the type of shell built around the Linux core. The two most predominant shell architectures are known as Gnome and KDE . They both have similarities to Windows.

Some Linux distributions are developed on user-friendly standards, but not all of them are easy to use. Even with the desktop shell, configuring the policies for program access can often be confusing and uninviting.

The same can be said of the process of installing third-party software. Linux-capable software is distributed in packages, mostly by download. Depending on the Linux version, some (or a lot of) manual intervention may be needed for software additions not found in the pre-installed software library.

"Linux, by nature of the different users that support each of the distributions, lends itself well to users with specific requirements," said Nate Melby, an instructor at Kaplan University's School of Information Systems and Technology.

The real task is finding a distribution that suits a potential user's needs. Live CDs that can run the newest Linux versions and hard drive partitions running dual-boot software let consumers use their hardware for multiple purposes, he suggested.

The following list includes distributions that are ideal for novices and others that are for more advanced users who have access to IT support:

Debian GNU/Linux is a free operating system with more than 15,490 pre-compiled installation packages. Debian runs on almost all PCs, including many older models.

Knoppix Linux is a free distribution based on Debian GNU/Linux. Knoppix comes with recent Linux software and desktop environments that include OpenOffice.org, Abiword, Gimp, Konqueror, Firefox, Apache, PHP, MySQL and hundreds of other open-source programs.

Mandriva Linux used to be called Mandrake Linux and is famous for its ease of use for both servers and home office uses. The Mandriva Linux PowerPack contains more than 2,300 high-quality applications including a complete office suite. This free distribution comes with several pre-configured levels of security. Commercial support is available.

6

Page 7: Project of RHCE

Reg No:-800119695

Red Hat (NYSE: RHT) Enterprise Linux is the leading commercial platform for open-source computing and is sold by subscription. It is not a good choice for home users and Linux newcomers.

SuSE Linux is a leading, professional-class OS that is popular both for enterprise and home computing use; SuSE Linux Professional includes more than 1,000 leading open-source applications and is available in enterprise and desktop versions. The purchase price varies with the version and the number of installations.

Ubuntu is a free Linux distribution for desktop or server use, which includes Live CD, regular releases, applications installed by default, and fast downloads of other software packages. Professional technical support is available.

Xandros Desktop Home Edition (US$39.99) and Home Edition Premium ($79.99)are built on the Debian Linux platform and include the Xandros Security Suite with the Xandros Firewall, Anti-Virus, Xandros Networks Updates, and a rootkit checker (anti-spyware).

Linux is not a free version of Windows. The two systems differ not only visually, in the graphical user interface the user sees, but also functionally, as is frequently discussed, and legally to boot, which is constantly emphasized by the Free software community. The differences between them are so fundamental that drawing a comparison between them is nearly impossible. There are so many moot points that they could make up a very long list.

This part of my article concerns the architectures of Windows systems. The systems themselves are baffling ones, to put it mildly, but to know them is more than a necessity. (And a forced necessity sometimes…) When I say Windows, I mean the whole family of operating systems - NT/2k/XP/Vista - but mainly XP Professional. Many a time I’ve read anti-Microsoft rants, where the authors complained about lack of command line functionality (poor in Windows and very advanced in Linux), or installation processes, which create some problems and erratic application upgrades (just at the point the comparisons to Linux programs like apt-get, emerge and rpm show up). A lot of grumbles pertaining to wrongly set-up default user and root accounts could be found there. And so on.

These inconveniences are grievous ones in my opinion, more, they should be branded as top-level ones. But the fact remains that something can be done with them - more

7

Page 8: Project of RHCE

Reg No:-800119695

or less. For example, any Windows system I’m talking about here allows to create a user account after all. Linux as well makes it possible to unlock root account to work with. No problem. I must emphasize one thing — it can be done. Regardless whether someone will do it or not. I can’t contradict as well the sentence that Windows’ default configuration is “politically incorrect”. But this very text concerns architectural solutions which cannot be changed one iota, mainly due to project’s “derailed” design philosophy.

I admit to a certain simplifications in comments, even drastic ones, with premeditation. I want the article to be understood by everyone who has a basic knowledge of operating systems, so I ask those who know the subject well to remember this and do not show the signs of the ROTFL syndrome

This is a collection of random thoughts rather than a scientific article about Windows architecture so keep this in mind when reading and commenting.

As we all know, operating systems make use of a “user” notion. We can log in to the user account and then run amok within the “computer space” the account is defined by. With the exception of a group of system functions which are restricted for a unique user called the “system administrator”. This fact is common knowledge. It can be a Unix’s “root”, a NetWare’s “supervisor”, or another “admin”. The distinctive feature of this peculiarity is the fact that the user is a real Master of his system as Zeus was for the ancient Greeks.

Provided that we do not talk about Microsoft Windows systems, otherwise the matter would become more complex. Namely, the Microsoft’s flagship product has at least two distinct administrators, as some of you know (and some of you don’t). One of them is called ADMINISTRATOR user, the other is named SYSTEM user. The standard SYSTEM account is like an “agent” from the Wachowski brothers’ Matrix trilogy. If we look at the process list in Task Manager we’ll see that most of them belong to SYSTEM user. It is also the owner of the technical files like the System Volume Information (SVI) directory and its files. Our electronic friend, the SYSTEM user, is the only default owner of the file, so if we want to check the space it takes we will have to add the ADMINISTRATOR user to the list of permissible users. (Other users can be added too, but I do not recommend this option.)

I will try to explain in the next chapters why I think that “Though this be madness, yet there is method in it”, and that the SYSTEM user is indispensable for the Windows system’s functionality. But now, a short afterthought on its existence taken as a whole. It is common knowledge that every problem in the IT world can be resolved in many ways. Are all of them equally simple? Decidedly no. But the Kiss, “Keep It Simple, Stupid”, rule has proved to work in real life. As I have written above, all operating systems have only one administrator in principle, and that’s a simple solution. That’s for sure, that the existence of another administrator would automatically create certain complications, to put it mildly. A trivial example: nearly all common Windows users do not know how to get into SVI directory (so they don’t need the “advanced users” at all).

8

Page 9: Project of RHCE

Reg No:-800119695

If I wanted to write a dirty trick which gathers a Windows user’s passwords, projects and everyday agenda, I’d put the data just there. First of all, the SVI directory is not visited at all. What’s more, most of the users do not know about its existence. Secondly, the directory evinces a magic feature of changing size in flushes by up to several hundreds of MB - both up and down. (Failover information is stored there). The ideal place. What is important, a computer virus is more efficient if it is able to infect executable files with the highest permissions. Once more, the SYSTEM user is the best for these types of tasks. For sure, the SYSTEM user will not make a hue and cry, as it isn’t Artificially Intelligent.

Making an analysis of a Windows architecture, it might appear that the implementation of the “agent” was vital to the system… Really? I’ll answer in a while.

Let’s vote, which system - Windows or Linux - starts faster. Most IT users would vote for the Windows systems. It is a solid proof for a thesis that one should deal with a democracy with utmost care. I suggest to run a test. Let’s measure the starting times of the two systems with the help of a stopwatch. Let’s start with Windows first. We switch on the computer, we observe POST messages or a BIOS manufacturer’s logo, and at last we face a boot manager (GRUB, LILO, etc.) or we see a system’s loading process. Here we turn on the stopwatch. Boring moments pass. Boredom filling our limbs… The system crunches and minces some data, but we are still lazily yawning… One more time and the login window appears. Most of the users would stop the stopwatch now. Unrecoverable error! The system loading is still going on! We type in a password and we see how the graphical environment emerges. Beg your pardon. The graphical environment and the system. Windows system finishes loading - depending on configuration - after several dozens of seconds after user actually logs in!

To examine the reasons that the system booting process was solved in a particular way, we must start from the ground up, or see to the notion of the system’s kernel. It’s funny - but everyone uses Operating Systems’ names, but only a few know what it really is. If a precise definition cannot be delivered, it is advisable to create a list of features which will describe the idea. However, even the operating systems’ specialist cannot agree how to define operating systems. Nearly all features are the same, but there is always a small “but”. Even the operating system’s bible - Silberschatz’s book (A. Silberschatz, P. Galvin “Operating System Concepts”) names two definitions. Generally, it is considered that the operating system is a program, which runs incessantly in the computer from the beginning (when the operating system has been started, not the computer!) until the computer is turned off (or restarted). All other programs are called “applications”.

An operating system resembles a government. It provides means to proper usage of computer resources. And similar to the government it doesn’t make use of any useful functions. It simply creates an environment in which other programs might facilitate the useful functions.

In this view the operating system’s definition is tantamount to a kernel definition. In other words, one could place an equality sign between the word “kernel” and the technical

9

Page 10: Project of RHCE

Reg No:-800119695

concept of an operating system. Generally, the phrase “operating system” is used to denote all those programs which are provided by a manufacturer to satisfy the demand for such a working environment. That’s why the Linux name is often used to define the whole system, although the name denotes the kernel only. Let’s assume that when I write about kernel I will use a full name - operating system. However, I say “system” when I want to describe all the programs as a whole, together with the kernel.

Now, the difficulties appear. The kernel tasks are defined very loosely. No one knows if management refers to blocking access to system resources or to allowing them to be accessible (e.g. a network card), or it has to deliver a handler (even if a partial one). In practice, the solution is not a simple one, as to master the resources, their specifications must be known. In other words, the problem boils down to one question: whether the kernel should be a program containing complete solutions, however basic, or the program should be focused on only one thing - administration, leaving all the works to do to “external” (to kernel) applications?

With the first example we get a really big program called a monolithic kernel. The second example defines a small and fast microkernel, which looks like an “underdeveloped” version of fully fledged kernel. Monolithic kernels are used by Linux systems (sometimes called Linux distros). Microkernels, for example the Mach microkernel, are foundations to Mac OS X operating systems (attached to Apple computers) and GNU/Hurd operating system which is still in its infancy (which is the case for almost two decades).

And another important matter. An operating system, or every operating system, is build like a cake (or gâteau). As we know the bottom part consists of a layer of biscuit, then it’s covered with sweet fudge, then another biscuit disk, let it be a coffee-flavored one, and once more a fudge layer covered with jelly. As far as programming is concerned, such a layered structure is also used but it’s called abstraction layers. And so as we have the first biscuit level (layer) in a cake which “lies on a hardware” (on a table), so we have a kernel in operating systems which manage the hardware (all operations depend on the layer). Next levels are then build on top of the kernel. For example - first we have X Window System, then on top of it a graphical environment (e.g. KDE), then window manager (e.g. kWin), and only then, on top of all the “layers”, a Firefox web browser. It does matter that every layer sends messages only to its direct neighbors. When a jelly dribbles down onto a table it is high time to lay off the cook.

10

Page 11: Project of RHCE

Reg No:-800119695

Operating System Architecture

Keeping in mind the layered model we will come back to Windows systems’ booting. First of all we have to emphasize that the Windows system’s kernel is similar to a microkernel. (To be more precise, the kernel is called a hybrid kernel - it can be placed between monolithic and microkernels. None the less, it needs many “helpers”).

After starting the computer, the first thing which is loaded is a kernel indeed (ntoskrnl.exe). Next comes its best “friend”, namely HAL module - Hardware Abstraction Layer which manages drivers needed for system loading. When the environment is ready, a Session Manager is put into motion (smss.exe - Session Manager Subsystem) which starts identification and authentication programs - or using simple terms - which shows the login screen. A user satisfied that his Windows “is ready” to use, may enter a password, which makes the system load system permission data (Group Policy) and then have up and running the tasks defined in Runonce and Run keys placed in Windows Registry (e.g. HKLM\SOFTWARE\Microsoft\CurrentVersion\Runonce). At the end, Autostart (from Start Menu) applications are loaded.

Linux systems present a different approach towards this problem. After the monolithic kernel has been loaded, the init process is started, which in turn invokes other processes (I suggest to issue a pstree command in a console while this happens). Practically, all the necessary system processes are started during the system start. So when a user sees login window (or screen) the only thing left to do is to attend to the KDE or GNOME graphical environments. Anything beyond that is ready to use. (Ubuntu team works at present to replace the init script with an upstartscript. But it doesn’t affect our reasoning.)

11

Page 12: Project of RHCE

Reg No:-800119695

The question - which solution is better - must be left without an answer. However, a short digression must be added to the end. Microsoft uses the trick notoriously. As psychology teaches, the most frustrating is a man’s inability to act and his lack of influence on any processes, so moving the login phase into the middle of starting sequence of events, will give the user psychological comfort and it will be received better. And even though the monitor has displayed the famous task bar and icons, no one will be able to load an advanced spreadsheet application or a game. Most of the users are aware they must wait a while yet. Such solution is a better one than previous ones in terms of marketing but it backlashes in lesser stability or the system’s safety and leads sometimes to the frustration of inexperienced users.

Taking into consideration the whole start sequence - Linux doesn’t load slower than Windows systems. The foundation of operating systems, that is, all what is hidden behind the name is known for years. There’s no wizardry in this world.

Operating System

Why the opinion that Linux systems are safer than the Windows systems is so prevalent? Perhaps due to the fact that it is true. But why? Let’s go back to the previous point. As I wrote, an operating system resembles a cake. You’ll find its kernel at the bottom, and its applications placed on top. According to the cake, picture the kernel together with associated programs creating a so called kernel layer. The rest of the running tasks make up a user layer. In other words - the kernel layer creates an environment in which the user layer is ran. The system is divided into two - upper and lower parts.

We can simplify the matter if we are to write about the Linux, Mach (Mac OS X kernel), Solaris or BSD systems. Safety tasks are run within the kernel layer. Basically, in the kernel alone. The Mach microkernel has additional safety modules which run in the kernel layer

12

Page 13: Project of RHCE

Reg No:-800119695

as auxiliary programs. Protection in Unix systems is always on, moreover, it is simple in terms of design and due to that statistically tougher to crack.

The same cannot be said about Windows systems. The protection subsystems are more complex and they run within the user layer. The logic lying behind is screwed up. The operating system is deaf and blind. It creates an environment. The programs which can “talk” to the environment are started in the user layer, so the protection which works on the same level should be efficient. Read from a paper, it is true, but life is not so rosy. First of all, any program running in the user layer (protection is implemented as another program) is more vulnerable or prone to “disarmament” than protection implemented in the kernel layer. For second, one of the most popular computer protection systems, not playing with details, is a firewall. As it works in the user layer, it must be designed in such a way that it shouldn’t find itself not starting in the system’s loading process. At last, it is a program, and contrary to the kernel itself, it doesn’t have to work.

A small digression. I have written earlier about the “SYSTEM user”. This SYSTEM is needed by the Windows systems to start programs in the user layer, among others. After all, we mustn’t wait to launch a firewall until John Smith is logged-in (after several hours in which his computer has been up and running). So the SYSTEM user is used. But it suffices, like in the Mach example, to place the protection subsystem in lower layer and have the problem off of a head.

Let’s assume something like this. I have logged in to a Windows system as a common user. Let’s check what disks have been attached to my system or speaking precisely - what disks have been mapped to my system. I have found, as a “normal” user, a few network disks from two servers. My computer runs several programs. You’ll find among them local ones, one from the first server, and another one from the second server. All the applications make use of several dozen files at once, some of them placed on the two servers.

Let’s assume now that at one time I have decided to read the data from a file owned by a server administrator (and it has just happened to be me). Oh, Lord! How I did yearn to work with any Unix system in such conditions! Any attempt to attach admin resources will end up with the message: “Multiple links to server or to shared resources by the same user, making use of the user’s name more than once, is not allowed. Disconnect all previous server connections and try to reconnect.” Marvelous!

If I was working under Linux or OS X I’d be able to mount the needed device and to make use of a file, using a nice and simple program called smbmount. The program treats every connection as a unique one and “pays no attention” to such conditions where another copy of itself has just made a connection to the same device under the name of another user. This is the direct result of conceptually complex design of the user layer, which I described earlier in this article. It can be commented only one way: another proof for superiority of simplicity over complexity.

13

Page 14: Project of RHCE

Reg No:-800119695

It is not the author’s intention to rekindle another flame war between Windows and Linux users. The author asks both sides interested in this topic to refrain from darting names onto each other. If one feels necessity to comment the article, please write “it is bad or not”, or point where it should be rewritten in a broader perspective - what doesn’t mean it should show superiority of one of the systems over the other. Such a statement would be highly subjective. And when I reckon Windows’ architecture inferior to Linux one, it doesn’t mean it is inferior. They differ. Writing operating system is a complex matter and too many times the chosen solution is so called “a solution of lesser evil”. One is able to write a similar “list” of architectural items pertaining to Linux systems, but it would have nothing to do with Photoshop running or not on every of the two systems.

Case Studies - 02

Users and Groups Management in Linux

Control of users and groups is a core element of Red Hat Linux system administration.

Users can be either people, meaning accounts tied to physical users, or accounts which exist for specific applications to use.

Groups are logical expressions of organization, tying users together for a common purpose. Users within the same group can read, write, or execute files owned by the group.

Each user and group have a unique numerical identification number called a userid (UID) and a groupid (GID) respectively.

When a file is created, it is assigned a user and group owner. It is also assigned separate read, write, and execute permissions for the owner, the group, and everyone else. The user and the group to which a file belongs, as well as the access permissions on the file, can be changed by the root user or, in most cases, by the creator of the file.

Proper management of users and groups, and effective management of file permissions are among the most important tasks a system administrator undertakes. For a detailed look at strategies for managing users and groups, refer to the chapter titled Managing Accounts and Group in the Red Hat Linux System Administration Primer.

14

Page 15: Project of RHCE

Reg No:-800119695

User and Group Management in Windows

The group is is one area where win.mit.edu, or WIN, diverges from a typical Windows Domain. WIN users and groups are defined and maintained in the MIT system of record, Moira.

There are a variety of tools available to add an existing user to an existing group. These include the Moira list management web interface, moira commands like blanche, and the WIN machine Moira MMC snap-in.

On a WIN machine you may run moira or blanche from the command line or the run menu. You may also start the Moira MMC snap-in from the menu item "Start-> Programs-> Administrative Tools-> Moira Account Management."

Moira MMC Procedure

To add a user to a group using the Moira MMC:

1. Select List Management from the left panel and right click on the selection. 2. Select Find Lists. 3. Click on Name, enter the list name and hit Search. 4. Select the list name and hit Display. 5. Right click on the list name and select Properties. 6. Click on the Members tab. 7. If you have the permission, the Add button will be sensitized, so click on it. 8. Choose the type of object you wish to add and enter its name. 9. Click OK.

Case Studies - 03

File System

It keep the data in organized. It allocates the space to the and directories and it assign attributes to the file directories.

Linux used ext2 & ext3

It arrange all the file and directories in highrical way

15

Page 16: Project of RHCE

Reg No:-800119695

/ This is toplable directory in the highrical which is called root. It is the top of the file system structure . All the directory are mounted under it.

16

Page 17: Project of RHCE

Reg No:-800119695

17

Page 18: Project of RHCE

Reg No:-800119695

This is a layout from a RedHat system. Depending on the system admin, the operating system and the mission of the UNIX machine, the structure may vary, and directories may be left out or added at will. The names are not even required; they are only a convention.

The tree of the file system starts at the trunk or slash, indicated by a forward slash (/). This directory, containing all underlying directories and files, is also called the root directory or "the root" of the file system.

Directories that are only one level below the root directory are often preceded by a slash, to indicate their position and prevent confusion with other directories that could have the same name. When starting with a new system, it is always a good idea to take a look in the root directory. Let's see what you could run into:

Directory Content

/bin Common programs, shared by the system, the system administrator and the users.

/bootThe startup files and the kernel, vmlinuz. In some recent distributions also grub data. Grub is the GRand Unified Boot loader and is an attempt to get rid of the many different boot-loaders we know today.

/dev Contains references to all the CPU peripheral hardware, which are represented as files with special properties.

/etc Most important system configuration files are in /etc, this directory contains data similar to those in the Control Panel in Windows

/home Home directories of the common users.

/initrd (on some distributions) Information for booting. Do not remove!

/lib Library files, includes files for all kinds of programs needed by the system and the users.

/lost+found Every partition has a lost+found in its upper directory. Files that were saved during failures are here.

/misc For miscellaneous purposes.

/mnt Standard mount point for external file systems, e.g. a CD-ROM or a digital camera.

/net Standard mount point for entire remote file systems

/opt Typically contains extra and third party software.

/procA virtual file system containing information about system resources. More information about the meaning of the files in proc is obtained by entering the command man proc in a terminal window. The file proc.txt discusses the virtual file system in detail.

18

Page 19: Project of RHCE

Reg No:-800119695

Directory Content

/rootThe administrative user's home directory. Mind the difference between /, the root directory and /root, the home directory of the root user.

/sbin Programs for use by the system and the system administrator.

/tmp Temporary space for use by the system, cleaned upon reboot, so don't use this for saving any work!

/usr Programs, libraries, documentation etc. for all user-related programs.

/varStorage for all variable files and temporary files created by users, such as log files, the mail queue, the print spooler area, space for temporary storage of files downloaded from the Internet, or to keep an image of a CD before burning it.

Case Studies - 04

Software project site – Often individual software project will offer their own set of RPM packages for their own project. This is particularly useful for project under continuous development. If the project doesn’t offer RPMs, they will typically offer code in what is called a tarball. The tarball may include binary code or more often, source code you can build for your environment.

Most fedora repositories are light on descriptions of the packages they offer. The following list summarizes some other Web sites that you can browse to find detailed information about software that runs in Linux. Then you can search Fedora repositories for Fedora- or RHEL-specific versions of those packages

*Freshment(www.freshmeat.net) – this site maintains a massive index of Linux Software. You can do keyword searches for software projects or browse for software by category.

*SourceForge (www.sourceforge.net) – This site hosts thousands of open source software projects. You can download software and documentation from those projects through the SourceForge site.

*Rpmfind (www.rpmfingd.net) – This site hosts thousands of open source software that is package in the RPM Package Management(RPM) format across a variety of repositories. You can do a keyword search from this Website.

We can just download a single software package to get the software in that package to word. Many package depends on other packages. For example software package for playing audio & video typically rely on other software packages for decoding different kinds of content.

19

Page 20: Project of RHCE

Reg No:-800119695

Case Studiesb - 05

Sendmail should be installed by default when you install Red Hat Linux. If it is not then you need to install the Sendmail RPM's with the Red Hat distribution.

Download the Sendmail RPM's from the RedHat website, from a mirror or from your Red Hat installation CD.

These RPM's are required:

sendmail-{ver}.i386.rpm sendmail-cf-{ver}.i386.rpm sendmail-devel-{ver}.i386.rpm

Configuring Sendmail

1). Edit file "/etc/mail/sendmail.mc" - Look for the line:

DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')

Change this line to:

dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')

Save the file.

2). Make the sendmail configuration file:

$> m4 /etc/mail/sendmail.mc > /etc/sendmail.cf

3).Restart Sendmail:

$> /etc/rc.d/init.d/sendmail restart

PROJECT ON RHEL 5

20

Page 21: Project of RHCE

Reg No:-800119695

All about Linux swap space

When your computer needs to run programs that are bigger than your available physical memory, most modern operating systems use a technique called swapping, in which chunks of memory are temporarily stored on the hard disk while other data is moved into physical memory space. Here are some techniques that may help you better manage swapping on Linux systems and get the best performance from the Linux swapping subsystem.

Linux divides its physical RAM (random access memory) into chucks of memory called pages. Swapping is the process whereby a page of memory is copied to the preconfigured space on the hard disk, called swap space, to free up that page of memory. The combined sizes of the physical memory and the swap space is the amount of virtual memory available.

Swapping is necessary for two important reasons. First, when the system requires more memory than is physically available, the kernel swaps out less used pages and gives memory to the current application (process) that needs the memory immediately. Second, a significant number of the pages used by an application during its startup phase may only be used for initialization and then never used again. The system can swap out those pages and free the memory for other applications or even for the disk cache.

However, swapping does have a downside. Compared to memory, disks are very slow. Memory speeds can be measured in nanoseconds, while disks are measured in milliseconds, so accessing the disk can be tens of thousands times slower than accessing physical memory. The more swapping that occurs, the slower your system will be. Sometimes excessive swapping or thrashing occurs where a page is swapped out and then very soon swapped in and then swapped out again and so on. In such situations the system is struggling to find free memory and keep applications running at the same time. In this case only adding more RAM will help.

Linux has two forms of swap space: the swap partition and the swap file. The swap partition is an independent section of the hard disk used solely for swapping; no other files can reside there. The swap file is a special file in the filesystem that resides amongst your system and data files.

To see what swap space you have, use the command swapon -s. The output will look something like this:

Filename Type Size Used Priority/dev/sda5 partition 859436 0 -1

Each line lists a separate swap space being used by the system. Here, the 'Type' field indicates that this swap space is a partition rather than a file, and from 'Filename' we see that it is on the disk sda5. The 'Size' is listed in kilobytes, and the 'Used' field tells us how many kilobytes of swap space has been used (in this case none). 'Priority' tells Linux which swap space

21

Page 22: Project of RHCE

Reg No:-800119695

to use first. One great thing about the Linux swapping subsystem is that if you mount two (or more) swap spaces (preferably on two different devices) with the same priority, Linux will interleave its swapping activity between them, which can greatly increase swapping performance.

To add an extra swap partition to your system, you first need to prepare it. Step one is to ensure that the partition is marked as a swap partition and step two is to make the swap filesystem. To check that the partition is marked for swap, run as root:

fdisk -l /dev/hdb

Replace /dev/hdb with the device of the hard disk on your system with the swap partition on it. You should see output that looks like this:

Device Boot Start End Blocks Id System/dev/hdb1 2328 2434 859446 82 Linux swap / Solaris

If the partition isn't marked as swap you will need to alter it by running fdisk and using the 't' menu option. Be careful when working with partitions -- you don't want to delete important partitions by mistake or change the id of your system partition to swap by mistake. All data on a swap partition will be lost, so double-check every change you make. Also note that Solaris uses the same ID as Linux swap space for its partitions, so be careful not to kill your Solaris partitions by mistake.

Once a partition is marked as swap, you need to prepare it using the mkswap (make swap) command as root:

mkswap /dev/hdb1

If you see no errors, your swap space is ready to use. To activate it immediately, type:

swapon /dev/hdb1

You can verify that it is being used by running swapon -s. To mount the swap space automatically at boot time, you must add an entry to the /etc/fstab file, which contains a list of filesystems and swap spaces that need to be mounted at boot up. The format of each line is:

<file system> <mount point> <type> <options> <dump> <pass>

Since swap space is a special type of filesystem, many of these parameters aren't applicable. For swap space, add:

/dev/hdb1 none swap sw 0 0

22

Page 23: Project of RHCE

Reg No:-800119695

where /dev/hdb1 is the swap partition. It doesn't have a specific mount point, hence none. It is of type swap with options of sw, and the last two parameters aren't used so they are entered as 0.

To check that your swap space is being automatically mounted without having to reboot, you can run the swapoff -a command (which turns off all swap spaces) and then swapon -a (which mounts all swap spaces listed in the /etc/fstab file) and then check it with swapon -s.

Swap file

As well as the swap partition, Linux also supports a swap file that you can create, prepare, and mount in a fashion similar to that of a swap partition. The advantage of swap files is that you don't need to find an empty partition or repartition a disk to add additional swap space.

To create a swap file, use the dd command to create an empty file. To create a 1GB file, type:

dd if=/dev/zero of=/swapfile bs=1024 count=1048576

/swapfile is the name of the swap file, and the count of 1048576 is the size in kilobytes (i.e. 1GB).

Prepare the swap file using mkswap just as you would a partition, but this time use the name of the swap file:

mkswap /swapfile

And similarly, mount it using the swapon command: swapon /swapfile.

The /etc/fstab entry for a swap file would look like this:

/swapfile none swap sw 0 0

How big should my swap space be?

It is possible to run a Linux system without a swap space, and the system will run well if you have a large amount of memory -- but if you run out of physical memory then the system will crash, as it has nothing else it can do, so it is advisable to have a swap space, especially since disk space is relatively cheap.

The key question is how much? Older versions of Unix-type operating systems (such as Sun OS and Ultrix) demanded a swap space of two to three times that of physical memory. Modern implementations (such as Linux) don't require that much, but they can use it if you

23

Page 24: Project of RHCE

Reg No:-800119695

configure it. A rule of thumb is as follows: 1) for a desktop system, use a swap space of double system memory, as it will allow you to run a large number of applications (many of which may will be idle and easily swapped), making more RAM available for the active applications; 2) for a server, have a smaller amount of swap available (say half of physical memory) so that you have some flexibility for swapping when needed, but monitor the amount of swap space used and upgrade your RAM if necessary; 3) for older desktop machines (with say only 128MB), use as much swap space as you can spare, even up to 1GB.

The Linux 2.6 kernel added a new kernel parameter called swappiness to let administrators tweak the way Linux swaps. It is a number from 0 to 100. In essence, higher values lead to more pages being swapped, and lower values lead to more applications being kept in memory, even if they are idle. Kernel maintainer Andrew Morton has said that he runs his desktop machines with a swappiness of 100, stating that "My point is that decreasing the tendency of the kernel to swap stuff out is wrong. You really don't want hundreds of megabytes of BloatyApp's untouched memory floating about in the machine. Get it out on the disk, use the memory for something useful."

One downside to Morton's idea is that if memory is swapped out too quickly then application response time drops, because when the application's window is clicked the system has to swap the application back into memory, which will make it feel slow.

The default value for swappiness is 60. You can alter it temporarily (until you next reboot) by typing as root:

echo 50 > /proc/sys/vm/swappiness

If you want to alter it permanently then you need to change the vm.swappiness parameter in the /etc/sysctl.conf file.

Conclusion

Managing swap space is an essential aspect of system administration. With good planning and proper use swapping can provide many benefits. Don't be afraid to experiment, and always monitor your system to ensure you are getting the results you need.

24