Chapter 1 Introduction to Linux

snottysurfsideServers

Dec 9, 2013 (3 years and 11 months ago)

124 views

Chapter 1 Introduction to Linux


1.1 Linux
Overview

1.2

Linux
D
istribution
s

1.3


Linux Kernel

1.4


Linux Shell

1.5


System Administrator

1.6


Examples and Lab Practice

1.
7


Summary

1.
8


Self
-
Review Questions

1
.
9


Exercises



Objectives of
t
his Chapter




Introduce concepts of
Linux
o
perating
s
ystem



Discuss the responsibilit
ies

of
a
s
ystem
a
dministrator



Demonstrate the Fedora Linux
i
nstallation



Demonstrate adding users and groups


1.1


Linux

Overview


Linux is a freely distributed, multitasking, multi
-
u
ser
UNIX

like operating system. It was
d
esigned specifically for the PC.


Linux distributions are available

in 32
-
bit and 64
-
bit
versions
on a variety of pl
atforms such as Intel, Alpha, Sp
arc,
and
Power
-
PC.
We say
Linux is
UNIX

like
rather than saying that

it is
UNIX

because it
s kernel behaves like
UNIX but no UNIX code was used in the development of Linux due to

the AT&T
UNIX

trademark.
Linux h
as all the features of UNIX,
as well as some

new featu
res.

The first version on Linux was developed in 1991 by a

F
inish college student
,

Linus
Torvalds.
H
e published his project
o
n USENET
. In 1992 the software was released using

the GNU

(GNU’s Not Unix)

General Public License (GPL), a royalty free
method ot
distribute
software.
The

Free Software Foundation

(FSF) was f
ounded in 1985 and
supported the

develop
ment of many GNU utilities and tools for

programmers and
developers.
Much of the GNU software was later

ported and compiled into

Linux
.

Most
Linux distributions rely heavily on these GNU tools and utilities.

Origina
l
ly

Linux
wa
s a command
-
line operating system without

a Graphical User
Interface

(
GUI
)

. In order to compete
with
Windows and make Linux more attractive,
GNOME
(

GNU Network Object Model Environment
)

project
,
which is
part of the
GNU
project was developed t
o provide us
er friendly Windows like interface.

GNOME’s
original intention
was to create

a
distributed object

framework similar to
Microsof
t

s
OLE

but actually

t
he GNOME project provides two things:
t
he GNOME desktop
environment, an intuitive and attractiv
e desktop for users
;

and the GNOME development
platform, an extensive framework for building applications that integr
ate to be
come a
complete

Linux desktop GUI environment
.


A

different

free
graphical
desktop
environment, the K Desktop Environment (
KDE
)

wa
s

developed by
the
KDE project for
UNIX workstations
.
Both
GNOME and KDE are
widely adopted by many Linux distributions.


Learning system administration requires interacting with an operating system. It
might
seem desirable to

provide

students
with
experi
ence working

on

all the operating systems
they might use later.
However,

this is not possible, because new operating systems
continue to be developed. Even if no new operating
systems
were developed there
are
already too many operating systems to be descri
bed in a single book. This book will use
Linux to illustrate system administration concepts throughout.
Linux was selected
because it is open source and it can run on inexpensive PCs. Linux distributions are
available that can
run directly off
a CD or USB
device without using a dedicated partition
on
a
hard drive. Because of the
similarity

of Linux to UNIX, system administration is
similar in both operating systems. However, a variety of flavors of UNIX

and Linux are
available. Some of the common UNIX flavo
rs include

AIX, FreeBSD, HP
-
UX, Solaris,
and Tru64.
Linux flavors or distributions are described in the next section. System
administration principles are the same in all the distributions, but different distribution
s

supply different system administration

tools.


If you
master

Linux/
U
NIX

administration
well
,

you will not find it difficult to administer
other operating systems, such as Windows
.
I
n Windows
the commands
are very similar
to the commands in U
NIX

-

sometimes
even
having
the
same
names.

The

Linux

market is expanding, particularly as a server operating system
.
International
Data Corporation

(
IDC
)

report
s

that during the first

quarter of

2008
,

Windows accounted
for 39.2 % of
all server s
ales revenue, UNIX for 30.6%, and
Linux
for 13.6%
. Desktop
adop
tion of Linux
still lags with only about 1% of the market being Linux and Microsoft
Windows dominating

with

more than 90%

of the market
.

It is
clear that
,

currently
,

Linux
is primarily

used for server operating system.


Active
Thinking
?

What are some ad
vantages of using a graphical or GUI interface?
What are some advantage of using a command
-
line interface?


1.2 Linux Distribution
s


A Linux distribution is a complete operating system consisting of a
kerne
l
(the core of an
operating system) and utilities

(tools for
the
operating system) together with a variety of
system applications. A free distribution is supported by its open source project
. An
example of this is
Fedora project
’s support of Fedora. A

commercial distribution is
sponsored by
a

vendor
. An
example of a commercial sponsorship is Novell’s

sponsorship
of SUSE
.
A

wide variety of
open source and commercial
distr
ibutions have been created.
The large number of distributions

often confuses beginners who are unsure how to select
between the different

distributions. A system administrator not only needs to know about
different distributions
in order
to select one appropriate for
a particular situation
, but also
to take advantages of the features of the selected distribution.

Table 1.1 compares some
of
the popular Linux distributions.


Distribution

Open
Source

Platform

RPM

Root

Live

CD/

DVD

GUI

Market
Share

Server/

Desktop

Red Hat


All



i楮畸



g潯o

60%

Enterprise

/Server

Fedora



䅬A



oe搠䡡t



g潯o

include

above

Server

Debian



䅬A

D
pkg





ㄵN

p
e癥r

p啓r


䅬A

奡pq

p污l歷k牥

e癡l

g潯o



pe牶r爯re獫瑯s

䵡湤n
a步



f湴敬Ⱐ
m潷o爠


3
rd

party

R/H,
Debian



g潯o

Y㌥

pe牶r爯re獫瑯s

p污l歷k牥



f湴敬

m
潯o

啮楸⁓瑤


睥ak

Y㌥

pe牶rr

䭮潰灩h



䅬A

a


p污l歷k牥I

䑥扩慮



扥獴

睥ak

Y㌥

䑥獫瑯s

呡扬攠ㄮㄠ卵b浡my映偯灵 a爠i楮畸⁄楳 物扵瑩潮o


䕡c栠i楮畸⁤楳 物扵瑩潮楳ie搠
i
渠呡扬攠ㄮㄠ桡猠s摶a湴n
ge猠s湤⁤楳

va湴nge献

奯甠獨潵汤v
獥汥l琠t

i楮畸⁤楳 物扵瑩o渠扡獥搠潮dy潵爠oeed
s

䵡ny 晡c瑯牳⁳桯畬搠de
c潮獩摥牥搬

獵s栠
a猺s
w
桥瑨敲
瑨t

sy獴敭s
w楬氠扥

畳u搠景d⁢畳 湥獳Ⱐs潭攠畳oⰠ潲⁡ca摥浩c ed畣a瑩潮㬠
睨w瑨敲
景爠瑨r⁳y獴敭⁷楬氠桯獴

te戠b灰汩ca瑩潮
s
;

睨w瑨敲 y潵⁷a湴⁴漠桡癥

晲ee e渠
獯畲se⁳y獴敭爠
need

瑯t
桡癥

晵汬⁴散桮楣a氠獵灰o牴

a癡楬a扬b

f牯洠瑨攠癥n摯牳㬠睨d瑨敲
瑨t


o
獰sc瑩癥⁳y獴敭⁡摭d湩獴牡瑯爠楳t
a 睬y 杲g摵d瑥t

橵湩潲ofq⁰牯 e獳s潮o氠潲⁡
獥湩潲⁡摭d湩獴牡瑯
爠r
桯⁰牥晥牳

c潭oa湤
-

湥 a摭d渠獴y汥
.

佮le y潵⁨ove⁤ 瑥牭楮r搠y潵爠潰rra瑩湧⁳y獴敭 e摳Ⱐy潵o
can

楤敮瑩iy 睨楣栠i楮畸
摩獴物扵瑩潮猠桡癥⁴桥⁦ea瑵牥猠y潵ee搮

c潲oexa浰meⰠ周I⁋湯灰楸 i楮畸
摩獴物扵瑩潮⁩猠
a癡楬a扬攠楮⁡

i楶攠䍄i
景牭r琠
獯⁩t

ca渠扥⁵獥d

楮i


aca摥浩c⁥湶楲
潮oen琠睩t桯畴⁡

摥摩捡瑥t

pa牴楴r潮o
a癡楬a扬攠瑯⁩湳瑡汬ti楮畸渮

q桥⁓l
ac歷kre i楮畸慣歳

䝕f⁤ 獫
瑯瀠
獵灰潲瑳
I

扵琠桡猠
exce汬e湴⁳異灯牴⁦潲o
浯獴
啎䥘

瑲t摩d楯湳⸠⁓啓䔠r猠灯灵污p⁩渠䕵牯灥
扵琠b猠湯s⁡猠灯灵sa爠r猠潴桥爠i楮畸⁤楳 物扵瑩潮猠楮⁕湩瑥搠
p瑡瑥猠
e癥渠瑨潵g栠楴⁩

晲ee.

oe搠䡡琠i楮畸

睡猠晩牳琠se汥l獥搠楮‱㤹㐠慮搠煵dc歬y⁢ ca浥⁴桥 a摩dg 䱩湵i

摩獴物扵瑩潮⸠
f琠

猠瑨攠s楲獴si楮畸⁤楳 物扵瑩潮⁴漠o獥
o


a猠楴猠灡c歡g楮i 景f浡m

om䴠
⡯E楧楮a汬y
oed

Hat Package Manager
, abbreviated
RPM
) is a
package management
system

developed by
Red Hat
.

An RPM file

(package) is a way to distribute software s
o

that
the
software

can be easily installed, upgrad
ed, querie
d, and or
ga
nized
. It is one of the
most important features for Red Hat Linux
.

Red Hat discontinued the Red Hat Linux line in favor of
Red Hat Enterprise Linu
x

(RHEL) for enterprise environments. The
source code

of RHEL is still

free, and has been
the basis for several other
RHEL clones
,
such as Fe
dora which is
developed by the
community
-
supported
Fedora Project

and sponsored by Re
d Hat.


Fedora

is an
RPM
-
based, general purpose
Linux distribution
, developed by the
community
-
supported and sponsored by
Red H
at
.

Its first release was in 2004 when Red
Hat Linux was discontinued and replaced by RHEL. Fedora's main objective is t
o
provide

free

open source software
, and continue

t
o be on the leading edge of Linux

t
echnologies
.

M
any people still
refer to

Fedora as Red Hat Linux.

Among
the

many Linux distributions
, the authors

chose Fedora distribution to explore the
Linux system administration
.

Fedora was selected
because
of
its popularity in the Linux
market, its
free cost, its popular RPM software package management, its GNU and
GNOME GUI supports,
easy

instal
lation, configuration
, and maintenance, and its
SELinux based security features.


Active
Thinking
?

Which Linux distribution has the largest marketshare?


1.3

L
inux Kernel


The kernel is the heart of the Linux operating system just like any
other
UNIX

system
s.

The Linux kernel
has three

layers as shown in Figure 1.2
.
At the base of the kernel, t
he
low level layer consists of hardware device drivers

and

file syste
m drivers
.

The middle
layer consists of process management, memory management,

network management,
file
system management,
a
nd various other management modules
. The

upper layer provides a
system call interface to Bash s
hell and other system program calls.


The core of the kernel operations is found in the middle layer. M
emory management
makes maximum use of
the
limited
amount of
memory
installed on a machine by

assigning

memory areas and swap space to accommodate multiple concurrent system
programs
.
P
rocess

management is another important part of
the
kernel which creates
processes and implements multitasking by switching
the
CPU betwe
en
multiple
processes. The kernel also

keeps track of files on the disk via file system management.
The network mana
gement of

kernel takes cares of packet handling
and communication
.

The Kernel runs your Linux and manages all system resources to support system
programs to access system hardware. It

provides all
the
tools with which
the
services can
be built. These tools are acce
ssed via the system call interface.
It prevents

users from
accessing the hardware directly
.

At the lowest level, the kernel contains a hardware
device driver for each kind of
common
hardware such as hard disk and network devices it
supp
orts.

Laid o
n top o
f t
he Linux kernel
are various

services. Without these services
the kernel is
useless to users
.
User applications rely on services to request the kernel
to
perform tasks

on behalf of the

user.
The services are written to take advantage of the system call
i
nterface provided by the kernel. This system allows users to perform a wide variety of
activities on the computer. For instance, issue commands at the

Linux command line to
manipulate file system t
o mount new drives,

start the

httpd

daemon on Linux
for the

Apache web server,
run shell script
s

to automate

the system administration task, or run
OpenOffice

to type a letter
.


Active
Thinking
?

The Linux kernel space is divided into three layers. What are the
three layers
?




Figure

1.2 Linux Structure


1.4


Linux BASH Shell


There are two ways for a system
administrator

to perform administrative
tasks
: by Shell
command lines or by
using a
GUI interface.
This chapter

will briefly discuss the Shell
command lines interface
. Future chapters

will explain the command line interface in
greater depth and explain how to use the GNOME GUI interface.

The command line interface

is
the

most direct

way to
interact with a

Linux

system
.

A
ll
GUI tool
s for system administrations are based on these shell
command lines. It is
important that

junior system admin
istrators

understand how to use

shell command lines
because it
help
them
learn
how the Linux
system
works
. Most proficient system
admin
istrators

prefer command line or shell scripts for system
administ
ration jobs. Of
course
,

t
he GUI
interface is

more user friendly.


In

Figure 1.2

we can
see that

the Shell is on the top of the Linux kernel
. Shell commands
use the system call interface to interact with the kernel on behalf of a user
.
The
most
common Linux

shell is called "BASH
". The name comes from "Bourne Again S
h
ell
”.

Bourne refers to Stephen Bourne of Bell Labs.

In Linux
,

users can use

many different
shells
,
such
as

Korn shell, C shell, Bo
u
rn
e

shell, etc.

Users

can switch from one shell to
another shell

by typing the shell name
they want to switch to
at
the
command line

prompt
. The Bash shell is the defa
u
lt shell for Linux.



System call interface

---------------------------------------------------------------------------

Kernel

Memory, Network, Task schedule, File System, others

Management modules

File system drivers, TCP/IP network drivers


BASH shell and Linux Utility


X windows

GNOME, KDE, Toolkits

Linux Daemons

Services

Apache, MySQL

Applications

1.4.1

Some Server Shell Commands


Later chapters will provide more details on shell programming. This chapter will only
present a very
brief overview. You can use shell commands just by typing the command
at the shell prompt or by writing a shell script containing one or more shell commands.




In the
command
mode
, the user types a s
ingle command (or a short sequence
of
commands

separated b
y ; or | pipe separators ) and the result is displayed
.



Using

shell scripting

a user
can automate a complex job
.

He or she
edit
s

a script
text file just like the autoexec.bat file in DOS, then executes the

text file as a shell
batch
script.


Listed belo
w are a few examples of commands in Linux.



1)

File system and disk management




The
df

command

reports the amount of free space on each partition.



T
he
du

command

summarize
s

the size of a given directory

and all sub
-
directories.



The
quota

commands displays u
sers' disk usage and limits.



The
mount

command

get
s

a list of all the mounted fil
e

systems on the system
and
also
is used to
mount a partition or device into

a

file system. Use
umount

to
unmount a file or directory or device from system. In Linux, all dev
ices,
directories, and files are considered
to be
files.



The
yum

command is used to install software on the server


2)

Check
p
rocess
es

running
on the server




The
ps

command
check
s

the process running on

the server and

list
s

al
l the
running process
es

with th
eir

respective process ID.



The
top

command checks

the load on the server and lists
their

owners, process
IDs, plus
total process
es
, sleeping process
es
, zombie process
es,

etc.



The

uptime

command reports

the basic information about the uptime and load of
th
e server.



The
kill

command
kill
s

a
specified
running process
with its ID
on the server.


3)

Networking connection

commands




The
ifconfig

command
simply get
s

information about networ
k interface
configuration or
change
s configuration
.



The
ping

command test
s

the connection with a specified IP
address

on the
network.



The
netstat

command
find
s

the number of connections to the server

via
ports.




The
APF

or
CSF

firewall commands can

block a particular IP from connecting to
the server.




The

nmap

command
can scan and discover passive services on a network to
secure the system.



The help system in Linux can be accessed by typing
man
at the prompt. The man
command
provides you access to an online Linux manual. If you are unsure of how to use
a Linux command type
man

followed by the command you would like explained.

For
example, the following



$ man ipconfig


c
an be used to

explain the
ipconfig
command.
The vario
us options that can be used with a
command will be listed as well as an explanation of how the options are used.


The above list are just a few examples. These commands and a number of others will be
discussed in later chapters.


1.4.2
Shell Script Basics


A shell script is a plain
-
text file
with a
.sh

extension

(just a convention)
that contains
shell commands.
You can execute
the script

by typing its
file
name at

the
shell

prompt
, or
by placing its name in another shell script.


Below is a very simple scrip
t:


echo "Hello, W
orld
!
."

w
ho



T
he
who

command shows all the users who
are currently

log
ged
on
.
If you typed this
script in a file and ran it, the script
w
ould

show “Hello,
W
orld!” followed by list of users
who
are
currently log
ged in
. Most
real
-
world scr
ipt
s

are

more complex

than this
, use
many system variables,
and
include if
-
then
-
else or looping flow controls
.

Such scripts
will
be
discuss
ed

in
later

chapters
.


Active
Thinking
?

The BASH acronym stands for what?


1.5


System
Administrator


System a
dministr
ation covers all tasks that are necessary to keep a system (or server) up
and running. The system administrator is the professional person in charge of system
administration to maintain and operate the system and network. In most cases
,

the system
admin
ist
rator

belongs to the IT department and reports to the CIO or director of the IT
department. The system administrator is one of the most important persons in the IT
department. He or she has the highest special privileges (root privilege) and duties.

The s
ystem admin
istrator needs

technical knowledge of operating system
s
, network
s,
hardware,
web, database, and other popular application pa
ckages. This person shoul
d

know the business nature of the organization, know how to manage staff team and
manage project

including the equipment acquisitions.

The sys
tem
admin
istrator

must
know how to diagnose, troubleshoot and quickly fix problems
.

The duties of a system administrator are wide
-
ranging, and vary widely from one
organization to another.
The s
ys
tem administra
tor is

charged with installing
,

configuring
,
maintaining
, securing, and

providing technical
support

for
servers
. He or she must
plan
for and respond to service outages
, docume
nt policy and procedure, and handle legal
issues or

any other issue
s that arise

c
oncerning the system servers.

The system
a
dm
inistrator must have people skills to effectively communicate with users, in addition
to the
technical skills

necessary to deal with hardware and software problems. Technical
writing skills are often a challenge,

since they must document the system for users who
often lack the technical expertise possessed by the administrator.

Since the system administrator has great responsibility
,

it is important that an
administrator adhere to the highest ethical standards of

conduct at all times. System

administrators must
enforce
the
policy and rules written in the policy documents o
f the
organization
.

Although the
s
ystem
admin
istrator

is not a programmer he/she still needs a good
understanding of programming such as script
ing for administrative task automation.

In
some companies, the system admin
istrator

can also be a
database administrator

(DBA)
who
maintains a
database

system, and is responsible f
or the integrity of the data plus

the
efficienc
y and performance of the syst
em. He or she may also
be
the

web administrator

who
maintains web
server services (such as
Apache) that allow for internal or external
access to web sites.

Figure 1.3 shows the environment surrounding the system administrator. The next four
sub
-
sections d
iscuss these four aspects.




System
daily operation
,
Installation
,
configuration
,
maintenance
,
network
,
security
,
trouble
shoot
,
others
Software
Installation
,
upgrade
Web server
,
db server
,
Others
Users
Communication
,
tech support
,
training

Documentations
Plan
,
Policy
,
procedure
,
Legal
,
others
System admin


Figure 1.3
Responsibilities of the system administrator


1.5.1 System

operation
s


1) Day
-
to
-
day s
ystem operations


The daily administrative job include
s resource usage and performance (CPU, memory,
disk, server load) monitoring, troubleshooting, task automation and automatic scheduling,
configuration of the servers and applications, user account management and user process
monitoring, and security checki
ng. Most of the routine administrative jobs should be
automated by scripting and scheduling.


2) Other common administrative tasks


Some system
tasks
may not need to be performed on a daily basis, but are still important
to keeping systems running. These i
nclude:




Install, configure, support and maintain the hardware, peripherals, and network

Manage, schedule, implement, maintain and test operating system upgrades,
including new release upgrade
s

and patches in accordance with established IT
policies and pr
ocedures



Ensure

data/media recoverability by implementing a schedule of system backups



Plan, evaluate, purchase har
dware equipment



Develop and promote

standard operating procedures and enforce the polic
ies




Manage Helpdesk problem tickets and respond t
o users with assistance or
resolution.



Conducts routine hardware audits of servers and other assets



Establish Disaster Recovery strategies (Planning and implementation) that include
24 x 7 on call duties to respond to service outages and problems in cas
e of
emergencies



1.5.2 Software


A system administrator is responsible for maintaining the software installed on servers
and sometimes on client machines as well. The system administrator’s responsibilities
related to software are listed below. Note that

this list does not include writing or
developing new software packages. A system administrator may need to do some systems
programming, but he or she should not be doing application programming.




Install, upgrade, and maintain web, databa
se, ftp, mail, an
d other server

and
workstation software



Ensures workstation/server data

integrity



Evaluate, purchase, install, configure, and test software before deploying it for use
by others



Manage software contracts and licenses



Ensure the firewall and other software

are

appropriately configured

to protect the
system
and
are
running


1.5.3 User


Good communication with users is also a very important job for the system administrator.
The success of system administration can be evaluated based on the user’s satisfactio
n. A
system is useless without users. There are many different type
s of

users surrounding the
systems such as application developers, fun
ction users, CIO and

CE
O in a business
environment;
IT staff, students, faculty, and
support
staff in an academic envir
onment.

The system administrator should tell users what is being planned, what is
currently being
done
, and what has been done recently. This information can be communicated via e
-
mail
s
, phone messages, paper memos, etc. All system users need to access sys
tem
resources but the needs are quite different. The developer always requires many more
resources than end users. He or she needs a development server to conduct testing before
moving products to the production server. The developer also needs to access m
ore
system software and application software than end users.

The system administrator should provide technical support to the users. Different types of
users will need different kinds of support and assistance. The system admin
istrator

only
needs to provi
de the environment support rather than solve every specific problem a user
may encounter.

The system administrator should also provide users with training on any newly installed
and upgraded system software and application software.





1.5.4 Documentati
on


Documentation is one of the system administrator’s important duties, which should n
ot
be ignored. It includes
d
ocumentation of

the

system
co
nfiguration

of
servers
, network
s
,
web server
s
, database server
s
, software, and
also
non
-
technical documents suc
h as ethics
code, system wide
policy and procedures
. All these must be recorded in eith
er electronic
media or on paper
. The documentation should include the logs of document creation date
and persons or groups who made the document,
and the change track re
cords with

reason
for changes.

The system wide technical document should includes the layout of network and all
equipments, hardware configurations, software installed with its version and
configuration, and all upgrade information. These documents will

help the system
administrator retrieve information or keep track of all system wide changes. It will a
lso
help any successor to more easily

take over

the job

if there are any personnel changes.

The ethics code may include issues related to honesty,
privac
y, copyright, and license

contract issues.

The policy documents may cover

the user’s rights and responsibilities, in addition to the
administrator’s rights and r
esponsibilities. It should
clear
ly state

what the administrators
and users are permitted to do
and what they are
not allowed to do. For instance,

whether
the administrator is granted the right to look at other people’s private e
-
mail

or not
. Also,
the policy document should state the level of service users can request and what the
administrator can
offer, and the system resources allocated to each user, such as disk
space and e
-
mail space.

The procedure document may specify the steps of action a user should take to accomplish
a certain task. These can be procedures for an application to assign a new
a
ccount,
request a new resource, request service or

tec
hnical support, request technical training, or
requ
est

a meeting related to system issues. The system backup, problem report, and
software upgrading also have their procedures or guidelines to be follo
wed.

This book focuses on the technical aspect of system administration
,

which is listed as the
first two categories.

In the next section, you will practice installing the Fedora server, which includes the
installation of
Apache, MySQL and PHP that are inc
luded with Fedora
. We chose the
platform of Linux
, Apache, MySQL, PHP(LAMP) as the

theme of this book so that we
can practice all server site administration plus the very popular application servers such
as web server, database server, and server pages.

A
ctive
Thinking
?

Does a system administrator need to have good people skills? Why
or why not?


1.6


Examples and Lab Practice


1.6.1 Fedora Pre
-
Installation


In this lab section we guide
you through the process of installing

Fedora
9

server on 32
-
bit PC
s
.
If

you
do not already have a Fedora 9
D
VD

(One was provided with the text),
you
can download the software from
http://fedoraproject.org/get
-
fedora

and burn your
own DVD. If you prefer to purchase a DVD, a n
umber of vendors sell disks, such as
Frozen Tech (
http://www.frozentech.com/
)
, Discount Linux
(
http://www.discountlinuxdvd.com/
), and Lindistros (
http://lindistros.com/fedora
-
p
-
4.html
). Price for a Fedora DVD including shipping should be less than ten dollars.


When ordering or downloading y
ou can choose
a l
ive

CD or DVD
instead of an
installation
DVD. Live media
allows you to run directly from the distribution medium
without installing

on a

hard drive. Note that to complete some of the exercises in the text
you will need to install Linux on writeable media
-
either
on
a hard drive or a USB drive
.

To install Fedora f
rom a DVD or run it using a live DVD, you will need to include the
DVD drive in the boot sequence of your PC. To configure your machine to boot from the
DVD you may need to change BIOS or CMOS settings.
To access the BIOS setup utility,
press the F2 key wh
en the machine is starting. Some machine
s

use keys other than F2
;

use whatever key your machine indicates for BIOS setup. If you do not see a message
during startup about which key to use for BIOS setup, try one of the common BIOS setup
keys, such as F1, F
10, esc and delete.

Before installing Fedora 9, you need to determine whether Fedora 9 is the only operating
system you want on a computer

or whether you want more than one operating system
installed. To allow a machine to boot a different operating syste
m
,

you will need to create
separate hard disk partitions for each operating system.
If there is a
lready an

operating
system installed
on a computer
,

such as Windows XP, as long as there
is

more than 20GB
disk space available, you can perform the dual
-
boot
partition installation with Fedora
9
.
Fedora server
may

need more than 20GB
,

depend
ing

on the size of applications to be
installed

with it
.

1.6.2 Fedora
S
erver Installation


First, boot the machine from
a
Fedora
installation
DVD, and select the first opti
on.

The Fedora 9 is the most current version of Fedora Linux operating system.



Skip the media test
,

because it takes a long time to complete



Click the Next button on the welcome screen.



Select
English
language

as the language to use
for installa
tion
.


Select “U.S. English” or other appropriate keyboard layout.



The next step, creating partitions for the Linux file system, is very important. Partitioning
divides the hard drive into isolated sections (partitions) where each partition acts as if
it
were a separate drive. If multiple operating systems co
-
exist on the same machine
,

then
each operating system requires at least one dedicated partition. Linux frequently uses
several partitions. Note the option at the base of the screen to “Review and m
odify
parti
ti
on
ing

layout”
.


To install Linux
,

you must have enough space for the operating system files to be placed.
To create a partition to hold the Linux files, there are
five
options shown on the next
screen. For the default layout with a small boot

section, select one of the first
four
options.
If you prefer to customize your layout of the Linux file system rather than using
the default settings, select the last option.




If you want default file system layout

and either have an empty disk or desi
re to erase
everything on your existing disk
,

select the first option.
The

default
layout

generates
three
partitions.

1) Swap partition

This partition provides
a
system with virtual memory. When there is not enough RAM
,

data is written to this swap partiti
on.
Linux allows users to set the
size

of
the s
wap
partition
. Common settings are the same size as the amount of RAM on machine or twice
the amount of RAM.

For example, if
a computer has

1GB

of RAM
, the size of swap
might be

1GB or 2GB.

Other values are le
gal and will affect performance. If the partiton
is being heavily used, you might want to consider increasing the amount of RAM on the
computer.

2) /boot partition holds the Linux kernel and bootstrap process files. The separated /boot
partition is for pro
tection of these import boot programs.

3) root(/) partition holds all system programs, application programs, user data, and
packages. It is about 5GB.


The first
four
partition options are for default layout. The default file system for Fedora is
the ex3 f
ile system based on ex2. The ex3 system is easier for file system recovery from
crash over
the
ex2 system. You do not need to change this setting.

Option1) Remove
s

all partitions on the specified drives:
i
t will install the new system to
replace an existin
g Linux.

Option2) Remove Linux partition on the specified drives:
i
t will wipe out everything and
install a new system.

Option3)
Allows one to resize existing part
it
ions
.

Option4) Keep
s

all
existing partitions and uses
free space

to create new partitions:
i
t will
install the new system on free space and retain your current partitions.


Dual
-
boot system


Dual
-
boot system
s

ha
ve

two co
-
exist
ing

operating systems such as Windows and Linux.
You can choose one of them to boot at machine start up time. If you don’
t have any
operating system installed on the machine, you can create
a
partition for
W
indows first
and leave enough space (20GB) for Fedora. Of course, you can add a new additional hard
disk drive, for example, an IDE drive, just for Fedora installation. T
his drive is assigned
as
hdb

and
hda

is assigned to Windows partition. If you have two partitions on
the
first
hard drive, they are recognized as
hda1

and
hda2

You can install Fedora on an existing hard drive or partition
;

just tell the installation
progra
m to install Fedora Linux in the designated drive (additional available disk drive)
or partition (available free partition on the same drive where other OS is installed in
different partition).

Fedora even includes an option to resize existing partitions t
o create
space
to install Fedora.




On the next screen, set

the
/
swap partition
size to be
twice
as
large
as
RAM.
The swap
partition is for virtual memory.
It is used as an extension
to

RAM
,

if the computer runs

short of RAM.



Next, create a 100 MB
/
boot partition to hold the system boot program




Now create the system root (/) partition.



The three partitions created so far are default partitions and are created
in
a standard
installation.

Users can create additional partitions

during instal
lation

if desired.

The sequence of
creating partition
s

is not important.

Here
we

create a separate
/
home partition where each user stores his data and programs in
their own home directory so that
user data is placed in a separate partition from system
data
.





You may also want to create a /usr partition to
hold
application programs shared by all
users.




The size of each partition depends on your environment. For example,
if
the system has
many users
or
user
s

ha
ve

large data and programs
,

then you need

to allocate much more
space for the /home partition.


Here is the
summary list after you configured

the partitions.




The following two screen shots show the
progress of
partition
creation
. It
will
take a
while to complete the disk writing.






Next
, you decide on the boot loader. The
boot loader

is used to load the operating
system. Without a boot diskette, a boot loader should be installed. When
the
machine
starts, the BIOS reads the
master boot record
(
MBR
)
,

which is located in the first sector
(1
024 bytes) of the hard disk. The master boot record holds a part of
,

or all of
,

the boot
loader program and the partition information table. With the read data the BIOS activates
the boot loader. The MBR can only hold one boot record for one operating syst
em due its
limit
ed

size. If you need to boot multiple operating systems
,

the system must use a boot
loader. The boot loader will determine which operating system to
load
and then transfers
the control to that system kernel software
;

the kernel then initial
ize
s

the operating system.

Linux Loader
(
LILO) and GRand Unified Boot loader

(
GRUB
) are two popular boot
loaders
that

come with Linux distributions. The LILO is an older Linux boot loader.

GRUB is a newer boot loader
tht

is
in
stalled by default. GRUB can
load
a
variety of open
source operating systems
as well as

proprietary operating systems. GRUB has
an
interactive command interface and supports booting from a network. GRUB can always
perform boot loading in its default command
-
line interface
,

even if the

configuration file
is configured incorrectly.



Now, you need to
configure the network settings for the computer
.
The d
efault setting is Dynamic
Host Configuration protocol (DHCP) where the IP address will be assigned by your Interface
Service Provider
(ISP) each time you have your own ISP. If you have an assigned IP

address,
click on the Edit button to enter static IP configuration mode. Linux will detect the network
interface cards automatically and let you enter additional information by typing in val
ues.

This
allows you to enter a static IP
address and subnet mask to specify the host and network in
IP
v4 format.

You can re
-
configure the machine to use a static IP address after you complete the
installation. If you do not know the address now
,

you can s
et it later.
If you are installing Fedora
on a machine in an academic lab as part of a course, ask your instructor what values to use for
your network settings.




Internet Protocol version 4

(
IPv4
) is the fourth
version

of the
Internet Protocol

(IP)
, but

it

is the first version of the protocol to be widely
used
.
I
Pv4 uses 32
-
bit

(4
-
byte
) addresses,
which limits the
address space

to

2
32

or 4,294,967,296
possible unique addresses.

T
he
rapidly growing number of computers connected to the Internet

is expected

to soon
exceed the
4,294,967,296

addresses available; forcing the adoption of IPv6 that uses 128
bit addresses. We use IPv4 addresses in this text, since that is what is commonly in use
today.
IPv4 uses dot
-
decimal notation

(182.126.0.1) to represents a
n

IP host address. The
following step
set
s

the
host IP address and its subnet.



The n
ext setting is for the network interface card configuration
,
the server’s gateway(to
access internet outside the LAN)
, the primary DNS and Secondary DNS. T
he Domain
Name
Server

(DNS)

is used to convert host names into
IP
addresses

(ex: 1
92
.
168
.
1
.
94
)
only.

A
detailed discussion of these setting
s

and their meaning
s

is provided in the
networking chapter
.
Press
the
‘Edit’

button at the top right

and
enter the

IP address,
netwo
rk mask and
disable IPv6 support
. Then manually
set
hostname

(domain address)
,
gateway
,

and DNS servers
. Your numbers should not match those shown here
.




You have now

completed

setting up networking on

the serve
r.

The
next step

is to set the
time zone.




Then a
ssign the

root account password here.


When you install Fedora Linux you can also include many application packages such as
A
p
ache Web server.



I
nstall
the
KDE GUI desktop software and
the

GNOME GUI software
.






Y
ou can install many serv
er component packages

on the software packages screens
. To
complete exercises

in other chapters

you will need

DNS
Name S
erver, FTP
S
erver,
M
ail
S
erver,

and
My

SQL

Database
.









After selecting all the additional software packages that you would like
to install at this
time,

launch the installation process
, by clicking Next
.





Congratulations! It too
k

you about 30
-
45 minutes to complete the entire Fedora
installation.

If you need to add more software packages after system installation
,

you can
still

install them using GNOME: System
-
> Administration
-
> Add/Remove Software or
using yum command.




The installation
now allows

you
to
c
reate a use
r
. For
tasks that do not require
root
privilege
, it is safer to

use
a
regular user account instead of root a
dmin account.

The
“john”

account will be used in C
hapter 2.




Set up system date and time.




Here is the first screen you will see after the system installation.

Many system
administration tasks can be perform
ed

from

the GNOME desktop
. Look for system

administration task
s

in the

System
-
> Administration
menu.





1.6.3
Post
-
installation setup


1) Add Additional Users:


To complete the exercises in the next chapter
,

it will be helpful to have user

groups
defined and a few additional accounts. Create t
hose now by logging in using the root
account. At the GNOME desktop
,

click Systems
-
> Administration
-
> Users and groups.
This will bring up a screen similar to the one below.
The user “john” you created in the
last section should already be listed.




C
reate two additional users:

susan

and
bill
,

in addition to

john
,

that
you created during
the install. Click the “Add User” button at the top of the screen and then fill out the form
shown below.



The users you just will each belong to a group with the s
ame name as their user names.
Create a group named
linux

and assign all three regular users (
bill, john
, and
susan
) to
this group. If you grant any access rights to
a

group for accessing files or directories,
all

members are granted the same privileges
.






After you have finished your listing of groups should look like the following. If you are
missing users

groups or users (these are the group members in the screenshot),

you
sh
ould add the missing entries

before continuing.




2) Additional Configura
tions


Some housekeeping configurations need to be taken care of after the installation. For
example, you need to edit
/etc/hosts

file to replace server1.example.com with your new
host name.

The file

/etc/hosts

contains a mapping list of IP addresses and t
he host

names that they correspond to. In general,
/etc/hosts

only contains entries for your
local machine, and perhaps your name server or gateway. Your local name server will
provide address
-
to
-
name mappings for other machines on the network, transparent
ly.


Edit /etc/hosts file to reflect this computer.
Fedora includes several text editors
. I
t does
not matter which you use. Gedit is easy to use and available from the menus:
Applications
-
>Accessories
-
>Text Editor. Alternatively, you can launch a termina
l
window and use vi, if you are familiar with this editor. To invoke vi, type:
vi /etc/hosts

in
the terminal window


[root@localhost etc]# vi /etc/hosts




Regardless of the editor

you choose
to use, you need

to add the fourth line. Use the IP
number and
domain specification of your machine.

We used 192.168.1.93 and
host1.domain.com but you values will be different. Use the same values that you used in
the network configuration section.

Also adjust the local loopback address, 127.0.0.1 to
point to localhos
t as shown above. Eliminate references
server1.example.com and
server1.

The system consults th
e /etc/hosts file

to determine the
IP

address that corresponds to a
host name
, before consulting the DNS server for hostnames not included in the file.


I
n order
to guarantee all other services
are
up
and
running, you need to disable the
SELinux

by adding a line
in the
etc/selinux/config

file.


SELINUX=disable


Alternatively, y
ou can di
s
able SELinux

by
using the menus at the top of the
GNOME
desktop: System
-
>
A
dministration

-
> SELinux




SELinux package provides extended security for Linux
,

which will be discussed in the
Security chapter.


In some cases
,

you may also

need to temporarily

disable
firewall
by fir
ewall
configuration of
the
GNOME desktop and
e
n
a
bl
e it

again

later.





After you finish configuring your networking and other configuration files, re
boot

your
server so that

the changes ttake effect.

Reboot the server by including the

r reboot option
in the shutdown command:


shutdown
-
r now


The fol
lowing
commands include the /sbin directory in the

system environment variable
$
PATH definition
so that you can freely run many system commands
anywhere
without
specifying the directory path.

The details will be discussed in the Linux environment
chapter.



root@localhost etc]# echo $PATH

/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/home
/john/bin:/sbin

[root@localhost etc]# PATH=$PATH:/sbin

[root@localhost etc]# export PATH


Use
ifconfig

command to check the configuration of the networ
k interface card
and
run the
route

command to check the router configuration. The details of these
commands will be discussed in the networking chapter.

If the path command is not
specified as indicated above use would need to use
/sbin/ifconfig

and
/sbin/
route

to run the commands.




[root@localhost etc]#
/
ifconfig eth0

eth0 Link encap:Ethernet HWaddr 00:1E:90:C1:3E:9D


inet addr:192.168.1.93 Bcast:255.255.255.255 Mask:255.255.255.0


inet6 addr: fe80::21e:90ff:fec1:3e9d/64 Scope
:Link


UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1


RX packets:30131 errors:0 dropped:0 overruns:0 frame:0


TX packets:17709 errors:0 dropped:0 overruns:0 carrier:0


collisions:0 txqueuelen:1000


RX byte
s:44321988 (42.2 MiB) TX bytes:1400710 (1.3 MiB)


Interrupt:22 Base address:0xa000


[root@localhost etc]#
/
route
-
nee

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface
MSS Window irtt

192.
168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
0 0 0

192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
0 0 0

0.0.0.0 192.168.1.254 0.0.0.0 UG 0 0

0 eth0
0 0 0


3)
LAMP start
-
up


This is the time to start up Apache, My

SQL, and PHP after the system installation.

You can launch command line terminal by:


Application
-
>System Tools
-
> Terminal


At system prompt, check whether HTTP Apache

, PHP, and MySQL installation are in
place
using the rpm command
as shown
on

the

screen below. If the necessary files are not
in place, you can use yum to install all LAMP relevant packages as shown below.




One you have verified the software is install
ed, start the mysqld service for MySQL and
the httpd service for Apache.



Alternatively, you can

use GNOME
’s

Add/Remove Software manager
to search for and
install packages

as shown below
.

Menu Location is: System
-
>Administration
-
>

Add/Remove Software





The n
ext step is to start up the all relevant daemon and services and list their run
-
level
status.

The service run level 0
-
8 will be discussed in detail later in the text.


You can use graphical tool
ntsysv

by typing netsysv at

the
terminal prompt to
set
a
service to

automatic
ally

start w
hen the

system
is rebooted.



Now
,

test
that

PHP

is working correctly on your computer
. Apache HTTP server comes
with PHP module which will start when
httpd

starts.

If you use any Web browser to
browse the
http://localhost

you should see the PHP default page. It tells you that the Web
server is up running.




The Apache has its default virtual root directory at /var/www/html as shown here.




Since it is the root directory, if you wa
nt to access the
test.php

in this directory, you don’t
need to specify the full directory path. Enter
http://localhost/test.php

for the address in
your Web browser.




If you
are connected to a network or

any oth
er machine

(can
even
be a Windows
machine) connected to this server with Ethernet cable, you can use ping

your server

from
another computer
to check the
network is working and allowing connections.

You should
also be able to

use a

web

browser to
display

th
e default page
be specifying the IP address
of your server
.




You can also install an optional GUI PHP admin package
phpMyAdmin

to make
administering a MySQL database easier.
If you do not do it now, you will install it in
chapter 9 to complete some of t
he exercises in that chapter.
The installation
procedure

is
shown below:




Finally
, check the

installation of the

MySQL
server software
. We will use the DBA root
account for this test. Root is a fully privileged account created during the installation o
f
MySQL. In MySQL the root account does not have a password initially, but it is strongly
recommended that you assign it a password when you login. Assigning the password will
be covered in Chapter

9.



Log in to your MySQL server by typing “mysql

u root
” at the shell prompt. If you
succeed in connecting to the Server
,

you should get a welcome message and the
“mysql>” prompt. You can get out of mysql by typing exit at the mysql> prompt.

MySQL also provides an administration utility,
mysqladmin
,

to help i
n configuring and
maintaining a database server. For help in using this utility, type “mysqladmin
-
?”

at the
Linux shell prompt.





Summary


Linux is a freely distributed, multitasking, multi
-
user
UNIX

like operating system.
We
use Fedora in this book be
cause it is
widely used, runs on PCs, and is

free.
Because of the
similarity between Linux and UNIX, if you master system administration in Linux you
will also be able to administer

UNIX

and

other
UNIX

like platform
s. You can even apply
the system administ
ration principles learned on Linux to administering
Windows
servers
,

although some of the actual commands used to administer Windows require a different
syntax or have different names
.

The target audience of this book i
s IT students they may become
system

administrators,
information system managers, directors of IT department
s, and other high rank
individuals in
IT related areas. Therefore
,

we discussed the duty and scope of system
administrator and aspects of system administrative tasks. The system
admini
strator

not
only need
s to have

technical knowledge of system administration, but also needs to have
people skills, technical writing skills, and management skills.

In this chapter, we discussed the selection of various Linux distributions based on the
popu
larity, usage(client/server), GUI interface availability, cost, software package
support, and other attributes and features.
The

Linux architecture

was explained
,

including
the
Linux kernel, Linux shell, and shell scripts.

In the last section

of the
first
chapter,

E
xample and
L
ab
P
ractice,
step by step directions

walked you through
the installation of

Fedora server

with Apache web server, MySQL

database server, and PHP
software
. The use of

Fedora RPM

was explained. You also
used Fedora’s graphical interface

to create users and groups.
The successful Fedora
server installation
will
provide you
the ability to continue with the material in coming
chapters.





Self
-
Review Questions


1. W
hich Linux distribution is best known for its LiveCD
?


a. SUSE


b. Fed
ora


c
.

Dedian

d. Knoppix


2.

The leader free open source Linux distribution is
.


a. SUSE

b. Slackware

c
.

Dedian

d. Fedora


3.

GNOME, as a component of GNU project, is to provide free user friendly desktop
interface


a. False

b. True


4.

Linu
x is Unix


a.
T
rue

b.
F
alse


5.

Linux user can’t access hardware directly from command line, must use shell .


a. Falsr

b. Frue


6.

The default Linux shell is .


a. Korn shell

b. C shell

c
.

Born shell

d. Bash shell


7.

A system admin only nee
d to have technical administrative skills
.


a.
T
rue

b.
F
alse


8.

Web and database administration may also be part of system admin’s duty depending
on the company and
organization.


a.
T
rue

b.
F
alse


9.

Most Linux server operations require root privilege
to execute.



a.


False

b.

True


10.

The default Linux shell is


a. Korn shell

b. C shell

c. Bo
u
rn
e

shell

d. Bash shell


11.

The number of partitions in the Linux standard installation is


a. 1

b. 2

c. 3

d. 4


12.


/usr partition is used to hold all
user home directories


a.

True

b.

False


13.

The “/” partition is the home directory of the root user.


a.

True

b.

False


14.

The /sbin must have its own partition because many important comands are available
there



a. True


b. False


15.

User and group management task
s can be done either by Linux command lines or by
GNOME desktop of



a. True


b. False


16.

Which one is name of a partition



a. /dev/sda3


b. /home


17.


PHP is a Web server



a. True


b. False



18.

PHP must have support of Apache i
n LAMP



a. True


b. False


19.


One user can be assigned to multiple user groups



a. True


b. False


20.


A server should have its static IP instead of using
Dynamic Host Configuration
protocol (DHCP)



a. True


b. False




Keys to

the self
-
Review Questions


1. D

2. D

3. B

4. B

5. B

6. D

7. B

8. A

9.

B

10.

D


11. C

12. B


13. B

14. B

15. A

16. A

17. B

18. A

19. A

20.
A




1.7


Exercises


1
.

Download a Linux LiveCD or LiveDVD and boot this Linux from the media wh
e
re
Linux is loade
d.

2. Install a dual boot Fedora Linux co
-
existing with Windows on separate partitions on
the same machine.

3. Install a server vers
ion Fedora follo
wing the tutorial in the lab section of this chapter

4. Use
man

manual utility to find the detailed descript
ions of the shell commands listed in
the shell section of this chapter.

5. Run each shell command listed in the shell section of this chapter.

6.
Switch

from one shell to another shell and come back to default shell

7. Display the current shell using
echo

$<shell variable> command

8. Login yourself as
root
, create a user, then logout the root user, login as the user you
just created.

9. Practice
vi

editor and
emacs

editor by yourself, please reference
vi
and
emacs
by man
tool.

10. Run your first shell script.