linux administration - information technology...the main concept that unites all versions of unix is...

35
Linux Administration UNIT 1 Ch 1 : INTRODUCTION An Introduction to UNIX, Linux, and GNU. In recent years Linux has become a phenomenon. Various organizations that have adopted it, including some government departments and city administrations. Major hardware vendors like IBM and Dell now support Linux, and major software vendors like Oracle support their software running on Linux. Linux truly has become a viable operating system, especially in the server market. Q) What is Unix ? The UNIX operating system is a set of programs that act as a link between the computer and the user. The computer programs that allocate the system resources and coordinate all the details of the computer's internals is called the operating system or kernel. Users communicate with the kernel through a program known as the shell. The shell is a command line interpreter; it translates commands entered by the user and converts them into a language that is understood by the kernel. Unix was originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Douglas McIlroy, and Joe Ossanna. There are various Unix variants available in the market. Solaris Unix, AIX, HP Unix and BSD are few examples. Linux is also a flavor of Unix which is freely available. Several people can use a UNIX computer at the same time; hence UNIX is called a multiuser system. A user can also run multiple programs at the same time; hence UNIX is called multitasking. Q) A Brief History of Unix: 1. The Unix operating system found its beginnings in MULTICS, which stands for Multiplexed Operating and Computing System. The MULTICS project began in the mid 1960s as a joint Prepared by Prof. Sweta Chheda Page 1

Upload: others

Post on 09-Apr-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Linux Administration

UNIT 1

Ch 1 : INTRODUCTION

An Introduction to UNIX, Linux, and GNU.

In recent years Linux has become a phenomenon. Various organizations that have adopted it,

including some government departments and city administrations.

Major hardware vendors like IBM and Dell now support Linux, and major software vendors like Oracle support their software running on Linux.

Linux truly has become a viable operating system, especially in the server market.

Q) What is Unix ?

The UNIX operating system is a set of programs that act as a link between the computer and the user.

The computer programs that allocate the system resources and coordinate all the details of the computer's internals is called the operating system or kernel.

Users communicate with the kernel through a program known as the shell. The shell is a command line interpreter; it translates commands entered by the user and converts them into a language that is understood by the kernel.

Unix was originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken

Thompson, Dennis Ritchie, Douglas McIlroy, and Joe Ossanna.

There are various Unix variants available in the market. Solaris Unix, AIX, HP Unix and BSD are few examples. Linux is also a flavor of Unix which is freely available.

Several people can use a UNIX computer at the same time; hence UNIX is called a multiuser system.

A user can also run multiple programs at the same time; hence UNIX is called multitasking.

Q) A Brief History of Unix:

1. The Unix operating system found its beginnings in MULTICS, which stands for Multiplexed Operating and Computing System. The MULTICS project began in the mid 1960s as a joint

Prepared by Prof. Sweta Chheda Page 1

effort by General Electric, Massachusetts Institute for Technology and Bell Laboratories. In 1969 Bell Laboratories pulled out of the project.

2. One of Bell Laboratories people involved in the project was Ken Thompson. He liked the potential MULTICS had, but felt it was too complex and that the same thing could be done in simpler way. In 1969 he wrote the first version of Unix, called UNICS. UNICS stood for Uniplexed Operating and Computing System. Although the operating system has changed, the name stuck and was eventually shortened to Unix.

3. Ken Thompson teamed up with Dennis Ritchie, who wrote the first C compiler. In 1973 they rewrote the Unix kernel in C. The following year a version of Unix known as the Fifth Edition was first licensed to universities. The Seventh Edition, released in 1978, served as a dividing point for two divergent lines of Unix development. These two branches are known as SVR4 (System V) and BSD.

4. Ken Thompson spent a year's sabbatical with the University of California at Berkeley. While there he and two graduate students, Bill Joy and Chuck Haley, wrote the first Berkely version of Unix, which was distributed to students. This resulted in the source code being worked on and developed by many different people. The Berkeley version of Unix is known as BSD, Berkeley Software Distribution. From BSD came the vi editor, C shell, virtual memory, Sendmail, and support for TCP/IP.

5. For several years SVR4 was the more conservative, commercial, and well supported. Today SVR4 and BSD look very much alike. Probably the biggest cosmetic difference between them is the way the ps command functions.

6. The Linux operating system was developed as a Unix look alike and has a user command interface that resembles SVR4.

Q) Architecture of UNIX OS: Here is a basic block diagram of a UNIX system:

Prepared by Prof. Sweta Chheda Page 2

The main concept that unites all versions of UNIX is the following four basics:

Kernel: The kernel is the heart of the operating system. It interacts with hardware and most of the

tasks like memory management, tash scheduling and file management. Shell: The shell is the utility that processes your requests. When you type in a command at your

terminal, the shell interprets the command and calls the program that you want. The shell uses standard syntax for all commands. C Shell, Bourne Shell and Korn Shell are most famous shells which are available with most of the Unix variants.

Commands and Utilities: There are various command and utilities which you would use in your

day to day activities. cp, mv, cat and grep etc. are few examples of commands and utilities. There are over 250 standard commands plus numerous others provided through 3rd party software. All the commands come along with various optional options.

Files and Directories: All data in UNIX is organized into files. All files are organized into

directories. These directories are organized into a tree-like structure called the filesystem.

Q) UNIX Philosophy/Characteristics

1) Simplicity i) Many of the most useful UNIX utilities are very simple and, as a result, small and easy

to understand. ii) Larger, more complex systems are guaranteed to contain larger, more complex bugs, and

debugging is a chore that should be avoided. iii) KISS, ―Keep It Small and Simple,‖ is a good technique to learn. iv)

Prepared by Prof. Sweta Chheda Page 3

2) Focus i) It‘s often better to make a program perform one task well than feature-bloat programs

because such programs are difficult to maintain. ii) Programs with a single purpose are easier to improve as better algorithms or

interfaces are developed. iii) In UNIX, small utilities are often combined to perform more demanding tasks when

the need arises, rather than trying to anticipate a user‘s needs in one large program. 3) Reusable Components:

i) This Make the core of application available as a library. ii) Well-documented libraries with simple but flexible programming interfaces can help

others to develop variations or apply the techniques to new application areas. iii) Examples include the dbm database library, which is a suite of reusable functions rather

than a single database management program. 4) Filters:

i) Many UNIX applications can be used as filters. That is, they transform their input and produce output.

ii) UNIX provides facilities that allow quite complex applications to be developed from other UNIX programs by combining them in new ways.

iii) This kind of reuse is enabled by reusable component feature. 5) Open File Formats:

i) The more successful and popular UNIX programs use configuration files and data files that are plain ASCII text or XML.

ii) This is good choice for application development. iii) It enables users to use standard tools to change and search for configuration items and to

develop new tools for performing new functions on the data files. 6) Flexibility:

i) This means writing the program so that its network-aware and able to run across a network as well as on a local machine. ii) You can‘t anticipate exactly how ingeniously users will use your program. Try to be as flexible as possible in your programming. Try to avoid arbitrary limits on field sizes or number of records. iv) Never assume that you know everything that the user might want to do.

Q) Linux Distribution (April2013)

Linux is actually just a kernel. You can obtain the sources for the kernel to compile and install it on a machine and then obtain and install many other freely distributed software programs to make a complete Linux installation.

These installations are usually referred to as Linux systems, because they consist of much

more than just the kernel. Most of the utilities come from the GNU Project of the Free Software Foundation.

Creating a Linux system from just source code is a major.

Fortunately many people have put together ready-to-install distributions(often called flavors), that contain not just the kernel but also many other programming tools and utilities.

These often include an implementation of the X Window System, a graphical

environment common on many UNIX systems. Prepared by Prof. Sweta Chheda Page 4

The distribution usually come with a setup program and additional documentation to help

you install your own Linux system. Some well known commercially backed distributions are Fedora (Red Hat), openSUSE

(SUSE), Ubuntu (Canonical Ltd.), and Mandriva Linux (Mandriva), and entirely community-driven distributions, such as Debian, Slackware and Gentoo.

Q) Distinguish between Windows and Linux/Unix.

1) DOS/Windows :

Files, folders & devices treats as it is.

No case sensitive.

Not proper structure of shell and one shell is utilized for all users.

Virus affection is more. CPU + I/O + Memory utilization is more.

2)Linux/Unix :

Linux treats everything as a files

Case sensitive

Properly design shell for each user

Virus affection is less

CPU + I/O + Memory utilization is less.

Q) The GNU Project and the Free Software Foundation (April 2013)

1. Linux owes its existence to the cooperative efforts of a large number of people. The

operating system kernel itself forms only a small part of a usable development system.

2. Commercial UNIX systems traditionally come bundled with applications that provide system services and tools. but for Linux systems, these additional programs have been written by many different programmers and have been freely contributed.

3. The Linux community (together with others) supports the concept of free software, that is,

software that is free from restrictions, subject to the GNU General Public License (the name GNU stands for the recursive GNU’s Not Unix).

4. Although there may be a cost involved in obtaining the software, it can thereafter be used

in any way desired and is usually distributed in source form.

5. The Free Software Foundation was set up by Richard Stallman, the author of GNU Emacs,

one of the best-known text editors for UNIX and other systems.

6. Stallman is a pioneer of the free software concept and started the GNU Project, an attempt

to create an operating system and development environment that would be compatible with UNIX.

7. The GNU Project has already provided the software community with many applications

that closely mimic those found on UNIX systems under the license of GNU. Prepared by Prof. Sweta Chheda Page 5

8. A few major examples of software from the GNU Project distributed under the GPL follows GCC: The GNU Compiler collection, containing the GNU C compiler

G++ : A G++ compiler included as a part of GCC

Bash : a command shell

GNU : A command shell GNU Emacs : A text editor and evironment

9. Many other packages have been developed and released using free software principles and the GPL, including spreadsheets, source code control tools, compilers and interpreters, Internet tools, graphical image manipulation tools such as the Gimp, and two complete object-based environments: GNOME and KDE.

10. There is now so much free software available that with the addition of the Linux kernel it

could be said that the goal of a creating GNU, a free UNIX-like system, has been achieved with Linux.

Q) What is linux and Components of Linux System.

1)Components of Linux System

Linux Operating System has primarily three components

Kernel - Kernel is the core part of Linux. It is responsible for all major activities of this operating

system. It is consists of various modules and it interacts directly with the underlying hardware. Kernel provides the required abstraction to hide low level hardware details to system or application programs.

System Library - System libraries are special functions or programs using which application

programs or system utilities accesses Kernel's features. These libraries implements most of the functionalities of the operating system and do not requires kernel module's code access rights.

System Utility - System Utility programs are responsible to do specialized, individual level tasks.

What Is Linux?

Prepared by Prof. Sweta Chheda Page 6

1. Linux is a freely distributed implementation of a UNIX-like kernel, the low-level core of an

operating system. 2. Because Linux takes the UNIX system as its inspiration, Linux and UNIX programs are very

similar. In fact, almost all programs written for UNIX can be compiled and run on Linux. 3. Some commercial applications sold for commercial versions of UNIX can run unchanged

in binary form on Linux systems. Linux History :

4. Linux was developed by Linus Torvalds at the University of Helsinki, with the help of UNIX programmers from across the Internet.

5. It began as a hobby of Linus Torvalds who was inspired by Andy Tanenbaum‘s Minix, a small UNIX like system, but has grown to become a complete system in its own right.

6. The Linux was having copyright but it can be freely distributed. 7. Versions of Linux are now available for a wide variety of computer systems using many

different types of CPUs. 8. Even some handheld PDAs and Sony‘s Playstations 2 and 3 run on Linux. If it‘s got

a processor, someone somewhere is trying to get Linux running on it.

Q) What is kernel mode v/s user mode? Kernel Mode vs User Mode

Kernel component code executes in a special privileged mode called kernel mode with full access to all resources of the computer. This code represents a single process, executes in single address space and do not require any context switch and hence is very efficient and fast. Kernel runs each processes and provides system services to processes, provides protected access to hardwares to processes.

Support code which is not required to run in kernel mode is in System Library. User

programs and other system programs works in User Mode which has no access to system hardwares and kernel code. User programs/ utilities use System libraries to access Kernel functions to get system's low level tasks.

Ch 2 : DUTIES OF SYSTEM ADMINISTATOR

Q) Who is a system administrator ? The Linux System Administrator

1. LINUX is a multiuser, multitasking operating system from the ground up, and hence the

system administrator has flexibility and responsibility far beyond those of other operating systems.

2. New tools : Administrating System is sophisticated task hence system administrator should be acquainted with new tools in order to manage System.

3. Make no mistake: Every System Administrator decides which Application Software‘s and Peripherals Machine should have. If a user decide to have a particular application then we can say that user has taken mantle of System Administrator.

4. Precaution from Virus Attacks : When System is connected with internet there is prone of virus attacks, attacks can be Distributed Denial of Service (DDoS) or e-mail macro virus etc.

Prepared by Prof. Sweta Chheda Page 7

5. Understand Control of Linux : The Linux system administrator is more likely to

understand the necessity of active system administration than are those who run whatever came on the computer, assuming that things came from the factory properly configured.

6. Definition :- Linux system administrator :- Linux system administrator is the person who has ―root‖ access, which is to say the one who is the system‘s ―super user.‖

7. A standard Linux user is limited as to the things he or she can do with the underlying engine of the system.

8. But the ―root‖ user has unfettered(open) access to everything i.e. all user accounts, their home directories, and the files which are present in, all system configurations and all files on the system.

Q) Explain the duties of System Administrator. The person who is responsible for setting up and maintaining the system is called as the system

administrator. System administrators may be members of an information technology department.

Most of the following discussion also applies to network and Windows system admins. Duties of a system administrator The duties of a system administrator are wide-ranging, and vary widely from one organization to

another. Sysadmins are usually charged with installing, supporting, and maintaining servers or other

computer systems, and planning for and responding to service outages and other problems. Other duties

may include scripting or light programming, project management for systems-related projects. The system administrator is responsible for following things: 1. User administration (setup and maintaining account) 2. Maintaining system 3. Verify that peripherals are working properly 4. Quickly arrange repair for hardware in occasion of hardware failure 5. Monitor system performance 6. Create file systems 7. Install software 8. Create a backup and recover policy 9. Monitor network communication 10. Update system as soon as new version of OS and application software comes out 11. Implement the policies for the use of the computer system and network 12. Setup security policies for users. A system admin must have a strong grasp of computer security

(e.g. firewalls and intrusion detection systems). Q) Installing and Configuring Servers (april 2013)

Computer that specifically performs services for many users in a server

Broader meaning of server in Linux :

Prepared by Prof. Sweta Chheda Page 8

Graphical Desktop requires X SERVER. Printing requires Printing Server. Web access requires Web Server

Whenever a server is connected to machines outside your physical control, security issues

arise.

You want users to have easy access to the things they need, but you don‘t want to open up the system you‘re administering to the whole wide world.

Most of the imaginable servers are turned on by default.

But most essential servers remain turned off unless specifically enabled and configured.

This duty falls to the system administrator. To know exactly which server you need and how to employ them.

To be aware of potential security nightmare to enable the services that system is not using and does not need.

Thereby, enabling/disabling and configuring server services.

Q) Installing and Configuring Application Software.

It is possible for individual users to install some applications in their home directories, drive space set aside for their own files and customizations these applications are not available to other users without the intervention of the system administrator.

For multiuser, an application is to be installed higher up in the Linux File Hierachy(only

system administrator can perform)

The administrator can limit which users may use which applications by creating a ―group‖ for that application and enrolling individual users into that group.

Software packages might be installed in : 1. /opt : if they are likely to be upgraded separately from the Red Hat Linux distribution itself. 2. /usr or /usr/src : if they are upgrades of packages installed as part of Red Hat Linux. In Red Hat Package Manager (RPM) packages automatically goes where it should.

Q) procedure of creating and maintaining User Accounts. 1. In Linux machine an account must be created for each user and system administrator

creates account for each user. Eg : # useradd sweta(user account name)

2. System administrator can give option to users to change their own password. Eg: #passwd tyitnotes(user account password from System administrator)

New passwd : (at this step user can select his own password) Retype new passwd :

3. System administrator can configure a setting to prompt user that they must change password periodically.

4. System Administrator can stop person from accessing account i.e. System Administrator also may delete the account. Eg:# userdel sweta

5. System administrator can make restriction on web surf like user can surf web but has access to particular sites.

6. System administrator can stop certain websites. Prepared by Prof. Sweta Chheda Page 9

Q) Explain Backing up and Restoring Files in Linux.(april 2013) 1. Backup required to secure data from computer failure, some people may harm

others property or system if system administrator not perfect to handle it.

2. We back up important files so that in the event of a failure of hardware, security, or administration, the system can be up and running again with minimal disruption.

3. Backup can be taken in high capacity tape drive and can be stored in disks.. 4. It‘s it more sensible to back up user accounts and system configuration files from the

distribution CDs. CDs would be quicker and easier than getting the basics off a tape archive.

5. System Administrator must decide what to back up and how frequently backup. 6. System Administrator may maintain a series of incremental backups i.e. adding only the

files that have changed since the last backup or multiple full backups. 7. System Administrator may use RAID (redundant array of independent disks ) for Backup ,

which is multiple hard drives all containing the same data as insurance against the failure of any one of them, in addition to other backup systems.

8. System administrator should carry restore at least once in non critical time.

9. Need to formulate a plan for bringing the system back up in the event of a failure.

Q) Explain Monitoring and Turning Performance in Linux. 1. System Administrator brings improvement in system performance. 2. System Administrator takes some performance decision at installation time while others

are added later. 3. A good example is the use of the hdparm utility, to squeeze the best performance from your

equipment, monitor your system carefully and use Linux built-in configuration wisely. 4. Proper monitoring allows you to detect a misbehaving application that might be consuming

more resources than it should or failing to exit completely on close. 5. careful system monitoring and diagnostic practices give you an early heads-up when a

system component is showing early signs of failure, so that any potential downtime can be minimized.

6. Careful system monitoring plus wise use of the built-in configurability of Linux allows you to squeeze the best possible performance from your existing equipment.

Performance Monitoring Memory

Disk Sub System

Network Traffic

CPU

What to Monitor? Overall Performance

Active Process

Memory Usage

Disk Usage & Performance

CPU Utilization

Network Usage

Q) Explain How to configure a secure system.

Prepared by Prof. Sweta Chheda Page 10

1. There is a common thread in Linux system administration, something that is a constant

presence in everything you do, it is the security of the computer and data integrity. 2. The system administrator‘s task, first and foremost, is to make certain that no data on the

machine or network are likely to become corrupted, whether by hardware or power failure, by misconfiguration or user error (to the extent that the latter can be avoided), or by malicious or inadvertent intrusion from elsewhere.

3. Prevention from serious attacks like DDoS, E-mail attacks and worms attacks.

4. Firewalls as protection thereby enabling and disabling firewalls through network setup. 5. Monitoring the Red Hat Linux security mailing list to make sure that all security advisories

are followed. 6. If you are running Web, ftp, or mail servers, then make sure that passwords are not easily

guessed and not made available to unauthorized persons. 7. Prevention of Intrusion.

Q) State and Explain different tools used to Monitor Security of Linux. 1. Crackers : It‘s the clever people aiming to break into other peoples computers, just to amuse

themselves or doing potential larceny. If there is a vulnerability in a system, they will find it. 2. The Linux development community is quick to find potential exploits and to find ways of

slamming shut the door before crackers can enter by making available new, patched versions of packages in which potential exploits have been found.

3. First and best security tool is making sure that whenever a security advisory is issued, you download and install the repaired package.

4. As good as the bug trackers are, sometimes their job is reactive. Preventing the use of your machine for nefarious purposes and guarding against intrusion are, in the end, your responsibility alone.

5. If your machine is connected to the Internet, you will be amazed at the number of attempts that are made to break into your machine. And you‘ll be struck by how critical an issue security is.

6. Tools to monitor :

i. #uptime

ii. #top

iii. #free

iv. #watch

v. #vmstat vi. #iostat

vii. #netstat -i

viii. #mpstat

Ch 3: BOOTING AND SHUTTING DOWN

Q) What is Boot Loader?

A boot loader, also called a boot manager, is a small program that places the operating system (OS) of a computer into memory.

When computer boots up BIOS is the first program that is run. Prepared by Prof. Sweta Chheda Page 11

After it is loaded, the basic input/output system(BIOS) begins to performs some initial

tests through the Power On Self Test(POST) and then transfers control to the master boot record (MBR) where the boot loader resides.

If a computer is to be used with Linux, a special boot loader must be installed.

For Linux, the two most common boot loaders are known as LILO (Linux Loader) and LOADLIN (LOAD LINux).

An alternative boot loader, called GRUB (Grand Unified Boot loader), is used with Red Hat

Linux. LILO is the most popular boot loader among computer users that employ Linux as the main, or only, operating system.

The primary advantage of LILO is the fact that it allows for fast boot-up. LOADLIN is

preferred by some users whose computers have multiple operating systems, and who spend relatively little time in Linux.

LOADLIN is sometimes used as a backup boot loader for Linux in case LILO fails. GRUB is

preferred by many users of Red Hat Linux, because it is the default boot loader for that distribution.

Q) Explain Booting Sequence or Boot Process of Linux OS with the help of diagram. There are total six stages of Linux Boot Process (Startup sequence) : Press the power button

on your system, and after few moments you see the Linux login prompt.Have you ever

wondered what happens behind the scenes from the time you press the power button until the

Linux login prompt appears?

The following are the 6 high level stages of a typical Linux boot process.

Prepared by Prof. Sweta Chheda Page 12

Q) BIOS BIOS stands for Basic Input/Output System

Performs some system integrity checks

Searches, loads, and executes the boot loader program.

It looks for boot loader in floppy, cd-rom, or hard drive. You can press a key (typically F12 of F2, but it depends on your system) during the BIOS startup to change the boot sequence.

Once the boot loader program is detected and loaded into the memory, BIOS gives the control to it.

So, in simple terms BIOS loads and executes the MBR boot loader.

R) MBR MBR stands for Master Boot Record.

It is located in the 1st

sector of the bootable disk. Typically /dev/I, or /dev/sda

MBR is less than 512 bytes in size. This has three components 1) primary boot loader info in 1st

446 bytes 2) partition table info in next 64 bytes 3) mbr validation check in last 2 bytes.

It contains information about GRUB (or LILO in old systems).

So, in simple terms MBR loads and executes the GRUB boot loader.

Prepared by Prof. Sweta Chheda Page 13

S) GRUB (nov 12, april 13)

GRUB stands for Grand Unified Bootloader.

If you have multiple kernel images installed on your system, you can choose which one to be executed.

GRUB displays a splash screen, waits for few seconds, if you don‘t enter anything, it loads the default kernel image as specified in the grub configuration file.

GRUB has the knowledge of the filesystem (the older Linux loader LILO didn‘t understand filesystem).

Grub configuration file is /boot/grub/grub.conf (/etc/grub.conf is a link to this).

It contains kernel and initrd image.

So, in simple terms GRUB just loads and executes Kernel and initrd images.

T) Kernel Mounts the root file system as specified in the ―root=‖ in grub.conf

Kernel executes the /sbin/init program

Since init was the 1st

program to be executed by Linux Kernel, it has the process id (PID) of 1.

Do a ‗ps –ef | grep init‘ and check the pid.

initrd stands for Initial RAM Disk.

initrd is used by kernel as temporary root file system until kernel is booted and the real root file system is mounted. It also contains necessary drivers compiled inside, which helps it to access the hard drive partitions, and other hardware.

5. Init OR /sbin/init /sbin/init is the very first process to be executed by kernel in RAM.

The first script init runs is /etc/rc.d/rc.sysinit. This script starts system swap, checks the file systems, and performs other system initialization.

Next it looks at the /etc/inittab file to decide the Linux run level.

The default runlevel is set to 5.

Init identifies the default initlevel from /etc/inittab and uses that to load all appropriate program.(Execute ‘grep initdefault /etc/inittab’ on your system to identify the default run level)

Next it reads /etc/rc.d/init.d/ functions to determine the procedure to use to set the default system path, start and stop programs, find the process ID(PID) of running process and how to log the success or failure of starting a program.

The next script to run is /etc/rc.d/rc, which is responsible for starting and stopping services when the runlevel changes and determine the new runlevel.

In the /etc/rc.d directory are additional directories rc0.d, rc1.d, rc2.d, rc3.d, rc4.d, rc5.d, and rc6.d.

Prepared by Prof. Sweta Chheda Page 14

The number in the directory name corresponds to the runlevel.

Each of these directories contain scripts that are used to stop and start services for the runlevel.

When the Linux system is booting up, you might see various services getting started. For example, it might say ―starting sendmail …. OK‖. Those are the runlevel programs, executed from the run level directory as defined by your run level.

Depending on your default init level setting, the system will execute the programs from one of the following directories.

Run level 0 – /etc/rc.d/rc0.d/

Run level 1 – /etc/rc.d/rc1.d/

Run level 2 – /etc/rc.d/rc2.d/

Run level 3 – /etc/rc.d/rc3.d/

Run level 4 – /etc/rc.d/rc4.d/

Run level 5 – /etc/rc.d/rc5.d/

Run level 6 – /etc/rc.d/rc6.d/

Please note that there are also symbolic links available for these directory under /etc directly. So, /etc/rc0.d is linked to /etc/rc.d/rc0.d.

Under the /etc/rc.d/rc*.d/ directories, you would see programs that start with S and K.

Programs starts with S are used during startup. S for startup.

Programs starts with K are used during shutdown. K for kill.

There are numbers right next to S and K in the program names. Those are the sequence number in which the programs should be started or killed.

For example, S12syslog is to start the syslog deamon, which has the sequence number of 12. S80sendmail is to start the sendmail daemon, which has the sequence number of 80. So, syslog program will be started before sendmail.

Processes are stopped by the /etc/rc.d/init.d/ process stop command, and started by /etc/rc.d/init.d/ process start.

Eg: #etc/rc.d/init.d/httpd.start

U) Runlevel programs There are typically 6 levels. By default the file /etc/inittab has runlevel 5 as default.

Following are the different runlevels

runlevel Description

0 Halt

1 Single user mode

2 Multiuser, without NFS

3 Full multiuser mode(without a GUI)

4 Not used or unused (user-definable)

5 Full multiuser mode(with GUI) or X Windows

6 Reboot To change the system runlevel, change the line in the file /etc/inittab id:5:initdefault:

Prepared by Prof. Sweta Chheda Page 15

Just change the number 5 to a number 3, so the line now looks like this: id:3:initdefault:

Runlevel 1 lets you enter single-user mode. This runlevel is useful for troubleshooting or running diagnostics on your system.

If you are having problem with your system, you would usually enter runlevel 1 by entering the command during system boot, as shown below :

i. When the boot screen appears, highlight the kernel you want to change by using the down-arrow key.

ii. Press the letter e.

iii. Scroll to the second line and press e again.

iv. At the end of the line type init 1 and press Enter.

v. Press the letter b to boot the system into single-user mode.

Q) Runlevel Utilities:

There are many system utilities that helps to manage the system in different runlevels.

These management commands include the following: I. shutdown : Brings the system to a powered -off state or can reboot the

system. II. halt : Powers down the system. III. reboot : Reboots the system. IV. poweroff : Works the same as the halt command.

V. chkconfig : Manages what runlevels services start and stop at. VI. runlevel : Displays the current and previous runlevels. VII. init : Changes runlevels.

For ex: Perform the following commands for the runlevel:

To check the current runlevel you are in, you can use the runlevel command

#runlevel

N 5

Q) Startup Scripts and /etc/sysconfig files

The files in the /etc/sysconfig folder are read by the startup scripts. So it‘s worth mentioning them here. * network – contains information of your hostname, nisdomain name etc.

* clock – timezone information

* autofsck – automatic filesystem check during boot up

* network-scripts – folder contains interface configuration files ifcfg-lo, ifcfg-eth0 etc.

* hwconf – hardware information * sendmail, spamassassin, syslog, yppasswdd – information about the corresponding daemons. Edit the files in /etc/sysconfig folder to make changes to your system. Prepared by Prof. Sweta Chheda Page 16

Q) Init and single user mode

This runlevel is used by sysadmins to perform routine maintenance.

Its most commonly used for checking errors in file system with command ‗fsck‘.

Only the root file system will be mounted in this runlevel and the system administrator is provided with a shell.

If necessary, other partitions needs to be mounted manually. Also none of the deamons

will be running in this runlevel.

Only the system administrator can use the system in this mode. You can simply exit from the shell to boot it to the multiuser mode.

Q) Explain GRUB and LILO Loader. GRUB same as above.

LILO

LILO is a linux boot loader which is too big to fit into single sector of 512-bytes.

So it is divided into two parts :an installer and a runtime module.

The installer module places the runtime module on MBR.The runtime module has the info about all operating systems installed.

When the runtime module is executed it selects the operating system to load and

transfers the control to kernel.

LILO does not understand filesystems and boot images to be loaded and treats them as raw disk offsets

Q) Explain GRUB.conf file or the GRUB configuration file: /etc/grub.conf (or /boot/grub/grub.conf) in detail.

This grub.conf file contains everything you need to make sure the boot process works smoothly.

About Grub.conf file in Redhat Linux Server #vi /boot/grub/grub.conf

Grub.conf file it has 7 lines. There default file format. default=0 timeout=5 splashimage=(hd0,0)/grub/splash.xpm. gz hiddenmenu title Red Hat Enterprise Linux Server (2.6.1 8-53.el5) Prepared by Prof. Sweta Chheda Page 17

root (hd0,0) kernel /vmlinuz-2.6.18-53.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quite initrd /initrd-2.6.18-53.el5.img

FIRST LINE: default=0 :This command tells the grub to boot the first listing beginning with the title SECOND LINE: timeout=5 : while the system boot it will wait up to 5 second user to select the kernel. To change the time, increase or decrease the number as desired

THIRD LINE: splashimage=(hd0,0)/grub/splash.xpm.gz :it will load the (hd0,0)/grub/splash.xpm .gz image as the background when we were booting the OS. You can create your own image. How to create I splash.xpm.gz Image #convert imagelocation.png –resize 640x480 –colors 14 splash.xpm #gzip splash.xpm

FOURTH LINE: Hiddenmenu : This command tells the grub not to display t he menu and to boot the default kernel after the timeout expires.

FIFTH LINE:title Red Hat Enterprise Linux Server (2.6.18 -53.el5) It will give the kernel label as the ―title Red Hat Enterprise Linux Server (2.6.18 - 53.el5)‖

1) root (hd0,0): This line tells the GRUB to boot the system from the first partition of the hard disk.

2) kernel: This line tells the GRUB the location of the kernel as well as passes the parameter to the kernel. There are already two parameters

i. rhgb : tells the system to use th e graphical boot. ii. Quite : tells the system not to display detailed information about system booting.

Q) initrd : this line tells the GRUB location of the initrd

ramdisk image that is used to load special drivers for the system.

Q) Explanation of various boot options during booting with examples Prepared by Prof. Sweta Chheda Page 18

GRUB has the following boot option:

e :

a :

c :

Edit the command before booting.

Append the kernel argument before booting.

Open the GRUB command line

1. To select the kernel to edit boot parameters press ‗ e‘. The screen the looks like

Prepared by Prof. Sweta Chheda Page 19

The entry to be edited is highlighted and ‗ e‘ is again pressed to edit at the grub prompt .

2. To pass the argument to the kernel or to modify the kernel argument before booting press ‗a‘.

Prepared by Prof. Sweta Chheda Page 20

3. The GRUB command line

Following are the commands which can be executed on the grub command line:

i. Load up the GRUB command line to find the disk and partition that contain the

grub.conf file using the find command: grub>find /grub/grub.conf (hd0,0)

ii. You could also run:

grub> root (hd0,0): Filesystem type is unknown, partition type 0x8e.

Q) Service management –Enabling and disabling services:

On any system it is important to manage the running services. Managing services enables you to ensure the stability and reliability that your system will offer.

Prepared by Prof. Sweta Chheda Page 21

A service can range from something simple, such as providing your local system with the

correct time, or something more complex such as sharing a file system over the entire

network for your users using NFS. For ex: in the /etc/rc.d/rc3.d directory (which contain s to runlevel 3) :

# ls /etc/rc.d/rc3.d/

The K stands for kill and S stands for Start. The ## are any number between 01 and 99 including duplicates.

R) chkconfig command for service management. (nov’12)

Prepared by Prof. Sweta Chheda Page 22

To ease the management of services at each runlevel, you can use the chkconfig command.

Syntex : #chkconfig [option] service_name

Options:

i. --list[name] shows the status of the services at each runlevels Eg:

#chkconfig –list sshd

ii. --level <levels> Enables or disables the services at the given levels. Eg: #chkconfig --level 4 sshd on

iii. <name> <on|off|reset> Enables or disables the service at levels 2 -5. Eg:

#chkconfig sshd on

b)Using service command for service management:

Syntex: service <--status-all | service_name CMD>

Eg: #service sshd status

#service sshd start

#service sshd stop

Q) Differentiate between GRUB vs LILO. (nov ’12)

Below are given some few important differences about LILO and GRUB

LILO GRUB

LILO has no interactive command interface GRUB has interactive command interface

LILO does not support booting from a GRUB does support booting from a network

network

If you change your LILO config file, you GRUB automatically detects any change in

have to rewrite the LILO stage one boot config file and auto loads the OS

loader to the MBR

LILO supports only linux operating system GRUB supports large number of OS

LILO works by loading itself into space that GRUB has two stages(because its too

will fit on the MBR. overcomplicated to work as well, err |

means as easily as LILO).It loads stages 1

off MBR(usually) & stage 2 out of /boot,

along with its config.

LILO must be written again every time you GRUB does not

change the configuration file

Prepared by Prof. Sweta Chheda Page 23

Q) Explain the system SHUTDOWN process with the help of shutdown command and example.

The shutdown procedure for GNOME GUI desktop is as follows: 1)Choose Actions ? Logout from the top panel menu. A screen appears asking if you want to

logout, restart or shutdown. 2) Click the shutdown radio button.

3) Click OK, and your system begins to shutdown.

If not GUI then the command to shut down is /sbin/shutdown. Any user who are logged into system will receive a notice that the system is going down and anyone trying to log in after the shutdown command has been given will not be allowed to do so.

Following things will happen after shutdown command is executed. i) Runnings processes on the system are sent the SIGTERM signal, which attempts to stop

the running process. ii) The shutdown program signals the init program to change to a different runlevel,

i.e. runlevel 0 is used to shutdown the system thereby calling the rc scripts of the directory /etc/rc0.d/*

In most of the cases only root can use to shutdown the system.

SHUTDOWN Command : The shutdown command has options to alert users on the system when it is going down and to set up a shutdown at a particular time. Syntex : shutdown [option] time

Options: -k Doesn‘t shutdowns, just warns

-h Halts the system after shutdown -r reboots instead of turning off the system -F Forces a file system check on reboot -n Kills all processes quickly (not recommended) -t SESC sends a shutdown message but delays shutdown by x seconds

For ex: to turn off the system, do the following: # shutdown –h now This time instead of a complete power off, reboot the system as follows: # shutdown –r now Delay the shutdown by 2 minutes: # shutdown –h 2

Q) What is Boot Strapping? (nov’12, april’13)

A process that starts operating systems when the user turns on a computer system.

A boot sequence is the set of operations the computer performs when it is switched on that load an operating system.

Sequence of operations are as follows:

i) Locate and start boot loader program ii) ROM BIOS

Prepared by Prof. Sweta Chheda Page 24

iii) Look for a boot sector

iv) Boot sector

v) First sector of the disk

vi) Load boot sector into memory

Ch 4 THE FILE SYSTEM

Q) FILE SYSTEM STRUCTURE.

Understanding the organization, or layout, of the Red Hat Linux file system is one of the most important aspects of system administration.

For administrators, programmers, users, and installed software, knowing how and where

the files are stored on the system is critical for proper system operation.

A standard should be in place that specifies locations for specific types of data. Fortunately, Red Hat has Chosen to follow the standards outlined in the File system Hierarchy Standard (FHS).

This section briefly explains the FHS and its relevance to proper system administration.

The FHS provides specific requirements for the placement of files in the directory structure.

Placement is based on the type of information contained in the file. Basically two categories of file information exist:

shareable or un shareable, and

variable or static.

Shareable files are files that can be accessed by other hosts, and un shareable files can be accessed only by the local system.

Variable files contain Information that can change at any time on their own, without anyone actually Changing the file.

A log file is an example of such a file.

A static file contains information that does not change unless a user changes it.

Whereas Windows has a different root mount point for every drive.

If you have a /usr partition that fills up in Linux, you can create another file system called /usr/local and move your /usr/local data from /usr to the new file system definition.

This practice frees up space on the /usr partition, and is an easy way to bring your system

back up to a fully functional state.

This trick wouldn‘t work on a Windows machine, because Windows maps its file locations to static device disk definitions.

You would have to change programs‘ file references from c:\ to d:\, and so forth.

Linux‘s file system management is another good reason to use Linux on your production servers instead of Windows.

Prepared by Prof. Sweta Chheda Page 25

Q) ACCORDING TO THE FHS, THE ‘/’ DIRECTORY MUST CONTAIN OR HAVE LINKS TO THE FOLLOWING DIRECTORIES: (NOV’12)

The ‘/’ directory

The ‗/’ directory is called the root directory and is typically at the top of the file system structure. In many systems, the / directory is the only partition on the system and all other directories are mounted under it.

Figure shows a file system with the / directory mounted as the only partition, with all

other directories mounted beneath it.

The primary purpose of the / directory is booting the system, and to correct any problems that might be preventing the system from booting.

According to the FHS, the / directory must contain, or have links to, the

following directories: _ bin — This directory contains command files for use by the system administrator or other users. The bin directory can not contain subdirectories. _ boot — On Red Hat systems, this is the directory containing the kernel, the core of the operating system. Also in this directory are files related to booting the system, such as the bootloader. _ dev — This directory contains files with information about devices, either hardware or software devices, on the system.

Prepared by Prof. Sweta Chheda Page 26

_ etc — This directory and its subdirectories contain most of the system configuration files. If you have the X Window System installed on your system, the X11 subdirectory is located here. Networking related files are in the subdirectory sysconfig. Another subdirectory of etc is the skel directory, which is used to create files in users‘ home directories when the users are created. _ home — This directory contains the directories of users on the system. Subdirectories of home will be named for the user to whom they belong. _initrd--- This directory is used as a mount point when the system is booting.It doesn‘t contain any data, but it is very important that it be there. _ lib — The shared system files and kernel modules are contained in this directory and its subdirectories. _media---This directory contains the mount point for removable media such as floppy drives, CD-ROM drives, and USB devices such as flash memory sticks, which are typically automounted by the system. _ mnt — This directory is the location of the mount point for temporary file systems, such as a floppy or CD. _ opt — This directory and its subdirectories are often used to hold applications installed on the system. _ proc — Information about system processes is included in this directory. _ root — This is the home directory of the root user. Don‘t confuse this with the / directory, which has the same name. _ sbin — Contained in this directory are system binaries used by the system administrator or the root user. _selinux--- This directory is similar to the /proc directory in that it contains information about the selinux stored in the memory of the running kernel. _srv--- This directory is intended to hold site-specific data for system provided services. _sys--- This directory is the mount point for a virtual file system of type sysfs that is used to hold information about the system and devices. _ tmp — This directory contains temporary files used by the system. _ usr — This directory is often mounted on its own partition. It contains shareable, read-only data. Subdirectories can be used for applications, typically under /usr/local. _ var — Subdirectories and files under var contain variable information, such as system logs and print queues.

Q)what is in a File system? Again file system divided into two categories: User data - stores actual data contained in files Metadata - stores file system structural information such as superblock, inodes, directories

Q)Basic Commands in Linux.

ls : ls is probably the most commonly used Unix command. It lists information about files on the system. By default ls shows you the names of unhidden files in the current directory. You can use several additional options with ls to show you all sorts of detailed aspects of a file as well. Because ls has so many options, few system administrators know them all. A common usage of ls is ls-la, which lists files in a longer format, and lists all files, including hidden files.

Prepared by Prof. Sweta Chheda Page 27

cp : cp is Unix‘s copy command. The syntax of cp is pretty basic and is just like any

other operating system‘s file copy command. To copy filename-a to filename-b, type: cp filename-a filename-b.

rm : rm is Unix‘s remove command. To remove a file, type rm filename.

mv : mv is the move command. If moving files within a file system, mv operates more like a rename than a move, because just the logical name and logical location are changed. If a file is moved across file systems, mv copies the file over first and then removes it from the old location. To move filename-a to filename-b, type mv filename-a filename-b.

chown : chown changes the user or group ownership of a file or directory. Maintaining

proper file ownership helps ensure that only the people who own the file have access to it, since world accessible permissions can be severely limited without inhibiting the use of the file to its rightful owner.To change ownership of a file to username ben, type chown ben filename.

chgrp : chgrp changes only the group ownership of a file or directory. To set the group

ownership of a file to group admin, type chgrp admin filename.

chmod : This command changes file access permissions, handy when you want to limit who can and cannot read, write or execute your files. Permissions that can be modified with this command are write access, read access, and executable access for the user owner, the group owner, and all users on the system (world access). chmod also determines if the program text should be saved on the swap device and whether or not the command should be run under the user ID of the owner or under the group ID of the group owner.chmod has two methods of changing filename permissions. One way is the numeric method, which sets the user, group and world permissions at once. In this method, 4 represents read, 2 represents write, and 1 represents execute. So if you set a file‘s permissions to 444, you are setting it to be only readable to user, group, and world owners. If you add the numbers together you can add more file permissions. So to make a file writeable (4), readable (2), and executable (1) by user, and not accessible in any way to anybody else, you set it to permissions number 700. That breaks down to (4+2+1) for user, and no permissions for group or world, hence the two 0‘s. To change a file‘s permissions to 700, type chmod 700 filename. The other way to specify chmod

permissions is the character flag method, which changes only the attributes you specify. The letters used to change owner permissions are u for user, g for group, and o for other. To indicate the permissions mode,r is for read, w is for write, and x stands for execute. The + and – signs are used to indicate if the permission is being added or removed from the file. For example, to add readable and writeable permissions to filename-a for the user who owns it, type chmod u+rw filename.

Q) Standard and Non-standard Linux File System.

Working With Linux—Supported File Systems Linux is a very flexible operating system that has a long history of interoperability with other systems

on a number of different hardware platforms. A consequence of this friendliness to other operating

systems is that Linux can read and write to several different file systems that originated with other

operating systems much different from Linux. This section details the different file systems supported

and where they originated. One reason that Linux supports so many file systems Prepared by Prof. Sweta Chheda Page 28

is because of the design of its Virtual File Systems (VFS) layer. The VFS layer is a data abstraction layer between the kernel and the programs in user space that issues file system commands.

1) Standard disk file systems Support for these file systems come standard in Red Hat Linux. They are compiled into the kernel by default. If for some reason your kernel does not currently support these file systems, a kernel recompile with the proper options turned on should enable you to access all these file systems.

a) ext2 : (april’13) ext2 has become the standard file system for Linux. It is the next generation of the ext file system. Since then there have been a few new features added. One of these was sparse super blocks, which increases file system performance. ext2 was designed to make it easier for new features to be added, so that it can constantly evolve into a better file system. Users can take advantage of new features without reformatting their old ext2 file systems. ext2 also has the added bonus of being designed to be POSIX compliant. Can handle file systems up to 4TB large, and supports long filenames up to 1,012 characters long. In case user processes fill up a file system, ext2 normally reserves about 5 percent of disk blocks for exclusive use by root so that root can easily recover from that situation.

b) ext3 : (Nov’12,April’13) The extended 3 file system is a new file system introduced in Red Hat 7.2. ext3 provides all the features of ext2. Also features journaling and backward compatibility with ext2.

The backward compatibility enables you to still run kernels that are only ext2 aware with ext3 partitions. You can upgrade an ext2 file system to an ext3 file system without losing any of your data. ext3‘s journaling feature speeds up the amount of time it takes to bring the file system back to a sane state if it‘s not been cleanly unmounted (that is, in the event of a power outage or a system crash). Under ext2, when a file system is uncleanly mounted, the whole file system must be checked. This takes a long time on large file systems. ext3 keeps a record of uncommitted file transactions and applies only those transactions when the system is brought back up. A cleanly unmounted ext3 file system can be mounted and used as an ext2 file system.

This capability can come in handy if you need to revert to an older kernel that is not aware of ext3. The kernel sees the ext3 file system as an ext2 file system.ext3‘s journaling feature involves a small performance hit to maintain the file system transaction journal. Therefore it‘s recommended that you use ext3 mostly for your larger file systems.

c) Reiserfs :

It is Journaling fs.

Fast server performance.

Special for dir containing thousand of files.

Squeezes many files into a block. d) systemV :

Prepared by Prof. Sweta Chheda Page 29

Linux currently provides read support for SystemV partitions, and write support is experimental.

e) ufs : ufs is used in Solaris and early BSD operating systems. Linux provides read support,and write support is experimental.

f) FAT :

Windows file system.

Originally created for QDOS and used of double density double sided floppy disk.

Can handle very large file system.

FAT, FAT16, VFAT, FAT32 are different versions. FAT32 can handleup to TB in size.

g) NTFS :

It comes with all versions of windows

b-tree file system

It has performance and reliability advantage

Journaling, Encryption and Decryption support. h) IBM JFS(Journaling file system)

Linux support for JFS is written bye IBM.

2) Non-Standard File System : Supports for this file system need to be explicitly compiled into linux. a) FreeVxFS :

Veritas filesystem

Features are access control list, journaling, online backup

Versions : v1 : original VxFS

v2: Supports for fileset and dynamic inode allocation

v3: latest support quotes and large files

b) GFS :

Features : Enables multiple server to have read/write access to a single filesystem

3) Memory and Virtual File System These file systems do not exist on disk in the same way that traditional file systems do. They either exist entirely in system memory, or they are virtual because they are an interface to system devices, for example. a) proc

proc is a virtual file system that acts as an interface to the kernel‘s internal

data structures.

proc can be used to get detailed information about a system‘s hardware and to change kernel parameters at run time.

Even the process listing command, ps, gets its information from the proc file system. The kernel parameters can be changed with the sysctl command.

b) cramfs : Prepared by Prof. Sweta Chheda Page 30

cramfs is designed to cram a file system onto a small ROM, so it is small, simple,and able to

compress things well. The largest file size is 16MB, and the largest file system size is 256MB.

c) tmpfs :

tmpfs is structured around the idea that whatever is put in the /tmp file system is accessed again shortly.

tmpfs exists solely in memory, so what you put in temp doesn’t persist between reboots. d) ramfs :

It is cramfs without compression e) romfs:

It is read only file system.

Kernel on the disk has this file system.

4) Linux Disk Management : Working with disks is an important part of maintaining storage space on your system.

Partitions determine how your storage space is carved out of use later by the system and

its users.

When adding more storage or creating it for the first time, you should partition your disk space into a logical format for use later.

You are allowed to make only three primary partitions for operating system use and the

fourth is dedicated to hosting the extended partition.

To know about the current partition and filesystems, /etc/fstab file. To obtain partition information about your disks, command fdisk –l is used.

For creating partition : Partition the hard disk i.e.

#fdisk –cu/dev/sda

command : n first sector last sector :

Save the changes to the disk i.e. fdisk –cu/dev/sda

command : w

Inform the kernel about the partition i.e. partx –a/dev/sda

Make filesystem

i.e. mkfs.ext3 /dev/sda5 (sda5 is newly created partition)

Mount the partition (check in Mounting topic)

5) Mounting :

Mounting makes content of partition accessible in the directory. Mounting makes use of the file /etc/fstab.

Every mounting information must have the following entries:

I. Filesystem (partition to be mounted) : eg - /dev/sda2 II. Mounting point : eg - /boot

III. Filesystem type : eg – ext3 Prepared by Prof. Sweta Chheda Page 31

IV. Default parameters

V. Dump information

VI. Fsck i.e. filesystem check information

6) Logical volume – (Logical Volume Manager(LVM)) :

Prepared by Prof. Sweta Chheda Page 32

LVM enables flexible partitions.

Normally if you created partition, you have to keep the partition at that size indefinitely.

For example, if your system logs have grown immensely, and you‘ve run out of room on your /var partition, increasing a partition size without LVM is not possible.

With LVM in place, you could add another disk, create physical volume, and then add the

physical volume to the group that contain the /var partition.

Then you‘d use the LVM file system resizing tool to increase the file system size to match the new partition size.

Volume Group is the term used to describe various disk spaces (either whole disks or parts of

disks) that have been grouped together into one volume.

The basic syntax for using the LVM command is : lvm <command> file Eg : # lvdisplay /dev/tirup/lvtirup

For creating logical partition : i) Partition the hard disk

i.e. fdisk –cu/dev/sda command : n first sector last sector :

ii) Toggle(change) the id: i.e. fdisk –cu/dev/sda command : t

id : 8e

iii) Save the changes to the disk i.e. fdisk –cu/dev/sda command : w

iv) Inform kernel about the partition i.e. partx –a/dev/sda

v) create physical volume : i.e. pvcreate /dev/sda5 (assuming sda5 is newly created partition)

Prepared by Prof. Sweta Chheda Page 33

vi) Create volume group :

i.e. vgcreate tirup /dev/sda5

where tirup is the vg name and sda5 is the pv

vii) Create logical volume :

i.e. lvcreate –L 1000M –n tirup1 tirup

where tirup1 is the name of lv and tirup is the name of vg

viii) Make filesystem :

i.e. mkfs.ext3 /dev/tirup/tirup1 (assuming tirup1 is newly created logical volume)

xi) Mount the partition in /etc/fstab

7) Listing Physical volume and Logical Volume :

To get a listing of the physical volumes on the system enter the command as shown below at the terminal prompt : # lvm pvdisplay

To get a list of the logical volumes on your system, enter the command as shown below at

the terminal prompt : # lvm lvdisplay

To get a list of the volume groups on your system, enter the command as shown below at the

terminal prompt : # lvm vgdisplay

Q) RAID (nov’12, april’13)

From the lecture notes.

Hardware raid

Software raid RAID 0

RAID 1

RAID 5

The commands discussed here are only useful when using s/w RAID. H/W RAID is invisible to the operating system i) raidstart : This command will start an existing RAID device.

ii) raidstop : This command will stop an existing RAID device. iii) raidreconf : This command is used to add disks to an existing array to convert an array

to a new type.

Q) What is partition of a hard disk? What are different partitions to be created in Linux?

What is swap partition? (nov’12)

Partition is a means to divide a single hard drive into many logical drives.

A partition is a contiguous set of blocks on a drive that are treated as an independent disk. A partition table is an index that relates sections of the hard drive to partition.

/boot partition : contains kernel images and grub configuration and commands.

/partition

/var partition

/home partition

Any other partition based on application (e.g. /usr/local for squid) Prepared by Prof. Sweta Chheda Page 34

SWAP partition : swap partition are used to support virtual memory. In other words, data is

written to a swap partition when there is not enough RAM to store the data your system is processing. The size of your swap partition should be equal to twice your computer‘s RAM.

Q) Network Configuration Files

Under Red Hat Enterprise Linux, all network communications occur between configured software interfaces and physical networking devices connected to the system.

The configuration files for network interfaces are located in the

/etc/sysconfig/network-scripts/ directory. The scripts used to activate and deactivate these network interfaces are also located here.

Although the number and type of interface files can differ from system to system, there are

three categories of files that exist in this directory: Interface configuration files Interface control scripts Network function files

The files in each of these categories work together to enable various network devices.

Q) Network Configuration Files

Before delving into the interface configuration files, let us first itemize the primary configuration files used in network configuration.

Understanding the role these files play in setting up the network stack can be helpful when

customizing a Red Hat Enterprise Linux system. The primary network configuration files are as follows: /etc/hosts

The main purpose of this file is to resolve hostnames that cannot be resolved any other way. It can also be used to resolve hostnames on small networks with no DNS server. Regardless of the type of network the computer is on, this file should contain a line specifying the IP address of the loopback device (127.0.0.1) as localhost.localdomain.

/etc/resolv.conf This file specifies the IP addresses of DNS servers and the search domain. Unless configured to do otherwise, the network initialization scripts populate this file.

/etc/sysconfig/network This file specifies routing and host information for all network interfaces. For more information about this file and the directives it accepts,

/etc/sysconfig/network-scripts/ifcfg-interface-name For each network interface, there is a corresponding interface configuration script. Each of these files provide information specific to a particular network interface.