Linux Notes
Linux Notes
Linux Notes
..............................................................................
VI visual display editor
VIM visual display editor improved
this is command mode editor for files
other editors are emacs, gedit
vi editor is most popular
it is having 3 modes:
1 command mode
2 insert mode (edit mode)
3 extended command mode
Insert mode:
i Insert at current cursor position
I Insert at start of line
a Append at current cursor position
A Append at the end of line
o Insert line below cursor position
O Insert line Above cursor position
Ins-key same as i
ex command mode:
:w to save the file
:wq to save and quit
:q to quit without saving
:q! to quit without saving (forcefully)
:wq! to save and quit file (forcefully)
{used for read only files}
:se nu to SEt line NUmber
:se nonu to remove line number
:14 to move cursor to line no. 14
command mode:
dd to delete a line (cut)
4dd to delete 4 lines (cut)
yy to copy a line (yank)
10yy to copy 10 lines (yank)
p to paste lines below cursor position
P to past lines above cursor position
u to undo
ctrl+r to redo
/<find what> to find a text inside a file
more and less commands are used to see the contents of a file page wise.
syntax. # more < file name >
ex. # more file1.txt
now to see contents page wise press space
to see contents line wise press enter
less command is same as more
but to quit less command we have to press q
head ........ this command is used to see first 10 lines of a file.
ex. # head file1.txt
to see the first 'n' lines:
ex. # head -n file1.txt
tail ....... this command is used to see last 10 lines of a file.
ex. # tail file1.txt
to see the last 'n' lines:
# tail -n file1.txt
to create a group:
syntax. # groupadd <option> <groupname>
options:
-g to set GID
ex. # groupadd -g 1010 sales
ex. # groupadd mktg
to add/delete secondary users to group
syntax # gpasswd <options> <user> <groupname>
ex. # gpasswd -a user1 sales
to add a single user
ex. # gpasswd -M user2,user3,user4 sales
to add multiple users
ex. # gpasswd -d user1 sales
to delete secondary user from member list
to delete group ( group must not contain any primary user )
syntax. # groupdel <groupname>
ex. # groupdel sales
note: all information of group is stored in /etc/group file
it contain list of secondary members also.
..............................................................................
PERMISSIONS:-
to see the present permission on any file:-
# ls -ld <filename>
permission are applied on three levels:-
owner or user level
group level
others level
access modes are of three types:-
r read only
w write/edit/delete/append
x execute/run a command
access modes are different on file and directory
file dir
r open the file 'ls' the contents of dir
w write,edit,append,delete file add/del/rename contents of dir
x to run a command/shell script to enter into dir using 'cd'
the output of ls -ld command shows following properties
-rw-r--r-- 2 root root 54 15 march ..... file1.txt
`````````` `` ```` ```` `` `````````````` ```````
filetype+permission, links , owner, grp name of owner, size in bytes,
date of modification, file name.
file types:-
- normal file
d directory
l link file(shortcut)
b block file(harddisk,floppydisk)
c character file(keyboard,mouse)
permission can be set on any file/dir by two methods:-
1 absolute method(numbers)
2 symbolic method(ugo)
system-config-network
or
neat( Network Administration Tool )
used to set ip addr in Graphical mode
ifup:- interface up
this command will enable lan card
# ifup eth0
ifdown:- interface down
this command will disable lan card
# ifdown eth0
ethtool:- used to check whether lan card is detected or not:
# ethtool eth0
yes
How to change Hostname:
hostname:- this command is used to set hostname temporarily
and view hostname
to see hostname:-
# hostname (press enter)
to set hostname temporarily:-
# hostname sysX
to make hostname permanent:-
# vi /etc/hosts
192.168.1.X sysX
# vi /etc/sysconfig/network
HOSTNAME=sysX
to check log off and log in again and use 'hostname' command
Partitions:-
fdisk command is used in linux to create,delete,view,manage partitions
# fdisk -l
Disk /dev/hda: 41.1 GB, 41174138880 bytes
Device Boot Start cyl End cyl Blocks Id File System
/dev/hda1 * 1 1020 8193118+ 7 HPFS/NTFS
/dev/hda2 1021 1033 104422+ 83 Linux
Note:- 1Block=1KB
Id is used by system to identify the type of partition.
* means it is a boot partiton.
How to create new partition:-
# fdsik < device name >
# fdisk /dev/hda
command(m for help):
commands are:-
n new partition
d delete partition
p print partition table
t set system id(tag)
w to save and quit
q to quit without saving
m prints this help
l to list system id
to create new partition:-
command(m for help): n
first cyl..........: (press enter)
size in mb +sizeM..: +100M
command(m for help): w
it will display warning:- kernel use old partition table.
# partprobe /dev/hda
now check partition:-
# fdisk -l
How to delete partition:-
first note the partition no. by using 'fdisk -l' command.
for example----/dev/hda9
then,
# fdisk /dev/hda
command(m for help) : d
partition no.(1-9) : 9
command(m for help) : w
# partprobe /dev/hda
Note:- dont delete partition already created.
delete only that partition which u hav created.
How to format partition:-
mkfs command is used to make file system.
to format partition using ext3 file system:-
# mkfs.ext3 /dev/hda9
to format partition using ext2 file system:-
# mkfs.ext2 /dev/hda9
to format partition using vfat file system:-
# mkfs.vfat /dev/hda9
How to mount the formated partition:-
mount command is used to create a link between physical partition
and an empty directory.
you can use /mnt directory for mounting any partition
or you can create your own dir. also
# mount <device name+partition no.> < mount point>
# mount /dev/hda9 /mnt
# mount /dev/hda10 /4s
after mounting you can create file/dir in that partition:-
# cd /mnt
# touch 1 2 3 4
# mkdir one two three four
mount command is also used to check whether the partition is mounted
or not
# mount (press enter)
it will show all currrently mounted partitions
Label:- label of partition is name of partition
(ex. in windows .....disk1_vol1, localdisik)
(ex. in linux ..... /boot, /root)
How to check current label:
# e2label < partition no. >
# e2label /dev/hda1
# e2label /dev/hda2
how to change label:
# e2label /dev/hda9 Myname
# e2label /dev/hda10 yourname
How to convert ext2 to ext3
# tune2fs -j /dev/hda9
How to convert ext3 to ext2
# tune2fs -O ^has_journal /dev/hda9
(capital O)
................................................................................
05/04/08
SWAP
swap is a file system, it is similar to virtual memory of windows
swap space is used to improve the system performance
How swap works?
system identifies the idle process in RAM(memory) and sends it to
swap space, so that RAM again becomes free.
swap space is created on Hard disk
Rule to create Swap?
if size of RAM < 2GB
then size of SWAP=2*RAM
else
size of SWAP= 2 + RAM
How to view info about swap
# free
# more /proc/meminfo
# more /proc/swaps
# swapon -s
-s option is to show swap
How to increase Swap size
1. first create a new partition using fdisk command
ex. /dev/hda9
2. make it a swap partition:-
# mkswap /dev/hda9
3. enable swap on this partition:-
# swapon /dev/hda9
check it by using 'swapon -s'
How to Break root password:-
1. restart system
# init 6
2. go to single user mode
at the grub boot screen select Redhat and press 'a'
then give space and type '1'
then press enter
3. at the shell prompt change the root password
sh# passwd root
******
******
4. restart the system
# init 6
What is GRUB?
GRand Unified Bootloader is the default boot loader program for RHEL5
configuration file for GRUB is
/boot/grub/grub.conf
its contents are:-
default=0 ........default os is Redhat
timeout=5 ........time to change os
splashimage=(hd0,1)/grub/splash.xpm.gz ........grahical screen
hiddenmenu ........hides os options
title Red Hat Enterprise Linux Server (2.6.18-8.el5) ...... name of 1st os
root (hd0,1) ..... partition
kernel /vmlinuz-2.6.18-8.el5 ro root=LABEL=/1 rhgb quiet ...kerne
l
initrd /initrd-2.6.18-8.el5.img ..... Initial RamDisk
title Other ....... name of 2nd os
rootnoverify (hd0,0) | boot info
chainloader +1 | of 2nd os(windows)
................................................................................
..........
03/04/08
RAID
Redundant Array of Inexpensive/Independent Disk
2 or more hard disk are combined to create RAID, it is used in servers
with SCSI Harddisk.
Redhat supports following RAID Levels:-
RAID 0 (stirping) 2min 32max
RAID 1 (mirroring) 2min 2max
RAID 4 (striping with Parity disk) 3min 32max
RAID 5 (striping with distributed parity) 3min 32max
on client machine:-
method 1:- NFS
first ping server
# ping 192.168.10.10
then mount the shared directory from server to any local directory:-
# mount 192.168.10.10:/var/ftp/pub/Server /mnt
```````````` ``````````````````` ````
IP add of server:/location of shared dir local dir.
go to mount point
# cd /mnt
now install pakage:-
# rpm -ivh <pakage name + version>
# rpm -ivh vsftpd-2.0.5-10.el5.i386.rpm
(try dialog rpm also)
method 2:- FTP
first ping server
# ping 192.168.10.10
then install pakages using ftp method:-
# rpm -ivh ftp://192.168.10.10/pub/Server/<pakage name+version>
# rpm -ivh ftp://192.168.10.10/pub/Server/vsftpd-2.0.5-10.el5.i386.rpm
YUM
YellowDog Updater Modified
yum feature was avialable with fedora, now it is available in RHEL5
RPM feature is used to install pakages but its main drawback is
Failed Dependency Resolution.
yum automatically identifies dependency in pakages,& install those
dependencies also.
by using YUM we can install, remove, list pakages and group of pakages.
Repository:- it is the place where we create RPM Dump
on server we copy all rpm from RHEL cd/dvd
here a list of all those pakages is created
this list of pakages is called Repository.
generally we copy all rpm of 'Server' directory of rhel cd/dvd to
/var/ftp/pub/Server directory on Server.
Server side configuration:-
1. copy rpms from cd/dvd to /var/ftp/pub/Server
2. install pakage createrepo* from cd
3. create repository
4. edit configuration file /etc/yum.repos.d/rhel-debuginfo.repo
Client side configuration:-
1. check ip addr
2. ping server(192.168.1.10)
3. edit configuration file /etc/yum.repos.d/rhel-debuginfo.repo
4. start installing pakages using 'yum' command.
steps for Server:-
if vsftpd pakage is not installed then install it
make dir... /var/ftp/pub/Server
1 # mount /dev/dvdwriter /mnt
# cp -r /mnt/Server/* /var/ftp/pub/Server
`````````````` ```````````````````
source target
# cd /mnt
2. # rpm -ivh createrepo*
3. # createrepo -g /mnt/Server/repodata/comps* /var/ftp/pub/Server/
source target
4. # vi /etc/yum.repos.d/rhel-debuginfo.repo
edit following lines:-
#baseurl (remove hash)
#enabled (remove hash)
baseurl=ftp://<server ip adr>/pub/Server
(192.168.1.10)
enabled=1
steps for Client side configuration:-
just edit same file /etc/yum.repos.d/rhel-debuginfo.repo
and start installing pakages using 'yum' command
yum command :-
# yum install <pakagename> rpm -ivh <pkgname>
# yum remove <pakagename> rpm -e <pkgname>
# yum list installed rpm -qa
# yum list installed <pakagename> rpm -q <pkgname>
# yum grouplist -----
# yum upgrade <pakagename> rpm -Uvh < pkg name>
# yum groupinstall <grpname> -----
..............................................................................
08/04/08
BACKUP & RESTORE
TAR:- tape archive
this command is used to create archive.
syntax: # tar <option> <destination> <source>
options are:-
-c to create a new archive
-v verbose mode
-f to create archive of files also
-x to extract archive
-z to zip archive using gzip
-j to zip archive using bzip2
# tar -cvf /var/home.tar /home
to create archive of /home directory inside /var directory
# tar -tvf /var/home.tar
to see the contents of home.tar archive without extracting
# tar -xvf /var/home.tar
to extract /var/home.tar inside /var
# tar -xvf /var/home.tar -C /home
to extract /var/home.tar to /home directory
# tar -cvfz /var/home.tar /home
to create a tar of /home and zip it using gzip utility
# tar -xvfz /var/home.tar
to extract home.tar using gunzip utility
# tar -cvfj /var/home.tar /home
to create tar and zip it using bzip2 utility
# tar -xvfj /var/home.tar
to extract home.tar uing bunzip2 utility
after creating tar how to zip
there are two zip commands used, gzip/gunzip and bzip2/bunzip2
bzip2 is more powerfully than gzip
to zip using gzip:-
# gzip <tar file name>
# gzip /var/home.tar
# ls -ld /var/home.tar.gz
to unzip using gunzip:-
# gunzip /var/home.tar.gz
to zip using bzip2:-
# bzip2 /var/home.tar
# ls -ld /var/home.tar.bz2
to unzip using bunzip2:-
# bunzip2 /var/home.tar.bz2
Remote copy:-
scp---- secure copy
this command is used to copy contents of remote system,
we can take remote backup using this command
syntax # scp -r <source> <target>
# scp -r 192.168.1.1:/home 192.168.1.2:/tmp
source pc target pc
this command will ask for root password of remote pc
Note:- this command is based on ssh
ssh is Secure SHell
ssh is secure version on telnet
it uses port no. 23 like telnet
but the data, password sent using ssh is secure because
it encrypts data before sending
using ssh we can SHARE REMOTE DESKTOP in text mode.
HOW?
# ssh <ip add of remote pc>
password of root:
to run a command on remote pc:-
# ssh <ip add of remote pc> <command>
# ssh 192.168.1.1 init 0
this command will shutdown 192.168.1.1 pc
Steps:-
server side:-
create share folder:-
# mkdir /share
give full permission:-
# chmod 777 /share
export(share) this directory:-
# vi /etc/exports
/share 192.168.1.0/255.255.255.0(rw,sync)
NOTE:- /share *(ro,async)
restart service:-
# service portmap restart
# service nfs restart
client side:-
mount server's dir on /mnt
# mount 192.168.1.10:/share /mnt
check the contents:-
# cd /mnt
# ls
Note:- # showmount -e <ip add>
this command is used to see what is shared on 'ip add'
FTP SERVER
FILE TRANSFER PROTOCOL- used to upload and download files from ftpserver
following are different ftp server:-
wuftp washington university ftp
proftp
vsftp very secure ftp
FTP SERVER:- system which is having shared file/dir
FTP CLIENT:- system which is uploading/downloading file to server
Pakages:- vsftpd*.rpm
Port no. 20 for data transfer
21 for connection control
configuration file /etc/vsftpd/vsftpd.conf
/etc/vsftpd/user_list
/etc/vsftpd/ftpusers
services vsftpd
Daemon vsftpd
Steps:-
1 check for installed pakages
# rpm -q vsftpd
if not installed then install it using nfs method
# mount 192.168.1.10:/var/ftp/pub /mnt
# cd /mnt
# cd /Server
# rpm -ivh vsftpd*
2 create shared dir inside /var/ftp
# cd /var/ftp
# mkdir upload
# mkdir download
give write permission on upload directory
# chmod ugo+w upload
create some files in download directory
# cd download
# touch one two three
3 open main configuration file:-
# vi /etc/vsftpd/vsftpd.conf
you can change any of the following options:-
line no.
12 anonymous_enable=YES
to allow anonymous user to log into ftp server
user name for anonymous users are,
ftp
anonymous
15 local_enable=YES
to allow local users that are created on server machine to log into ftp
server from
client side
example of local users is user1,user2,raj,ravi
27 anon_upload_enable=YES
to allow users to upload file to ftp server
bydefault any user is not permitted to upload files to server, he can on
ly download
115 userlist_enable=YES
Note:-
if local_enable=YES is given in vsftpd.conf file
it means local users of server can also login from client side
ex. of local users are user1,user2, and even root
but bydefault root user is NOT allowed to login from network
so to deny any local user to login into ftp server, enter its name in
ftpusers file or user_list file, and reload the service
How to access FTP Server in graphical mode:-
open web browser( mozila filefox )
type addr
ftp://<ip addr of ftp server>
like
ftp://192.168.1.10(press enter)
............................................................................
10/04/08
SAMBA SERVER
Windows OS share file/folders using SMB(server message block) protocol
Windows OS share file/folder over tcp/ip by using CIFS(common internet
file sharing) method
Linux uses SMBD/NMBD to share file and folders with windows machine
for this we have to configure samba server on linux machine
pakages samba,samba-common,samba-client,swat
portno. 137 NetBIOS name service
138 NetBIOS datagram service
139 NetBIOS session service
configuration file /etc/samba/smb.conf and /etc/samba/smbpasswd
service smb
Daemon smbd,nmbd
Server side configuration:-
1 install the pakages if not already installed
# yum install samba*
2 open main configuration file
# vi /etc/samba/smb.conf
go to last line
copy last 8 lines(press yy)
paste at the bottom of file (press p)
now edit last 8 lines by removing ;(comment)
[myshare] .......... this is share name
comment = This is 4s shared dirctory .... you can type any comment
path = /var/share ................ this is path of shared directory
valid users = user1 ............... space seprated list of users
public = no .................... to make folder visible to all
writable = yes .................. to give write permission on folder
browseable = yes .... to see icon of shared folder in my'network places
'
3 create your shared dirctory
# cd /var
# mkdir share
# cd share
# touch file1 file2 file3
4 start the service
# service smb restart
Client Side configuration:-
there are 2 methods in which we can access samba server from linux clien
t
NFS:-
# mount //<ip add of samba server>/<share name> <mountpt> -o
username=smbusername
# mount //192.168.1.10/myshare /mnt -o username=user1
FTP method:-
# smbclient //<ip add of server>/<share name> -U username
# smbclient //192.168.1.10/myshare -U user1
smb>ls
smb>get file1
smb>put anyfile
smb>quit
Note :- on samba server you must create user and provide smb password
# useradd user1
# smbpasswd -a user1
*****
*****
to access samba server in graphical mode in linux go to
places----> Network Servers--------> system name
here you will find shared folder
How to access samba server from windows machine:-
go to my network places
entire network..... find linux machine icon
here you will find shared folder
..............................................................................
BOOTING PROCESS of LINUX
1 POST=== POWER ON SELF TEST
to check the conectivity of necessary hardware.
2 BIOS=== BASIC INPUT OUTPUT SYSTEM
to identify boot device
3 MBR==== MASTER BOOT RECORD
it is first 512bytes of hard disk
it keeps the information of boot loader(GRUB)
4 GRUB=== GRAND UNIFIED BOOT LOADER
GRUB is default boot loader for linux machine
it is loaded into memory(RAM) by MBR
it is capable of reading ext3 partition directly
GRUB is having 2 stages:-
1 STAGE
it loads second stage loader
2 STAGE
it reads /boot/grub/grub.conf file
and loads kernel(vmlinuz), and initrd
(Initial Ram Disk)
vmlinuz file is kernel of redhat linux
it is heart of operating system
it is responsible for establishing link between system
hardware and shell
then kernel loads initrd
initrd loads device drivers so that kernel can
comunicate with hardware.
5 INIT=== INITIALIZATION OF OTHER PROCESS
then kernel initialize first process that is init
init is responsible for running other process, like
auditd, syslog, portmap, cups, sshd, xinetd, vsftpd,
dhcpd, crond, atd, yum-updatesd, haldaemon.
all these deamons are inside /etc/init.d directory
6 Boot specific files:-
/etc/rc.d/rc.sysinit
/etc/rc.d/rc.local
/etc/inittab.... to define default runlevel
...to define prefdm(preffered display mangager)
.bashrc ..... inside user's home directory
..... to define user specific aliases
ex. alias vi=vim
7 Login prompt and after that if it is runlevel 5 then X11 server
is started and gdm/kdm/xdm will provide graphical desktop.
PROCESS MANAGEMENT:-
How to manage different process:-
system identifies any process by its process id(PID)
how to see pid of a running process:-
# service vsftpd status
vsftpd is runnig (3954).......
(this is pid)
or
# ps -ef | grep vsftpd
NOte:- PID for init is always 1
how to start any process(daemon)
# service vsftpd start
how to stop a process
# service vsftpd stop
how to restart any process
# service vsftpd restart
how to reload the process
# service vsftpd reload
when we restart the service is shutdown and again started, it takes time
when we reload service only changes are reloaded, it is fast
if any service is not responding then we can use kill command to
abnormally terminate that process:-
# kill <pid of that process>
# kill 3954
note :- first check the pid of process, then kill it.
how to make any process to run permanently in any runlevel?
chkconfig command is used
like,
# chkconfig vsftpd on
to make vsftpd run bydefault in all possible runlevels
# chkconfig --level 35 vsftpd on
to make vsftpd run bydefault in runlevel 3 and 5 only
# chkconfig --list | grep vsftpd
to see present on/off status of vsftpd service
# chkconfig vsftpd off
to turnoff vsftpd service in all possible runlevels
..............................................................................
DHCP---- DYNAMIC HOST CONFIGURATION PROTOCOL
pakage dhcp-3.0.5-3.el5
configuration file /etc/dhcpd.conf
/usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample
/var/lib/dhcpd/dhcpd.leases
port no. 67 bootp server
68 bootp client
service dhcpd
Daemon dhcpd
How to configure dhcp server:-
check for dhcp pakage install:-
# rpm -q dhcp
if it is not installed then install it:-
# yum install dhcp*
now copy sample file to main configuration file:-
# cp /usr/share/doc/dhcp*/dhcpd.conf.sample /etc/dhcpd.conf
source sample file target main file
edit main configuration file
# vi /etc/dhcpd.conf
define the subnet with its class if ip addr
go to line no. 21
range dynamic-bootp 192.168.1.128 192.168.1.254;
start range end range
save and exit
restart the service:-
# service dhcpd restart
on client side issue following command to obtain ip addr automatically
from dhcp server:-
# dhclient
or
# netconfig
yes
* use dynamic IP configuration[bootp/dhcp]
then restart the service
# service network restart
or
user graphical method
# system-config-network
or
# neat
check the new ip addr
# ifconfig eth0
How to give DHCP reservation:-
we can bind any MAC addr to a IP addr by using dhcp ip address reservati
on
first we have to find out the mac addr of client:-
# ifconfig
it will show harware addr
now on dhcp server open main configuration file:-
# vi /etc/dhcpd.conf
modify following lines:-
hardware ethernet 12:34:56:78:AB:CD;
fixed-address 192.168.1.150;
save and exit, then restart dhcp service
note:- if you want to see mac addr of client from server machine then
# ping 192.168.1.X
# arp -a (press enter)
...............................................................................
14/04/08
DNS--- Domain Name Server/Service
DNS server is used to resolve Hostname to IP addr and IP addr to Hostnam
e
DNS server maintains Zone files
Zonefiles are database which contains information about different server
and thier corresponding ip addr
there are two type of zone database files:-
Forward Lookup Zone file:-
This file contain Hostname and corresponding IP add
It is used in Hostname to Ip addr resolution
Reverse Lookup Zone file:-
This file contain IP addr and corresponding Hostname
It is used in Ip addr to hostname resolution
When Hostname is added to Domain name it becomes FQDN
sys10.4s.com.
sys10-- hostname
4s-- domain name
.com-- top level domain
. root domain
A DNS server will have following records:-
SOA record Start Of Authority record
First record created when a dns is configured
Used for defining replication between DNS and Bakup DNS
A Address record
Used to show it Ip Addr of any hostname
PTR Pointer record
Used to show hostname of any IP Addr
NS Name Server record
Used to identify nameserver(dns server)
CNAME Canonical Name record
Used to provid alias/duplicate names to server
MX Mail Exchange record
Used to identify Mail server
Service named
Daemon named
Note:- DNS works on BIND(Berkely Internet Name Domain) version 9
In RHEL we call bind as named(nameserver daemon)
Steps:-
check ip addr:-
# ifconfig
if it is not correct set ip addr
# neat
or
# netconfig
restart network service:-
# service network restart
check hostname
# hostname
if it is not correct then set hostname
# hostname sysX.4s.com
make it permanent:-
# vi /etc/hosts
192.168.1.X sysX.4s.com sysX
# vi /etc/sysconfig/network
hostname=sysX.4s.com
now logout and login again to check hostname
check for pakage:-
# yum list installed bind*
if it is not installed, then install it:
# yum install cach*
# yum install bind*
total 9 pakages
edit configuration files:-
# vi /etc/named.caching-nameserver.conf
listen-on port 53 { 127.0.0.1;192.168.1.10; };
allow-query { localhost;192.168.1.0/24; };
match-clients { localhost;192.168.1.0/24; };
# vi /etc/named.rfc1912.zones
copy line no. 21 to 31 ( 11 lines)
paste it below line no. 31
edit these lines:
zone "4s.com" IN {
type master;
file "4s.for";
};
zone "1.168.192.in-addr.arpa" IN {
type master;
file "4s.rev";
};
change directory:-
# cd /var/named/chroot/var/named
copy and rename file localhost.zone
# cp -p localhost.zone 4s.for
copy and rename file named.local
# cp -p named.local 4s.rev
modify zone database file:-
# vi 4s.for
$TTL 86400
@ IN SOA sys10.4s.com. root.4s.com. (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS sys10.4s.com.
IN A 127.0.0.1
sys10.4s.com. IN A 192.168.1.10
sys9.4s.com. IN A 192.168.1.9
sys2.4s.com. IN A 192.168.1.2
# vi 4s.rev
$TTL 86400
@ IN SOA sys10.4s.com. root.localhost. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS sys10.4s.com.
10 IN PTR sys10.4s.com.
9 IN PTR sys9.4s.com.
2 IN PTR sys2.4s.com.
...............................................................................
MAIL SERVER:-
MAIL server uses MTA( mail transfer agent) like sendmail, qmail, postfix
squirrelmail, smail etc
MTA uses SMTP protocol to send and recieve mail at port no. 25
on the client side mail client software like mutt(Mutt Mail User agenT),
thunderbird, evolution, and webmail are used to send and recieve mail.
How to configure Mail server(sendmail):-
pakages sendmail* m4*
portno. 25 SMTP
110 POP3
143 IMAP
config file /etc/mail/sendmail.mc
/etc/mail/sendmail.cf
service sendmail
daemon sendmail
Server side configuration:-
install the pakages if not already installed
# yum remove sendmail*
# yum install sendmail*
open main configuration file:-
# vi /etc/mail/sendmail.mc
edit following line no.
116 add "# dnl" at the begining of line
155 add "# dnl" at the begining of line
(delete to new line)
compile this file and send its contents to sendmail.cf file
# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
note: this command will not show any output on screen
m4 is a macro compiler which is used to compile sendmail.mc file
start service
# service sendmail restart
set hostname ......... mail.4s.com
set ip addr
on client side:-
set hostname............. sysX.4s.com
set ip addr
set ip addr of dns server in resolv.conf file
# vi /etc/resolv.conf
nameserver 192.168.1.X
DNS Server configuration:-
In dns server the only change is in forward lookup zone file:-
add following entry:-
IN MX 5 mail.4s.com.----(to define mail server)
192.168.1.X IN A mail.4s.com.----(to define its ip addr)
now start mailing from one user to other
root user is mailing to user1:-
# mail user1
Subjet: hi
skldjf;lasjkdf
lkjdslkafja;sldjkf
these are the contents of mail
type it and then press ctrl+d
Cc: (press enter)
mail is sent to user1
how to check mail:
Login as different user, user1
$ mutt (press enter)
or
$ mail (press enter)
read a
read b
c=`expr $a + $b`
echo $c
for x in 10 20 30
do
echo $x
done
cat > animal
cat
dog
fly
goat
lion
for i in `cat animal`
do
echo " $i"
done
...............................................................................
/etc/fstab and /etc/mtab files
FSTAB---- File System Table file stores information about partition,
file type, mount point, and mounting options
system reads this file at the time of booting, and mounts the partitions
which are listed in this file
common contents of /etc/fstab are:
LABEL=/ / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
LABEL=/home /home ext3 defaults 1 2
LABEL=/usr /usr ext3 defaults 1 2
LABEL=/var /var ext3 defaults 1 2
LABEL=SWAP-hda7 swap swap defaults 0 0
/dev/hda9 /mnt ext3 defaults 0 0
label of partition mnt pt filesystem options dump fsck
how to see label of partition:-
# e2label /dev/hda2
/boot........ this is the label of /dev/hda2 partition
Installing virtualization:-
yum install <pakage name>
pakages are:
kernel-xen
xen
xen-libs
virt-managerz
gnome-applet-vm
libvirt