You are on page 1of 41


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


Linu x
Basi c
Co mm and s




Directory
commands:


1. #
mkdir

 ‐
 For
creabng
directory.

2. #
cd

 
 ‐
 change
directory.

3. #
cd
..
 
 ‐
 to
come
out
from
working
directory.

4. #
rmdir

 ‐

 to
remove
directory


File
Commands:


1. #
touch
<filename>
 ‐
 creates
a
blank
file.

2. #
cat
>
filename

 ‐
 creates
a
file
and
for
saving
this
file
(ctrl
+
D)

3. #
cat

 
 
 ‐
 to
see
the
content
of
the
file.

4. #
cat
file1
>>
file2
 ‐
 to
move
file1
mader
in
file2

5. #
cat
‐n
filename
 ‐
 to
see
how
many
lines
are
wriden
in
that
file.


Commands
for
deleb ng:


1. #
rm

filename
 
 ‐
 deletes

a
file.

2. #
rm
‐i

 
 
 ‐


 deletes
file/folder
in
interacbve
mode
(asking
mode)

3. #
rm
‐r
 
 
 ‐
 deletes
directory.

4. #
rm
‐f
 
 
 ‐
 deletes
files/folders
forcefully.


Help
Commands:


1. #
whabs

<command>
 
 
 These
all
are
the
help
commands.
Prints
all
related
tags


2. #
man
<command>
 
 
 about
that
command.

3. #
info
<command>

4. #
<command>
‐‐help

5. #
which
<command>

6. #
cd
/usr/share/doc


Rename
&
Move:


1. #
mv
<oldfile>
<newfile>








 
 
 
 (Rename)

2. #
mv
<filename>

<where
we
have
to
move
the
file>
 (Move)


Lisb ng
Commands:


1. #
ls
 
 
 ‐
 lisbng
files/folders

2. #
ls
‐l
(ll)
 
 ‐
 long
lisbng
of
files/folders
with
whole
informabon

3. #
ls
‐a
 
 
 ‐
 lists
all
files/folders
(hidden
also)

4. #
ls
???

 
 ‐
 all
files/folders
named
with
3
characters

5. #
ls
m*
 
 
 ‐
 files
&
directories
started
with
leder
m.



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


31. #
diff

file1
file2

 
 ‐
 To
see
difference
between
same
looking
files.



32. #
blkid
 
 
 
 ‐
 To
see
device
id
(ex‐
hda1,
sdb).

33. #
mkfs.vfat
‐I
/dev/device
id
 ‐
 To
format
device
in
fat
format.

34. #
aspell

‐c

<filename>
 
 ‐
 To
check
spelling
in
a
file.

35. #
neat
 
 
 
 ‐
 To
open
network
configurabon
on
graphic
terminal

36. #
ifconfig
 
 
 ‐
 To
check
the
IP
&
MAC
address
of
NIC.

37. #
ifconfig
eth0
<ip
address>
 ‐
 To
assign
temporary
IP

38. #
ifup
eth0
 
 
 ‐
 To
enable
network
card.

39. #
ifdown
eth0
 
 
 ‐
 To
disable
network
card.

40. #
vi
/etc/sysconfig/network‐scripts/ifcfg‐eth0
 
 
 To
assign
permanent
IP
,
here
we


41. #
vi
/etc/sysconfig/networking/devices/ifcfg‐eth0
 
 have
to
edit
a
file.

42. #
ethtool
eth0
 
 
 ‐
 To
check
graphically
whether
cable
is
connected
or
not.

43. #
#
df
‐h
<parbbon>
 
 ‐
 To
check
the
free
space
of
a
parbbon.

44. #
ping

(‐c2,
‐a)
<ip
address>
 ‐
 To
check
connecbvity
(‐c2
for
seeing
two
lines,
‐a

lisbng)

45. #
look

<word>
 
 
 ‐
 For
looking
the
exact
word
spelling.

46. #
date
mmddhhmmyy
 
 ‐
 To
set
date.

47. #
ps
 
 
 
 ‐
 To
check
the
processing
status.

48. #
kill
‐9
PID
 
 
 ‐
 To
kill
the
service
no.
9.

49. #
top
 
 
 
 ‐
 Full
details
of
all
processing
&
their
ID.
(k‐
kill,
h‐
help)

50. #
wget
<website>
 
 ‐
 To
download
the
website
home
page.

51. #
elinks
<website>
 
 ‐
 To
open
website
in
command
line.

52. #
xterm

 
 
 ‐
 Starts
a
new
sub‐terminal.

53. #
mud
 
 
 
 ‐
 To
send
mail
in
a
NIS
or
single
PC
between
user
&
root

54. #
du
‐h
<parbbon>
 
 ‐
 To
check
how
much
parbbon
is
used.

55. #
ln
/home/rahul

/rahul
 ‐

 It
will
link
the
file
in
home
name
rahul
with
rahul
(in
root)

56. #
seq

1

1000
>/home/rag
 ‐
 It
will
create
a
file
named
rag
having
no.
1
to
1000.

57. #
uname
 
 
 ‐
 To
see
kernel
name.

58. #
uname
–r
 
 
 ‐
 Kernel
release.

59. #
uname
–a
 
 
 ‐
 Whole
informabon
about
kernel.

60. 
#
find
/

‐name

<filename>
 ‐
 Searches
file
in
/.

61. #
find

‐perm

775
 
 ‐
 Searches
for
files
having
permission
775.

62. #
find

‐size

±
512k
 
 ‐
 Searches
for
files
of
512k




11


63. #
find
‐name
*.htm
 
 ‐
 Searches
files
having
extension
.htm.



64. #
zcat
<filename.gz>
 
 ‐
 To
see
the
content
of
compress
file.

65. #
chkconfig

on/off
<service>
 ‐
 To
on/off
any
service
permanently.

66. #
lsmod

 
 
 ‐
 List
of
drivers
running.

67. #
modinfo

 
 
 ‐
 Details
about
running
driver


68. #
sysctl
–n
kernel
 
 ‐
 To
update
kernel.

69. #
tmpwatch
 
 
 ‐
 Shows
temporary
files.

70. #
ge|acl
<filename>
 
 ‐
 It
will
display
full
informabon
about
that
file
or
directory.

71. #
se|acl

‐m
u:<user>:rwx
/ww
 ‐
 It
will
set
the
full
user
permission
on
ww
directory.

72. #
mount
/dev/cdrom
/mnt
 ‐
 To
mount
CD
ROM.

73. #
mount
/dev/device
name/mnt‐
 To
mount
any
external
device.

74. #
mount
‐t
vfat
/dev/parbbon
/mnt
 To
mount
fat
parbbon.

75. #
userdel
<username>
 
 ‐
 To
delete
user.

76. #
groupadd
<name>
 
 ‐
 To
add
a
group.

77. #
groupdel
<name>
 
 ‐
 To
delete
group.

78. #
cat
.bash_history
 
 ‐

 To
see
history
of
commands
(a]er
execubng
history
–c)

79. 
#
cat
>
.bash_history
 
 ‐

 To
remove
history
of
commands

80. #
chage
‐E
YYYY‐MM‐DD
<user>
‐
 Set
user
expirabon.

81. #
chage
‐l

<username>
 
 ‐
 To
see
user
detailed
informabon.

82. #
chage
‐W
1
<username>
 ‐
 To
set
warning
period
for
user.

83. #
file
<file/directory
name>
 ‐
 To
check
whether
it
is
file
or
folder.

84. #
cut
–f1
–d
:
/etc/passwd
 ‐
 It
will
show
the
first
column
of
passwd
file.

85. #
usermod
‐G
<group>
<user>
 ‐
 It
will
add
user
to
group.

86. #
id
username
 
 
 ‐
 To
see
the
id
of
user.

87. #
adduser
‐g
<group>
<user>
 ‐
 To
add
network
user
in
group.

88. #
command|tee
stages.out
 ‐
 It
will
give
the
output
of
command
in
file
name
stages.out.

89. #
less
<filename>
 
 ‐
 To
see
a
file
pagewise.

90. #
grep
<word>
<filename>
 ‐
 To
find
a
parbcular
word
or
string
in
a
file.

91. #
grep
–n
<word>
<filename>
 ‐
 To
see
the
line
number
in
which
that
word
is.

92. #
tar
‐cvf
<name>
<filesname>
 ‐
 It
will
take
the
backup
of
files
as
a
single
file.

93. #
tar
‐tvf
<name>
 
 ‐
 Show
how
many
files
&
their
name
in
the
backup
file.

94. #
tar
‐xvf
<name>

 
 ‐
 Restore
the
backup.



12


95. #
gzip
<filename>
 
 ‐
 It
will
compress
a
file.



96. #
bzip2
<filename>
 
 ‐
 It
will
compress
a
file.

97. #
gunzip
<filename>.gz
 
 ‐
 It
will
decompress
a
file.

98. #
bunzip2
<filename>.b2z
 ‐
 It
will
decompress
a
file.

99. #
ssh
<ip
of
remote
PC>

 ‐
 It
will
take
control
of
remote
pc
(ask
for
password)

100.
#
scp
/root/proxy.exe

10.0.0.1:/root
 ‐
 To
send
any
file
in
network.

101.
#scp
‐rv
<source>
<desbnabon>
 ‐
 To
send
any
directory
in
network.

102.
#
tunetofs

‐j

/dev/parbbon

 
 ‐
 for
converbng
ext2
to
ext3



 
 
 
 RPM
(RedH at
Packa ge
Mana ger )



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


_
_
_
_
_
_
_
_
_
_
 owner
 group


fi lename



f/d



User







group






others
 


r=4
(22)
 w=2
(21)
 x=1
(20)



read
 
 write
 
 execute

For
 di rect ory
 m ax im um 
 pe rm i ssi on
=
777

For
 fi l e s
m axi mum
 permi ssi on
=
666

To
 gi ve
 user
full
 pe rmi ssi on

#
chmod
777
filename


Defaul t
 pe rmi ssi on
 for
fi l e
=
644

Defaul t
 pe rmi ssi on
 for
 di re ct ory
=
755

To
 see 
t he
 i nte rnal
 pe rm issi on

#
umask
(max
per.
‐
umask
=
default
permission)

#
umask
000

(full
permission
for
all)

#
umask
777

(deny
for
all)


To
 change
 the
 ow ne r
 of
 fi le s
 or
 direct ory‐

#
chown
<username>
file/directory
name

To
 change
 g roup
 of
fi l es
 &
 di rect ory‐

#
chgrp
<groupname>
file/directory
name


Every
user
has
its
own
UID
(User
Idenbficabon)

Every
group
has
its
own
GID
(Group
Idenbficabon)

If
UID
matches
(i.e.
login
user
&
owner)
user
permission
is
applicable.

If
GID
matches
(i.e.
login
user
&
group)
group
permission
is
applicable.

If
nothing
matches
other
permission
is
applicable.



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)


BASH 
SHE LL
P ROGRA MM ING




By
this
we
can
make
a
script
of
any
server
and
run
at
bme
we
want
it.

#
mkdir

~/bin

#
cd
/root/bin

#
vi

test.sh
(type
the
following
in
the
file)

#!/bin/bash

mkdir

/repo

cd

/repo
(write
command
in
a
sequence
of
its
use)

:wq


#
chmod
u+x
test.sh
(to
give
executable
permission
to
file)

#
test.sh
(to
run
that
file)


To
display
the
content
on
the
screen‐

#
echo

“what
is
your
ip
address

$
(ifconfig)”

#
alias

‘R’=ifconfig

#
echo

“what
is
your
ip
address

$
(R)”



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)


Looping 
command
f or
maki ng
user s




#
for
USER
in
name1
name2
name3
name
4
name5

>do

>useradd
$USER

>echo
redhat|passwd
–stdin
$USER

>done

Now
it
will
create
five
users
named
name1,
name2,
name3,
name4,
name5
with
password
redhat.


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.


Now,
 for
 R aid
level
5 
 (m inim um
t hre e
 harddi sk)


#
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)


Now
for
RAID
lev el
1
(Mirroring)
 (minimum
two
harddisk
required)


#
mdadm

‐C

/dev/md0

‐‐chunk=64

‐‐level=1

‐‐raid‐devices=2

/dev/had{6,7}


Now
format
&
mount
same
as
above.


LV M
{LOGICA L
VOLUME 
MA NA GER}




In
LVM,
parbbons
space
are
merged
logically
not
physically.

Make
parbbons
of
same
size
(100mb‐
2
parbbons)


Fi rst
c re ate 
P hysic al
 Vol ume
 (PV)


#
pvcreate

/dev/hda5

/dev/hda6

or

#
pvcreate

/dev/hda{5,6}

#
pvdisplay

 
 (to
see
whether
pv
is
created
successfully)


Now
c re ate 
Vol um e
 Group

#
vgcreate

vg0

/dev/had{5,6}
 
 (200
mb)

#
vgdisplay
 
 (to
see
whether
vg
is
created
successfully)


Now
 we 
wi ll
 cre at e
l ogic al
 v ol ume

#
lvcreate

‐L
+50M

/dev/vg0

‐n

lv0
 (it
will
create
a
logical
volume
of
50
Mb{52
Mb})



21


To
 e xte nd
 t he
 l ogi cal
v ol um e



#
lvextend

‐L

+25M

/dev/vg0/lv0
 (it
will
extend
the
logical
volume
to
approx.
80
Mb)


To
 re duce 
t he
 l og ic al
 v ol um e

#
lvreduce

‐L

‐25M

/dev/vg0/lv0
 (it
will
reduce
the
logical
volume
to
25
Mb)



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


SOM E
IMP ORTANT 
F ILES 
& 
C OMMA NDS




1. #
vi

.bashrc
 
 (This
is
hidden
file
&
used
to
create
shortcuts
for
commands)

alias
c=’clear’

alias
m=’mkdir’

save
the
file

by
typing

the
above
words
it
will
create
shortcut
for
clear
and
mkdir
(c
&
m)

but
a]er
edibng
file
first
logout
&
again
login.


2. #
vi
/var/log/messages
 (shows
audit
messages)

3. #
vi

.exrc
 
 (we
have
to
create
this
file)

:se
nu
 
 
 (write
this
in
the
file)

Save
the
file

A]er
saving
file
you
will
find
line
numbers
already
wriden
in
every
file
you
open
for
edibng.


4. For
replacing
many
words
in
a
file
(for
ex‐
if
we
have
made
a
file,
in
that
file
many
bmes
dog
word

is
wriden
and
we
want
to
replace
word
dog
with
cat)

Open
file
with
vi
editor
and
on
esc.
Mode
type



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.


Pac k ag e s
 re qui re d:



 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


Line
 no. 
1079



access_log

/var/log/squid/access.log




squid

Line
 no. 
1087

Cache_log

/var/log/Squid/cache.log

Line
 no. 
1097

Cache_store_log

/var/log/squid/squid.log

Line
 no. 
2522

acl

our_networks

scr

192.168.1.0

192.168.2.0/24
 (here
change
with
your
network
range)


Line
 no. 
2523

hdp_access

allow

our_networks

Line
 no. 
2778

cache_mgr

rahulguptamd1988@gmail.com
(change
with
your
email‐address
or
name)


by
doing
these
configurabon
your
internet


Now
 for
A cce ss
l ist

Line
 no. 
2409


(there
you
will
find
typed
acl
C ONN ECT
 met hod
 C ONNEC T,
type
under
that
line)

acl

<any
name>

url_regex

<Websites
you
want
to
block
or
inibals,
downloadings>


(acl

xyz

url_regex

orkut
mp3
downloading

www.gmail.com
)

hdp_access

deny

<above
name>
(xyz)
 
 
 or


acl

xyz

url_regex

www.google.com
 (Only
this
website
you
want
your
client
to
access)

hdp_access

allow
xyz

hdp_access
deny
all
 
 
 (save
the
file)

3. #
service
squid
restart/reload

4. #
netstat

‐tulpn

|grep

3128
 
 (to
check
whether
squid
is
working
or
not)

5. #
vi
/var/log/squid/access.log
 
 (to
see
the
record
of
website
opened
by
client)

6. Now
on
client
PC
 

Re dhat‐
FireFox‐
edit
menu‐
preferences‐
connecbon
setng‐
Manual
Proxy
setng‐

Proxy

Server
IP‐
__________

Port
no.

3128‐
check
(use
this
proxy
for
all
protocols)

On
 Wi ndows:‐
 Internet
explorer‐
Tools‐
Internet
Opbons‐
connecbons‐

Lan
Setng‐
check

(use
a
proxy
for
this
lan)‐
Give
IP
&
Port
no.‐
OK.



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*


Port 
 num be rs:


67

Bootp,
68
DHCP


Confi g urab on
 fi l e:


/etc/dhcpd.conf


Servic e / Daem on:


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.



4. #
 se rvic e
 dhc pd
 re st art



5. Now
 on
 client
 set
 the
 TCP/IP
 setng
 on
 obtain
 an
 IP
 address
 automabcally
 &
 obtain
 DNS

server
address
automabcally.



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.


SAM BA
SE RVE R



∗ Samba
is
a
way
a

Linux
Computer
communicate
with
SMB
(Server
Message
Box)
and
CIFS.

∗ With
 Samba,
 you
 can
 make
 your
 Linux
 computer
 a
 part
 of
 Microso]
 based
 network.

Computers
with
various
Microso]
Operabng
systems
can
communicate
with
each
other
using

the
server.

∗ Message
Block
(SMB)
protocol.
When
a
Microso]
based
OS
shares
files
or
printers
on
a
TCP/IP

network,
it
uses
the
CIFS
(Common
Internet
File
System).

Confi g urab on
 Fil e s: 

 
 
 Servic e:

/etc/samba/smb.conf
 
 
 
 smb


1. #
yum

install

samba*
 
 (Install
samba
package)

#
rpm

‐ivh

samba*

2. Now,
edit
file

#
vi

/etc/samba/smb.conf
 
 

(at
last
of
file,
pressing
‘G’
copy
the
following
line
and
paste
the
lines
and
then
remove
‘;’
infont
of

the
line.)

[My
Share]
 
 
 
 (Share
name)


 comment=
 
 
 (any
comment)


 path=
 
 
 
 (here
give
the
path
which
you
want
to
share)


 valid
users=
 
 
 (Here
give
samba
users)


 public=
no


 writable=no
 
 
 (Here
give
the
permission
you
want
to
give)


 printable=no

save
the
file.


3. #
service

smb

restart

4. To
create
Samba
users

#
useradd

<username>

#
smbpasswd

‐a

<username>

5. To
check
samba
is
configured
of
not



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.)
 


APACHE
( WE B)
S ERVE R



Apache
Server
is
used
for
hosbng
website
for
Internet/Intranet.
By
this
server
we
can
also

authenbcate
only
limited
users
to
access
website.
For
this
server
you
must
have
DNS
server

configured
or
add
your
IP
and
server
name
in
hosts
file.

Pac k ag e s:

hdpd*

1. Install
package
for
hdp.

#
yum
install
hdp*

#
rpm

‐ivh

hdp*


2. Now
make
a
webpage.

#
vi

/var/www/html/rahul.html
 
 

(for
single
webpage,
for
virtual
hosbng
make
another
page
in
another
locabon,
)


3. Now
when
we
enter
the
DNS
address,
apache
server
welcome
screen
comes,
if
we
want
to

add
our
own
homepage
we
have
to
edit
a
file.

#
vi

/etc/hdpd/conf/hdpd.conf
 
 (at
last
of
the
file)

</virtual
Host


*:
80>
 
 
 (change
*
with
IP
address)


 Document
root


/var/www/html


 Servername


www.rahul.com

</virtual
Host>
 
 
 
 
 
 (save
the
file)

4. #
service

hdpd

restart

5. Now
when
you
enter
the
Domain
name
(www.rahul.com)
it
will
open
your
webpage)

6. AUTHE NTI CATI ON:

open
the
same
file
and
at
the
end
of
file,
type
the
following

<Directory
 
 /var/www/html>

AuthUserfile
 /etc/hdpd/conf/htpasswd

AuthName
 
 “Web
Authenbcabon”

AuthType
 
 Basic

Require
 
 Valid‐User

</Directory>
 
 
 
 
 (save
the
file)

7. Adduser

for

hdp

#
useradd

rahul

#
htpasswd

‐c


/etc/hdpd/conf/htpasswd

rahul
 



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


XEN
SE RVE R
( VIRTUA LIZAT ION) 




PA RA VI RTU ALIZ ATIO N


For
virtualizabon,
first
we
have
to
configure
NFS
server.

1. Install
packages

#
yum

install
system‐config‐kickstart*

#
yum

install

virt‐manager*

2. Now
copy
whole
DVD
in
a
folder
&
share
it

in
NFS
&
also
share
that
folder
in
which
kickstart
file
is

saved.

3. #
system‐config‐kickstart

(here
make
a
kickstart
file,
select
installabon
by
NFS
give
NFS
IP
&
Directory

and
save
it)

4. Also
make
a
parbbon
having
10
GB
space
and
format
that
parbbon
(
do
not
mount).

5. Now,
reboot
and
select
the
Xen‐Linux

6. Now
on
graphical
console

#
virt‐manager

New‐
forward‐
paravirtualizabon‐
forward‐
Install
media
URL:

nfs:<IP
address
of
NFS
>:/<path>

&
kickstart
URL:

nfs:<IP
address
of
NFS>:<path
where
kickstart
file
saved>
‐
next
–
Normal
Disk‐

/dev/<new
parbbon
created
by
you>
‐
next‐
finish.

7. Your
virtual‐Linux
machine
is
ready
to
install
with
the
help
of
NFS.





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


You might also like