Professional Documents
Culture Documents
Linux Basic CMD PDF
Linux Basic CMD PDF
2009
RAHUL
GUPTA
[ REDHAT
LINUX
RHEL‐5
SERVER ]
IN
THIS
FILE
I
WILL
TELL
YOU
ALL
ABOUT
LINUX
BASIC
COMMANDS
AND
SERVERS
1
INDEX
1. History
of
Linux
2. LINUX
PRINCIPLE
3. Linux
Directory
Structure
4. INSTALLATION
5. Linux
Basic
Commands
a. Directory
commands
b. File
Commands
c.
6.
2
Hi story
o f
Linu x
In
1969,
Four
programmer
Ken
Thompson,
Dennis
Ritchie,
Rudd
Canady
&
Doug
McElroy
made
a
program
in
Bell
labs
which
does
not
have
any
name
in
year
1969.
Brian
Kernighan
checked
that
program
&
found
it
is
very
good
so]ware
for
client
&
networking
purpose.
He
gave
the
name
Unix
to
this
program
on
1st
January
1970
(epoch
bme).
First
Operabng
System.
That
bme
that
program
was
wriden
in
Assembly
language.
In
1972,
a
programmer
Dennis
Ritchie
started
converbng
this
program
in
C
language.
(Also
called
founder
of
C
language).
1973‐
Unix
in
C
language.
1980‐
Berkeley
So]ware
Development
(a
part
of
research
program
of
Berkeley
University)
launches
open
BSD
(a
small
program
wriden
in
a
single
floppy).
Paul
Allen
&
Bill
Gates
are
the
employee
of
Bell
Labs.
In
1981,
they
both
started
Microso]
with
9
more
candidates
&
they
gave
a
programme
named
Xenix
(1980)
but
it
was
flopped.
In
1981‐
Launched
MS‐DOS
1.0
In
1984‐
UNIX
open
source
In
1985‐
First
Graphical
Based
OS‐
Win
2.0
In
1991,
Linus
Benedict
Torvalds,
B‐tech
Iind
year
Computer
Science,
23
years
old
student
of
University
of
Helensiki
(Finland)
made
Kernel
(25th
August
1991).
In
1994‐
RedHat
Company
(collecbon
of
Linux
Sets)
came
into
existence.
96.8
%
servers
of
Linux
bll
2009.
3
LINU X
PRINCIPLE
1. Everything
is
a
file.
2. Small,
single
purpose
programmers’.
3. Ability
to
Chain
programmers’
together
to
perform
complex
tasks.
4. Avoid
capbve
user
interfaces.
5. Configurabon
data
stored
in
text.
Linu x
Di re ctory
Stru cture
1. /home
‐
Users
home
(all
users
folders)
2. /bin
‐
Commands
(user
executable
&
Scripts)
3. /usr/bin
‐
Commands
(user
executable
&
Scripts)
4. /sbin,
/usr/sbin
‐
root
privileged
command
5.
/usr/local/bin
‐
commands
which
we
make
for
our
use.
6.
/etc
‐
System
Configurabon
files
7.
/boot
‐
Linux
Kernel
&
Bootable
files
8.
/root
‐
root
(Admin)
Data
9.
/mnt,
/media
‐
for
mounbng
any
external
devices
10.
/dev
‐
devices
(hdd,
CD‐Rom,
Pen
Drive)
11.
/var,
/svr
‐
Server
data
12.
/proc,
/sys
‐
System
Informabon
13.
/lib/usr/share
‐
Library
files
stored
4
INSTALLATION
Here
I
will
tell
you
installabon
related
requirements
and
files.
(not
whole
installabon).
Linux
uses
ext2
&
ext3
file
system.
Boot
loader
of
linux
GRUB
(Grant
Unified
Boot
Loader)
new
&
LILO
(Linux
Loader)
old.
Boot
from
CD
or
DVD
There
are
many
types
of
method
of
installing
linux
1. Simple
Graphical
method
‐
it
will
ask
for
a
Enter
2. Text
based
‐
in
this
you
have
to
write
linux
text
or
linux
askmethod
(from
this
you
can
also
install
from
NFS)
Minimum
requirement
for
Graphical
installabon
–
x86
processor,
256
MB
RAM.
Parbbon
Created
at
the
bme
of
installabon
Partition Name File System Used for Minimu m Siz e
/ ext3
linux
file
system
6000MB
or
6
GB
/boot ext3
Linux
boobng
files
&
kernel
75
or
100
MB
/home ext3
Linux
users
entry
It’s
upon
you
/swap Swap
Uses
as
virtual
ram
Double
of
RAM
Linux
can
support
maximum
63
harddisk
IDE
&
15
SATA
Harddisk.
In
Linux
7
users
can
log
in
at
the
same
bme.
Ist
User
‐
Atl
+
Ctrl
+
F1
nd th
II
to
VI user
‐
Alt
+
Ctrl
+
F2
to
F6
Graphical
user
‐
Alt
+
Ctrl
+
F7
5
LINUX
BOOT
PROCESS
6
7
8
Copy:
1. #
cp
<source>
<desbnabon>
‐
copies
files
from
source
to
desbnabon
2. #
cp
‐i
<source>
<desbnabon>
‐
copies
files
from
source
to
desbnabon
in
asking
mode
3. #
cp
‐i
*
<desbnabon>
‐
copies
current
working
directory
all
data
to
desbnabon.
4. #
cp
‐r
<directory
name>
<desbnabon>
‐
copies
directory
from
source
to
desbnabon
Editors
in
linux:
1. nano
2. vi
These
editors
are
used
in
console
mode.
3. vim
4. gvim
5. gedit
These
editors
are
used
in
graphical
mode.
6. Emacs
VI
editor/
VIM
editor:
There
are
three
modes
in
vi
editors
1. ex
mode
(default
mode,
by
pressing
escape
key,
this
mode
is
used
for
saving
and
exit
)
2. Insert
mode
(by
pressing
insert
or
I
key,
this
mode
is
used
for
edibng)
3. Replace
mode
(this
mode
is
used
for
replacing
text
wriden,
by
again
pressing
insert
or
r
key)
For
saving
document‐
come
on
esc
mode
and
write
: w q
For
setng
line
numbers
in
document
come
on
esc
mode
and
write
:
se
nu
For
coming
on
any
specific
line
press
line
no.
and
then
‘G ’
(ex‐
102
then
G)
For
going
at
the
end
of
page
press
‘G’
For
going
at
the
top
of
page
press
gg
Vim
editor
is
not
installed
default
when
you
install
linux,
you
have
to
install
vim
editor.
It
is
the
enhanced
version
of
vi
editor.
#
vim/vi
filename
Press
‘v’
to
come
to
visual
mode,
here
we
can
select
the
mader
which
we
want
to
copy
,
press
‘yy’
to
copy
(y
stands
for
yank).
Press
‘p’
to
paste
that
mader.
Press
‘dd’
to
delete
a
parbcular
line
where
cursor
is.
Nano
Editor:
Nano
is
a
command
based
editor,
earlier
used
when
advanced
editors
were
not
came
into
being.
When
you
open
a
a
file
with
this
editor,
you
will
find
all
related
help
of
this
command.
9
SOM E
BAS IC
COMMA NDS
1. #
poweroff
‐f
2. #
halt
‐n
‐p
‐
These
commands
are
used
to
turn
off
computer.
3. #
init
0
4. #
init
6
‐
These
commands
are
used
to
Restart
computer.
5. #
reboot
6. #
startx
‐
Switch
from
command
to
graphic.
7. #
init
5
‐
Restarts
system
from
command
mode
to
graphic
mode.
8. #
history
‐
To
see
history
of
recent
commands.
9. #
history
‐c
‐
To
clear
the
history
of
recent
commands
10. #
cat
>
/etc/issue
‐
To
create
logoff
scripts.
11. #
cat
>
/etc/motd
‐
To
create
logon
scripts.
12. #
cal
yyyy
or
mm
yyyy
‐
To
see
the
calendar
of
that
month
&
year.
13. #
bc
‐
Starts
basic
calculator.
14. #
whoiam
or
#
w
‐
To
know
by
which
user
we
logged
on
15. #
adduser
<username>
‐
To
create
user
16. #
passwd
<username>
‐
To
give
password
to
user.
17. #
usermod
‐L
<username>
‐
To
lock
a
user
account.
18.
#
usermod
‐L
<username>
‐
To
unlock
a
user
account.
19. #
passwd
‐d
<username>
‐
To
remove
password
for
a
user.
20. #
cd
~
‐
Switch
directly
to
users
home
directory
with.
21. #
head
<filename>
‐
To
see
the
top
ten
lines
of
a
file.
22. #
head
‐n
16
<filename>
‐
To
see
top
16
lines
of
a
file.
23. #
tail
<filename>
‐
To
see
the
bodom
ten
lines
of
a
file.
24. #
tail
‐n
16
<filename>
‐
To
see
bodom
16
lines
of
a
file.
25. #
evince
<filename.pdf>
‐
To
open
a
pdf
file
(only
on
graphical
terminal)
26. #
sort
<filename>
‐
Short
file
in
a‐z
format.
27. #
sort
‐d
<filename>
‐
Short
file
in
dicbonary
format.
28. #
sort
‐r
<filename>
‐
Short
file
in
z‐a
format.
29. #
cat
<filename>
|tr
‘a‐z’
‘A‐Z’
‐
Translate
file
in
all
capital
leders.
30. #
wc
(‐l/‐w/‐c
)
<filename>
‐
Word
count
(‐l
for
line,
‐w
for
word,
‐c
for
character)
10
11
12
xmms‐1.2.10‐9.i386.rpm
Package
Name
Version
Type
of
Extension
architecture
#
rpm
<opbons>
<package
name>
#
rpm
‐ivh
<package
name>
‐‐aid
(install
package
along
with
dependencies)
‐‐force
(forcefully)
‐‐nodebs
(to
remove
package
along
with
dependencies)
#
rpm
‐e
<package
name>
(To
uninstall
package)
‐U
(upgrade
the
package)
#
rpm
‐q
<package
name>
(Show
whether
package
is
install
or
not)
‐qa
(queries
all
installed
rpm
packages)
‐qc
(lists
only
the
configurabon
files
stored
in
the
queried
package)
‐qd
(lists
only
the
documentabon
files
stored
in
the
queried
rpm)
‐qi
(displays
whole
informabon
about
the
queried
rpm)
‐qs
(displays
the
states
of
files
in
the
queried
rpm)
‐ql
(displays
all
files
related
to
the
queried
rpm)
13
BREAKING
PA SS WORD
&
PASS WORD
SECU RITY
Bre aki ng
root
passw ord:
When
system
ask
to
select
OS,
here
press
‘e’.
Choose
the
second
opbon
‘Kernel/vmlinuz‐2.6.i8,
again
press
‘e’.
Write
‘1’
at
the
last
of
the
line,
Then
press
esc
key
and
then
‘b’.
Now
system
will
reboot
and
stops
on
single
user
mode
sh#
here
type
passwd
,
then
enter
type
new
password
now
reboot
&
give
root
and
new
password.
Passw ord
Sec urit y
(adding
passw ord
on
g rub
a] e r
i nstall ab on):
{on
graphical
terminal}
#
grub‐md5‐crypt
Password:
Confirm
password:
(Here
you
see
some
digits,
copy
those
digits)
Now
edit
file
grub.conf
#
vi
/boot/grub/grub.conf
Here
you
see
a
line
where
wriden
hidden
menu,
come
under
that
line
and
type
Password
‐‐md5
{paste
those
digits}
Save
file.
Now
your
password
cannot
be
broken
on
startup.
14
PERM ISS IONS
15
To
check
UID/GID
#
cat
/etc/passwd
(UID
for
root
=
0,
UID
for
user
starts
from
500)
Fi le s
w he re
UI D
&
GI D
i nformab on
sav e d
/etc/passwd
(UID)
/etc/shadow
(UID
in
encrypted
form)
/etc/group
(GID)
/etc/gshadow
(GID
in
encrypted
form)
16
RU N
LEV EL
(INIT)
To
edit
or
see
init
level
#
vi
/etc/inidab
0
=
shutdown
1
=
single
user
mode
2
=
mulbuser
mode
without
NFS
support
3
=
full
mulbuser
mode
4
=
not
used
5
=
Graphical
(x11)
6
=
reboot
If
our
system
boots
on
graphical
and
we
want
that
our
system
boot
on
init
3
default,
we
change
the
following
line
Id:5:initdefault
(here
we
change
5
with
3)
CRONTA B
#
crontab
‐e
‐u
username
*/1
*
*
*
*
echo
‘Hello’
>
/dev/dy2
(min,
hour,
date,
month,
day)
Save
file.
#
service
crond
restart
(now
when
user
login
on
2nd
terminal
it
will
get
message
hello
a]er
every
1
min.)
#
crontab
‐l
‐u
username
(to
see
how
many
crontab
are
running
for
user)
#
crontab
‐r
‐u
username
(deletes
the
crontab)
17
PARTIT IONS
Creabng
new/home
parbbon
#
fdisk
‐l
(for
checking
the
posibon
of
harddisk
parbbons)
#
fdisk
/dev/hda
(to
assign
whole
harddisk)
IDE0
Primary
Master
hda
Primary
Slave
hdb
IDE1
Secondary
Master
hdc
Secondry
Slave
hdd
:n
(n
for
creabng
new
parbbon,
enter)
Again
enter
Now
give
the
size
(ex‐
10000M)
:w
(w
for
save,
d
for
delete)
#
partprobe
(or
restart)
Now
to
format
this
parbbon
#
mkfs.ext3
/dev/hda7
(whatever
parbbon
you
have
made)
Now
to
mount
this
parbbon,
make
a
folder
(ex‐
/home)
#
mount
/dev/hda7
/home
(but
this
is
temporary
mounbng)
For
permanent
mounbng
#
vi
/etc/fstab
(now
do
the
following
entry
in
the
file)
/dev/hda7
/home
ext3
default
1
2
Save
the
file.
(now
if
you
have
permanently
mounted
the
parbbon
and
now
you
want
to
delete
parbbon
firstly
remove
the
entry
from
fstab,
otherwise
your
system
will
be
dump)
18
Creabng
Swap
Parbbon
Firstly
if
there
is
swap
parbbon
in
your
system,
stop
swap
#
free
‐m
(to
check
swap
is
working)
#
swapon
‐s
(to
check
swap
is
on
which
parbbon)
First
remove
the
entry
of
swap
from
fstab
#
fdisk
/dev/hda
(delete
swap
and
reboot)
Now
create
:n
:l
(for
seeing
the
swap
code)
:t
(to
give
code)
Parbbon
no:
5
Hex
code
:82
(for
swap)
:w
(save)
#
partprobe
#
mkswap
/dev/hda5
(to
make
parbbon
swap)
#
swapon
‐a
/dev/hda5
#
e2label
/dev/hda5
hda5‐swap
(to
give
label
to
parbbon)
Now
in
fstab
LABEL=hda5‐swap
swap
swap
defaults
0
0
:wq
(save)
Now
reboot
your
system
and
you
will
find
a
new
swap
parbbon.
19
RAID
Raid
are
of
two
types
1. So]ware
Raid
2. Hardware
Raid
Here
we
will
learn
to
implement
so]ware
Raid
(Raid1,
Raid5)
MD
(Metadisk)
(
when
many
harddisk
makes
a
disk)
First
create
4
(ex‐
had
7,8,9,10)
parbbon
of
equal
size.
#
mdadm
‐C
/dev/md0
‐n3
/dev/had{8,9,10}
‐l5
(by
this
command
we
have
successfully
created
raid
level
5)
To
form at
t he
m d0
#
mkfs.ext3
/dev/md0
Now
m ount
m d0
i n
a
fol de r
#
mkdir
/raid
#
mount
/dev/md0
/raid
To
chec k
t he
st at us
of
rai d
de vic e s
#
mdadm
‐D
/dev/md0
#
cat
/proc
/mdstat
To
m ak e
any
parb b on
fault y
#
mdadm
‐f
/dev/md0
/dev/hda10
To
rem ove
t he
parb b on
from
rai d
#
mdadm
‐r
/dev/md0
/dev/hda10
To
add
new
parb b on
i n
rai d
array
#
mdadm
‐a
/dev/md0
/dev/hda7
20
To
st op
the
rai d
#
mdadm
‐S
/dev/md0
Before
stopping,
we
have
to
unmount
raid
To
acb v at e
rai d
#
mdadm
‐A
/dev/md0
/dev/had
{7,8,9}
(mount
before
acbvabng)
#
mdadm
‐C
/dev/md0
‐‐chunk=64
‐‐level=1
‐‐raid‐devices=2
/dev/had{6,7}
Now
format
&
mount
same
as
above.
21
USER
QUOTA
Firstly
edit
file
/etc/fstab
for
adding
quota
for
users
#
vi
/etc/fstab
LABEL=home
/home
ext3
defaults,usrquota
0
0
Save
the
file
#
mount
‐O
remount
/home
(remount
home
parbbons)
#
quotacheck
‐cu
/home
(
to
check
whether
quota
is
applied
or
not)
#
quotaon
/home
(to
start
the
quota)
Now,
add
two
users
and
edit
file
for
user
#
edquota
user
(edit
this
file)
or
#
setquota
user
512
512
40
50
/home
It
will
set
quota
for
the
user
that
he
can
only
use
512kb
of
home
parbbon
space.
#
quotaoff
/home
(to
stop
quota)
22
PRINTE R
C OMMA NDS
These
commands
are
called
CUPS
(Common
Unix
Prinbng
System)
1. #
system‐config‐printer
‐
To
inibalize
Printer
graphically
2. #
lpstat
‐
To
check
the
status
of
printer
3. #
lprm
<job
id>
‐
To
cancel
the
prinbng
4. #
lpq
‐
To
check
the
prinbng
queue
status
5. #
a2ps
‐
Change
normal
text
to
Post
Script
6. #
ps2pdf
‐
Changes
post
script
to
pdf
7. #
lpr
<filename>
<Printer>
‐
Sends
prinbng
23
:%s/dog/cat/g
5. #
sed
‘s/dog/cat/g’
filename
(show
file
with
replaced
word)
6. $
su
(on
user,
ask
for
root
password
and
act
as
root)
7. #su
‐
username
(moves
directly
to
user
and
its
directory)
8. #
ls
–R
(Show
all
files
&
directory
in
tree
order)
9. #
vi
.bash_history
(history
of
commands
which
you
have
executed)
10. #
vi
/boot/grub.conf
bmeout:
50
(here
we
can
change
the
OS
selecbon
bme)
save
the
file.
SUDO
By
this
we
can
give
user
permission
to
run
a
parbcular
command
or
can
run
all
root
privileged
command.
#
vi
/etc/sudoers
(in
this
file
we
have
to
edit
the
file
&
write
the
user
name
under
the
following
line)
##
Al l ow
root
t o
run
any
c omm ands
anyw he re
root
ALL= (ALL )
ALL
use r
ALL= (ALL )
ALL
(here
write
the
username
to
whom
you
want
to
give
permission
to
run
root
privileged
command)
(Note‐
edit
this
file
carefully
otherwise
your
OS
could
be
corrupt)
Now
login
with
that
user
$
sudo
<root
privileged
command>
Password
(give
user
password)
24
25
YUM
(YELLOW
DOG
M ODIFIE R)
SERV ER
When
we
install
RPM
it
will
ask
for
dependencies
but
when
we
install
any
package
with
the
help
of
yum
it
will
install
all
dependencies
by
default.
For making YUM we have to ‐
1. Create
a
folder
named
re po
2. Mount
CD
ROM
(#
m ount
/ dev /c drom
/m nt)
3. Copy
Server,
Cluster,
ClusterStorage,
VT
from
DVD/CD
of
RHEL‐5
(#
c p
‐R v f
Se rve r
Cl ust er
Cl ust e rSt orage
VT
/v ar/ re po)
4. Paste
it
in
folder
named
re po
5. Delete
repodata
named
folder
from
all
the
four
folders.
6. Create
a
file
named
base.repo
#
v i
/et c/ y um. re pos. d/ base . re po
[base]
name=
base
baseurl=file:///var/repo/Server
enabled=1
gpgcheck=0
[Cluster]
name=
Cluster
baseurl=file:///var/repo/Cluster
enabled=1
gpgcheck=0
[ClusterStorage]
name=
ClusterStorage
baseurl=file:///var/repo/ClusterStorage
enabled=1
gpgcheck=0
[VT]
name=VT
baseurl=file:///var/repo/VT
enabled=1
gpgcheck=0
(save
the
file)
26
7. Edit
a
file
named
rhel‐debuginfo.repo
#
v i
/et c/ y um. re pos. d/ rhel‐ de bugi nfo. re po
(In
this
file
enabled
&
gpgcheck
must
be
0)
8. Now,
edit
this
file
#
v i
/et c/ y um. c onf
(Here
also
enabled
&
gpgcheck
must
be
0)
9. Now,
edit
last
file
#
v i
/et c/ y um /pl ugi nc onf. d/ rhnpl ug in.c onf
(Here
also
enabled
&
gpgcheck
must
be
0)
10. Now
we
have
to
group
files
to
create
repodata
11. Install
standalone
service
#
rpm
‐ iv h
/m nt / Se rve r/c re at e re po‐0 .4.4‐2. fc6. noarc h.rpm
12. #
c re at e re po
‐g
/m nt / Se rve r/ re podat a/c om ps‐rhel5‐ serv er‐c ore. xm l
/v ar/ repo/ Serve r
13. #
c re at e re po
‐g
/m nt /C lust e r/ re podata/c om ps‐rhel5‐c l ust e r. xm l
/v ar/ repo/C l ust e r
14. #
c re at e re po
‐g
/m nt /C lust e rSt orage / re podata/ c om ps‐rhel5‐c l uste r‐ st. xm l
/v ar/ repo/C l ust e rSt orag e
15. #
c re at e re po
‐g
/m nt / VT/ re podata/c omps‐ rhel5‐v t. xml
/ v ar/ re po/ VT
16. #
y um
cl e an
all
17. #
y um
l ist
all
18. Now
install
package
from
command
#
y um
i nst al l
< pac k ag e
nam e>
19. To
uninstall
package
#
y um
re m ov e
< pack ag e
nam e >
20. Now
on
graphics
you
will
find
add/remove
program
and
all
packages
are
there
to
install.
27
SQUID
SE RVE R
(Pr oxy
in
LINUX)
∗ Squid
server
controls
clients
computer’s
access
to
the
internet.
∗ It
blocks
the
users
from
accessing
undesirable
websites
and
hides
the
internal
idenbty
of
the
network.
∗ It
improves
performance
by
storing
WebPages
locally.
∗ It
is
generally
used
to
share
internet
from
one
machine
to
several
clients.
∗ Squid
server
is
widely
used
as
Proxy
server
because
it
provides
many
features
&
is
an
open
source.
Squid‐2.6.STABLE6‐4.el5.i386.rpm
Port
N um be r:
3128
(default)
Confi g urab on
Fil e:
/etc/squid/squid.conf
Servic e / Daem on:
squid
For
squid
your
system
must
have
two
lancard
one
for
internet
line
&
other
for
your
private
network.
1. #
yum
install
squid*
or
#
rpm
‐ivh
Squid‐2.6.STABLE6‐4.el5.i386.rpm
2. Edit
file
#
vi
/etc/squid/squid.conf
(in
this
file
set
line
no.
&
remove
‘#’
and
do
following
changes)
Line
no.
73
hdp_port
3128
Line
no.
993
Cache_dir
ufs
/var/spool/squid
100
16
256
28
29
DHCP
( DYNAMIC
H OST
C ONF IGURAT ION
PROT OC OL)
SERVER
∗ It
provides
IP
address
automabcally
to
the
clients
which
request
for
an
IP
address.
∗ Centralized
IP
management
∗ DHCP
prevents
IP
address
conflicts
and
helps
conserve
the
use
of
client
IP
address
on
the
network.
∗ DHCP
reduces
the
complexity
and
amount
of
administrabve
work
by
assigning
TCP/IP
configurabon
is
updated
automabcally.
Pac k ag e s:
dhcp*
67 Bootp, 68 DHCP
/etc/dhcpd.conf
dhcpd
1. Install
dhcp
package
#
y um
i nst al l
dhc p*
#
rpm
‐ iv h
dhc p*
2. Copy
dhcp
configurabon
file
#
c p
/ usr/ share/ doc / dhc p‐3.0. 1/ dhc pd.c onf.sam pl e
/ etc /dhcpd.c onf
30
3. Edit
this
file
#
v i
/et c/ dhc pd. c onf
Subnet
192.168.1.0
netmask
255.255.255.0
Opbon
domain
name
“example.com”
Opbon
domain‐name‐servers
192.168.1.1;
range
dynamic
bootp
192.168.1.10
192.168.1.20;
hardware
ethernet
__:__:__:__:__:__
fixed
address
192.168.1.16
(save
file)
In
this
file
we
have
to
give
our
network
range,
domain
name
&
its
IP
(opbonal),
range
of
IP
provided
by
DHCP
and
if
we
want
to
fix
any
address
for
specific
user
we
can
reserve
IP
for
that
with
the
help
of
MAC
address.
31
DNS
(DOMAIN
NA ME
SYSTEM)
Host
file
provides
resolubon
of
hostnames
to
IP
address.
It
can
only
resolve
the
names
provide
in
the
local
host
file.
It
cannot
be
used
as
central
database.
You
can
add
the
name
&
Ip
address
in
/etc/hosts
file.
#
vi
/etc/hosts
#
Do
not
remove
the
following
line
or
various
programs
127.0.0.0
localhost.localdomain
local
host
192.168.1.1
rahul.com
server
(save
the
file)
DNS
Provides
resolubon
of
names
to
IP
address
and
resolubon
of
IP
address
to
names,
defines
a
hierarchical
namespace
where
each
level
of
a
namespace
is
separated
by
a
”.”.
Zone‐
Zone
is
a
storage
database
which
contains
all
zones
records.
Forward
l ook up
z one:‐
Used
to
resolve
hostname
to
IP
address.
It
maintains
host
to
IP
mapping
informabon.
Ty pe s
of
R ec ords:‐
SOA
Record:‐
The
first
record
in
any
zone
file.
NS
Record
:‐
Idenbfies
the
DNS
Server
for
each
zone.
A
record:‐
Resolves
a
hostname
to
IP
address.
CNAME
Record:‐
Resolves
an
alias
name
to
a
host
name.
PTR
Record:‐
Resolves
IP
address
for
hostname.
MX
Record:‐
Used
by
mail
server.
Re qui re d
Pac k ag e s:
bind‐chroot‐9.2.4‐2.i386.rpm
bind‐devel‐9.2.4‐2.i386.rpm
bind‐libs‐9.2.4‐2.i386.rpm
bind*
bind‐ubls‐9.2.4‐2.i386.rpm
bind‐9.2.4‐2.i386.rpm
caching‐nameserver‐7.3‐3.noarch.rpm
system‐config‐bind
P ort
num be r:
53‐
DNS
Se rv ic e/ Dae m on:
named
32
1. Install
bind
#
y um
i nst al l
bi nd*
#
rpm
‐ iv h
bind*
#
y um
i nst al l
c ac hing *
#
rpm
‐ iv h
cachi ng *
#
yum
i nst all
sy st em‐c onfi g‐ bi nd*
#
rpm
‐ iv h
syste m‐c onfi g‐ bi nd*
2. Copy
the
file
#c p
/ usr/share / doc / bi nd‐9.3. 3/ sam pl e/ v ar/ nam e d/ nam e d. root
/v ar/ nam e d/ chroot /v ar/name d
3. Now
on
graphical
terminal‐
(check
that
in
network
tab
there
must
be
yours
IP
address
in
DNS
tab)
#
sy st em‐c onfi g‐bi nd
Now
a
window
comes
there
rig ht
clic k
on
DN S
se rve r‐
add‐
z one‐
i nte rne t‐
ok‐
forw ard
l ook up
z one‐
ok‐
rahul. c om
(g iv e
t he
dom ai n
nam e )(ok )
Now
rig ht
cl ick
on
dom ai n
nam e
(ra hul.c om)‐
add‐
IP v4
addre ss
(A )‐
ww w. rahul.c om
(full
dom ai n
nam e)‐
t he n
IP v 4
addre ss
(192.168 .1… .. )
4. #
se rvic e
nam e d
re st art
5. For
reverse
lookup
zone‐
255‐
R. C‐
I nt e rnet
R ev e rse
IP v4
z one‐
R .C.‐
add‐
NS
(N am e
Serv er)‐
Se rv e r
Dom ai n
N am e:
ww w. rahul. c om
(sav e)
6. #
se rvic e
nam e d
re st art
7. To
check
whether
your
DNS
server
is
working
#
host
www.rahul.com
(forward
lookup
zone)
#
host
192.168.1.1
(Reverse
lookup
zone)
#
dig
www.rahul.com/192.168.1.1
#
nslookup
www.rahul.com/192.168.1.1
8. On
client
PC
add
your
IP
in
DNS
tab
in
TCP/IP
setngs
and
ping
the
domain
name,
if
it
completes
successfully,
means
your
forward
lookup
zone
is
working
and
ping
‐a
<ip
address>,
if
it
gives
domain
name
it
means
reverse
lookup
zone
is
working.
(on
windows)
33
NFS
SE RVE R
Sharing
of
files
&
folders
between
Linux.
Pac k ag e s:
portmap‐4.0‐63.i386.rpm
nfs‐ubls‐1.0.6‐4.6.i386.rpm
Port
N um be r:
2049
–
nfsd
111
–
portmap
Confi g urab on
Fil e:
/etc/exports
Servic e:
portmap
nfs
Dae m ons:
nfsd
1. Create
a
folder
and
make
files
or
paste
files
you
want
to
share
from
in
network.
(ex.‐
/var/dump)
2. Edit
file
for
sharing
#
vi
/etc/exports
/var/dump
*(rw)
/var/rahul
192.168.1.15(ro)
(save
the
file)
(in
first
line,
we
have
share
/var/dump
for
all
users
in
a
network
with
read
&
write
permission
&
in
second
line,
we
have
shared
/var/rahul
only
for
the
PC
having
IP
address
192.168.1.15
with
read
only
permission)
3. #
service
nfs
restart
4. #
service
portmap
restart
5. #
showmount
‐e
(To
check
NFS
Server
and
its
shared
directory
from
Server
itself)
6. #
showmount
‐e
<IP
address
of
Server
>
(To
check
NFS
Server
and
its
shared
doc
from
client)
7. CLIENT
EN D:
For
taking
NFS
server
service
we
have
to
mount
directory
from
server
to
client
#
mount
‐t
nfs
<server
IP>:/var/dump
/mnt
#
cd
/mnt
(here
you
will
find
all
the
shared
material)
#
cd
/net
#
cd
/IP
of
NFS
Server
34
8. For
installabon
from
NFS,
copy
whole
DVD/CD
in
a
folder
and
share
it.
9. Boot
from
CD
on
another
client
computer,
write
linux
askmethod,
here
it
will
ask
to
select
the
installabon
media,
select
NFS,
now
it
will
ask
to
give
IP
for
your
client
computer,
give
IP,
Now
it
will
ask
for
Name
of
NFS
Server:
<Give
IP
of
NFS
Server>,
and
directory
:
<Give
the
path>.
Now
your
system
will
install
very
quickly
with
the
help
of
NFS
server.
35
#
testparm
6. Samba
users
entry
can
be
find
in
/etc/samba/smbpasswd
7. On
c li e nt
c om pute rs:
on
run:
\\<IP
address
of
samba
server>
Now
it
will
ask
for
samba
user
give
username
and
password.
NIS
SE RVE R
NIS
server
is
just
like
Acbve
Directory
Services
in
Windows.
NIS
server
need
NFS
server
,
so
it
is
necessary
to
install
NFS
server
before
NIS.
1. Set
the
hostname
#
hostname
rahul.com
2. Set
the
domainname
#
domainname
rahul.com
3. Install
the
package
#
yum
install
ypserv*
#
rpm
‐ivh
ypserv*
4. Now
create
as
many
as
user
you
want
to
create.
Share
/home
in
NFS
server.
#
vi
/etc/exports
/home
*(rw,sync)
(save
the
file)
5. #
service
nfs
restart
#
service
portmap
restart
#
service
ypserv
restart
6. #
cd
/usr/lib/yp
7. #
./ypinit
‐m
(in
this
file
it
will
ask
for
hostname,
add
hostname,
then
ctrl
+
D)
8. On
Cli e nt:
#
setup
(here
a
window
will
be
open,
here
mark
*
in
NIS
opbon,
it
will
ask
for
domain
&
IP‐
OK)
9. #
vi
/etc/auto.master
/home
/etc/auto.misc
(save
the
file)
10. #
vi
/etc/auto.misc
*
‐rw,so],intr
server
IP:
/home/&
(save
the
file)
11.
#
service
autofs
restart
36
(Now
you
client
is
ready,
login
with
the
user
that
you
have
created
on
Server
and
make
file
you
will
find
that
file
on
Server.)
37
(it
creates
a
new
file
htpasswd
and
add
user
rahul
in
it)
For
adding
more
user
#
htpasswd
/etc/hdpd/conf/htpasswd
<username>
(again
start
service)
8. Vi rt ual
H osb ng‐
First
copy
the
above
four
lines
<Virtualhost
*:80>
(change
*
with
IP
address
at
both
place)
Documentroot
/var/www
Servername
www.yahoo.com
</Virtualhost>
Come
to
the
lines
above
these
lines
#
Name
Virtual
Host
*:80
(remove
*
and
#
change
*
with
IP
address
of
the
system
)
SENDMA IL
Pac k ag e s:
Confi g urab on
Fil e:
send*
/etc/sendmail.mc
1. #
rpm
‐ iv h
‐‐ ai d
se nd*
#
y um
i nst al l
se nd*
2.
#
vi
/ etc/ se ndm ai l.m c
Line
no.
116
deamon_opbons
(Port=smtp,
addr=127.0.0.0,name=mta’)
dnl
(add
dnl
#
at
the
beginning
)
save
the
file.
3. #
m4
/etc/mail/sendmail.mc
>
/etc/mail/sendmail.cf
4. #
service
sendmail
restart
5. MA IL:
#
mail
root@localhost.localdomain
38
39
FTP
Re qui re d
Pac k ag e
Vsftpd*
1. #
rpm
‐ iv h
v s] pd*
#
y um
i nst al l
v s] pd*
2. #
v i
/ etc /v s] pd/v s] pd.c onf
We
have
to
remove
#
infront
of
the
following
lines.
Line
no.
12:
anonymous
=
default
user
(FTP
uses
two
users
anonymous
&
FTP
anonymous
has
no
password)
Line
no.
15:
local_enable=yes
(Local
user
can
login
through
FTP)
Line
no.
18:
write_enable=yes
(write
permission
is
enabled
to
FTP)
Line
no.
27:
anon_upload_enable=yes
(anonymous
user
can
upload
files)
Line
no.
31:
anon_mkdir_write_enable=yes
(anonymous
user
can
create
directory
)
Line
no.
35:
dir
message
enable=yes
Line
no.
85:
Ftpd_banner=
welcome
to
FTP
3. #
se rvic e
v s] pd
restart
4. Cli ent
e nd:
]p
<Server
IP>
>cd
pub
>get
<filename>
(download)
>put
<filename>
(upload)
40
>bye (exit)
41