0% found this document useful (0 votes)
2 views86 pages

LINUX PRACTICAL FILE[11]

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 86

INDEX

Practical no 1: Installation of Red HAT Linux operating system ............... 3


Practical no 2: Software Selection and Installation................................... 12
Practical no 3: Basic Command ................................................................ 15
Practical no 4: Introduction to Grub.conf ................................................. 18
Practical no 5: Setting up Samba Server ................................................... 20
Practical no 6: Configure DHCP server and client ................................... 34
Practical No.7: Configuring DNS Server.................................................. 43
Practical no 8 : Configure a Linux Server and transferfiles to windows
client.(Setting up NFS File Server)........................................................... 51
Practical no 9: Configuring Mail Server ................................................... 59
Practical no 10: Configure FTP Server on Linux server ........................... 62
Practical No 11 : Configuring Apache Web Server In Linux .................. 76
Practical no 12: Linux System Administration ......................................... 78
Becoming super user: ............................................................................... 78
Practical no 1: Installation of Red HAT Linux operating system.
Double click on VM VirtualBox icon and Oracle VM VirtualBoxManager will open.
Click on New button in the toolbar to create a new virtual machine

Create Virtual Machine Dialog box will open

Select option “I will install operating system later”.

Select the operating system as RedHat the Type will automaticallyget selected as Linux and Version as Red hat

(Virtual Box support no of operating system which you can select from, Typedrop down menu)
Now write the virtual machine name as you want or set it by default“Red Hat Enterprise Linux 6”.
Now Select the Hard disk space as 20GB and select Store virtual machineas single machine
Now you get the option that virtual machine is created with the followingsettings
Click on “customize Hardware” Select the memory size that is RAMyou want to allocate for RedHat virtual
machine (1 GB) click Next button.
Now select create a virtual hard drive to the new machine clickcreate button.
Your RedHat Virtual Box operating system drive is created. Now startthe RedHat by double-click on it or use
Start tab on menu bar.

Red hat installation starts from here. select “ Install or upgrade an existingsystem “ option and press enter. It is a
by default graphical installation option orit will automatically start in a while.
Here it will prompt for testing media before installation select “Skip” here

Select “Next”

Language Selection :--

Using the mouse select a language to use for the installation. The languagewe select here will become the
default language for the operation system once it is installed. Once you select the appropriate language click
“Next” button
Keyboard configuration :-
Select the correct layout type(for example U.S. english) for the keyboard we should prefer for the installation
and as the system default once the selection ismade, click “Next” to continue.

Enter the installation number:-


Enter the installation number. This no. will determine the package selection set that isavailable to the installer.
If we choose to skip entering the installation number we willbe presented with a basic selection of packages to
install later on.
Click on “Skip entering installation number. Then Ok -. Skip-> Yes and then done.
Now select basic storage option

Now the system will find the hard disk space and need to re-initializefor creating directories. Select “re-
initialize” all option.
Now here we assign our Hostname change the hostname as you desire or letit be as localhost.localdomain

22.. Now select “Create Custom Layout” for manually creating Partitions

23. Disk Partitioning Setup :-


Partitioning allow to divide the hard drive into installed sections where each section behaves as its own hard
drive partitioning is particularly useful if werun multiple operation system.

For Root :-
Select the option of create custom layout then create new partitions where mount
point is /(root) of type ext4 click on “force to be primary partitions” and give sizeas 10000 MB and click Ok

For Swap :- create new partitions where file system type is swap and size 4000 MB, click Ok
Now partitioning is complete. Click on “next”.
The following is tabular presentation of Disk Partition.Sr. No Mount Point File system type Size(MB)
1 /(root)Ext3/Ext4 10000 MB
2 -/swap 4000 MB
3 /boot Ext3/Ext4 2000 MB

Now before creating New Partition Table it will ask you to format Hard Disk.

Now it will ask for format and write changes to disk, click on “Write changesto disk”

Now here we can configure our boot loader. Click “Next ” for default setting
Now it gives you prompt for installation of Software. Select customize nowfor installation of set of
software and click on “Next”

Software selection:-
By default, the Red Hat Enterprise Linux installation process loadsa selection of software that is
suitable for a system deployed as a basic server. Note that this installation does not include a graphical
environment. To include a selection of software suitablefor other roles, click the radio button that corresponds to
one of the following options: Basic Server
This option provides a basic installation of Red Hat Enterprise Linux for use ona server.
Database Server
This option provides the MySQL and PostgreSQL databases.Web server
This option provides the Apache web server.Enterprise Identity Server Base
This option provides OpenLDAP and Enterprise Identity Management (IPA)to create an
identity and authentication server.Virtual Host
This option provides the KVM and Virtual Machine Manager tools to create a host
for virtualmachines.
Desktop
This option provides the OpenOffice.org productivity suite, graphical tools suchas the GIMP,
and multimedia applications. Software Development Workstation
This option provides the necessary tools to compile software on your Red HatEnterprise Linux
system.

This option provides only the packages essential to run Red Hat EnterpriseLinux. A minimal
installation provides the basis for a single-purpose server or desktop applianceand maximizes
performance and security on such an installation.
Click on Customize now and select following software.

1> Base server -Desktop :-


DesktopKDE
X-windows
2> Server
3> Web server
4> Database
5> System management
Now the next windows showing that it is “Transferring the install imageto hard drive” it copy all files to
hard drive so installation process get faster
Now the installation start from the hard disk files.

Installation of Red hat is completed and ask for the reboot. Click on “Reboot”.
once the Red hat start it show the window saying few more steps are therefor basic configuration. Click on
“Forward”.

Here select “I agree to the license agreement” to proceed and click “Forward”.
Now it asks for software update as we don’t have the RHN No.Click “Forward” .
Click on “Forward” to finish update setup
Now we have to create Normal User for our system. Provide Username and password and click on “forward”.
The Root user is different from the user we created now. Root user has administrator rights and the user we
created is normaluser without administrative rights.
Date and Time Zone Configuration Nowselect the System date for the window,

Set your time zone by selecting the city closest to your computer'sphysical location. Click on the map to
zoom in to a particular geographical region of the world.
From here there are two ways for you to select your time zone: Using your mouse, click on the interactive map
to select a specificcity (represented by a yellow dot).
A red X appears indicating your selection.
You can also scroll through the list at the bottom of the screen to select yourtime zone. Using your mouse, click
on a location to highlight your selection.
If Red Hat Enterprise Linux is the only operating system on your computer, selectSystem clock uses UTC. The
system clock is a piece of hardware on your computer system. Red Hat Enterprise Linux uses the time zone
setting to determine the offset between the local time and UTC on the system clock. This behaviour is standard
for systems that use UNIX, Linux, and similar operating systems. Click Forward to proceed
Now it will gives you Error “Insufficient memory to configure kdump”.Click on Ok.
37.. Kdump is used for backup and recovery purpose
39. Now your RedHat Virtual Machine is ready for use. Select the RedhatVirtual Option from VM-Ware
Workstation.
Shutting Down
To shut down Red Hat Enterprise Linux, the root user may issue the
/sbin/shutdown command. The shutdown man page has a complete list ofoptions, but the two most common
uses are:
/sbin/shutdown -hnow and
/sbin/shutdown -r now
After shutting everything down, the -h option halts the machine, and the -roption reboots.
PAM console users can use the reboot and halt commands to shut down the system while in runlevels 1 through
5. For more information about PAM consoleusers, refer to the Red Hat Enterprise Linux Deployment Guide.
If the computer does not power itself down, be careful not to turn off thecomputer until a message appears
indicating that the system is halted.
Failure to wait for this message can mean that not all the hard drive partitionsare unmounted, which can lead to
file system corruption.
Practical no 2: Software Selection and Installation

RPM (Red Hat Package Manager) is a default open source and mostpopular package management utility for
Red Hat based systems like(RHEL, CentOS and Fedora).
The tool allows system administrators and users to
install, update, uninstall, query, verify and manage system softwarepackages in Unix/Linux operating systems.
The RPM formerly known as .rpm file, that includes compiled softwareprograms and libraries needed by the
packages.
This utility only works with packages that built on .rpm format.
Some Facts about RPM Package:
RPM is free and released under GPL (General Public License).
RPM keeps the information of all the installedpackages under /var/lib/rpm database.
RPM is the only way to install packages under Linux systems, if you’veinstalled packages using source code,
then rpm won’t manage it.
RPM deals with .rpm files, which contains the actual information about thepackages such as: what it is, from
where it comes, dependencies info, version info etc.
(The name of the packaged software, The version of the packaged software,The package's release number).
There are 5 basic modes of RPM:
Install : It is used to install any RPM package.
Remove : It is used to erase, remove or un-install any RPM package.
Upgrade : It is used to update the existing RPM package.
Verify : It is used to query about different RPM packages.
Query : It is used for the verification of any RPM package.
To install any package go to the Packages Folder:
# cd /media/RHEL_6.0\i386\Disc\1/Packages
Once you are in the Packages folder - Now you can run your rpm commands.
(1) Package Installation:
The basic syntax for installation with rpm (redhat package manager) is:[root@tyit ~]#rpm -ivh package [name
and version]
Following are rpm installation options:
-i : To install the package
-v : verbose it is to enable verbose and shows usefulmessages during installation.
-h : It prints during installation up to 50 hash (#) to illustrate the progress.
Example : rpm –ivh dhcp*

--force : installs package forcefully or replaces if already exists.

--aid : To install package along with dependencies

--nodeps : it performs no dependency check.

2) Remove Installation Packages:


1. –e : To uninstall the package from the system
Upgrade the Package:
-u : to upgrade the existing package.
Query the Installed Package: -q: to query any installed packages

-qa : to query all installed packages

-qi : to show general information about the package searched for.

-ql : to show list of package files installed


-qip : to show general information of uninstalled packages.

-qlp : to show list of package files of uninstalled package.

ifconfig :-
Practical no 3: Basic Command

The ifconfig command is used to set an IP address


vi stands for visual editor.
To save a file in vi press Esc key and type :wq (write and quit) or :wq!

Hostname:-
The #hostname command is used to change the hostnameSyntax:
#hostname <>
chmod:-
#chmod is used to give permission for a particular directory

mkdir :-
The mkdir is used to create a new directory

ls :-
The ls command is used to list all the files in a particular folder

ls-a :-
The ls-a command is used to list all files in a particular directory.
cat :-
The cat command is used to create a new file.Syntax:
cat>>[filename]
To save a file ctrl+d
Practical no 4: Introduction to Grub.conf
What is GRUB?
GRUB stands for Grand Unified Boot Loader.
On RedHat open the GRUB configuration file (/boot/grub/grub.conf) inany text editor as follows:
[root@tyit ~]#vim /boot/grub/grub.conf

To edit the configuration file : Go to Insert mode (press ‘i’)


Add a new entry to the configuration file:
The new entry should have the title “Red Hat Recovery”.
The new entry should not be the default.
Change the timeout of the boot selection to 10 seconds.
The task is complete when the system boots with both entries in the GRUBmenu and they both work correctly.
The grub.conf configuration file is explained in detail below.
Default=0 - This line tells grub to boot the kernel with the first title in thefile. •Timeout=5 - This line tells the

grub to boot the default kernel after 5 seconds. The default timeout can be edited too.
Splashimage=(hd0,0)/grub/splash.xpm.gz - This line helps gub to identity the path of splash image it displays
for the menu. Although user can create hisown image but it has to be kept in the same path.
Hiddenmenu - This line tells the GRUB not to display the menu and to bootthe default kernel after the timeout
expires.
Title - This line helps GRUB to set title as boot name on the menu.
The lines following the title are :
Root (hd0,0) - This line instructs the GRUB to boot the system from thefirst partition o the first hard disk.
kernel /vmlinuz-2.6.18-8.el5 ro root=LABEL=/ rhgb quiet - Specifies the kernel location which is inside the
/boot folder as well as passes the parametersto the kernel. There are already two parameters i.e. rhgb tells the
system to usethe graphical boot whereas quite option tells the system to be quiet and not to display everything
that happens at the time of system boot.
initrd /initrd-2.6.18-8.el5.img - This line tells the GRUB location of the initial ramdisk image that is used to
load special drivers for the system duringboot process.
Practical no 5: Setting up Samba Server

Samba is basically used for establishing connection among linux to windows, with help of samba file sharing
can be done using Windows file-sharing protocol and connect your Red Hat Enterprise network to a windows
network toshare files and printers.
Windows use a protocol called Server Message Block (SMB) to communicatewith each other and to share
services such as file and print sharing.
With Samba, the Linux PC icon appears in the Windows Network Placeswindow and the files on the Linux PC
can be browsed using Windows Explorer.
The Windows File system can be mounted on your Linux System , and you canbrowse the Windows files from
your Linux PC.
Before using Samba to connect to the Windows computers, it must first beinstalled on the Linux PC.
All current distributions of Linux include three Samba packages:
Samba
Samba-client
Samba-common
Settings to be done in Windows
Go to “My Computer” -> “Network” -> Right Click on “Properties”

Go to the option “Change adapter settings” -> Right click on “VMWare Network Adapter VMnet1” -> Click
“IPV4” - > Click on “Properties” button ->Set IP Address Example : 192.168.1.1 -> Click “OK” -> Click
“Close”.
Right click on “VMWare Network Adapter VMnet8” -> Click “IPV4” - > Click on “Properties” button -> Set
IP Address Example : 192.168.1.2 -> Click “OK” ->Click “Close”.

Now Open “VMWare”– Linux Virtual machine Set the IP Address to 192.168.1.3To do so follow the
steps :
Right click on top of “Network symbol” -> Go to “Edit Connections” -
>Select “eth0” ->Click on “Edit” button -> Select IPV4 - >Select “Manual” .
Now set IP Address to 192.168.1.3
Set the Netmask as 255.255.255.0

Click on “Apply” button -> Click on “Close” button.

Now connect your network - > To do so double click on Network icon.


To check whether IP Address is set :
# ifconfig

To install the samba package :


# cd /media/RHEL_6.0\i386\Disc\1/Packages

Packages] # rpm –ivh samba*


To verify service package of samba Packages] # rpmquery –qa | grep samba
OR
Packages] # rpm –qa | grep samba

The following package with the version number should be installed –“samba-3.5.4-68.el6.i686”.
Now go to your home directory:
# cd /home

Now create a directory and create few files into it. You can also write thecontents in the file.
This is a directory to be shared by samba.
mkdir tyit
Go inside tyit directory to create files intoit cd tyit (// change directory )
touch f1 f2 f3 (creating 3 files with touch command – 3 files (f1 , f2, f3) withzero byte size will be created)
Creating a file named as ‘test’ with cat command
cat > test
// Write the contents
Hello my First Samba file to be sharedPress <ctrl+d> to save the file.

Also give this directory full permission.


chmod –R 777 /tyit/

Open the samba configuration file :


# vi /etc/samba/smb.conf
Make the following changes:
To set the line numbers - :se nu

a) Line no 74: workgroup=MYGROUP To workgroup= WORKGROUP(windows workgroup)


b) Line no 79: eth0 192.168.1.1/24 192.168.1.3/24
c) Line no 80: 127. 192.168.1. 192.168.108.

Now go to end of the file - > Press Esc -> :$


At the end of the file copy 7 lines and paste it.
To copy 7 lines - type 7yy

Go to Insert mode -> press ‘ i ’ -> press Enter and now paste it at the end

To paste come out of Insert Mode – Press Esc Key -> press ‘p’

Uncomment all the 7 lines and make the following changes.


After changes line should look as follows:[tyit]
comment = samba stuffpath = /tyit
public=yes writable =yes
;printable =yes
write list = Admin Administrator

Save the configuration file - > Press Esc Key and type :wq
Now start the smb service#] service smb start
#] service smb restart

Execute the command testparm to test the parameters

Stop Firewalls
# service iptables stop

To check whether firewalls are stopped


# service iptables status
To give temporary read only permissions
# setenforce 0

# getsebool –a | grep samba

In this file home directory is off


To make it on copy first line and paste with setsebool command as follows

#setsebool samba_enable_home_dirs=1
Now to check whether home directory is enabled:
# getsebool –a | grep samba

Restart the samba service


# service smb restart
Create a samba user and assign password# useradd test1
# smbpasswd –a test1
Enter the password and confirm password

Restart the service


# service smb restart

Check whether reply and response is working fine.

Close
Now to check whether files are been transferred from Samba toWindows Run - > \\192.168.1.3
It will prompt one dialog box asking for username and passwordEnter Username – test1
Enter Password - *********

Now you will be able to see that files are transferred.


Now create a folder in Windows and check whether files from windows are
transferred to Linux
In Linux – # ls

Files are transferred.


Summary : This practical shows how files are transferred from Linux toWindows and Windows to Linux.
Practical no 6: Configure DHCP server and client

DHCP, or Dynamic Host Configuration Protocol, allows an administrator to configure network settings for all
clients on a central server. The DHCP clients request an IP address and other network settings from the DHCP
server on the network. The DHCP server in turn leases the client an IP address within a given range or leases
the client an IP address based on the MAC address of the client's network interface card (NIC). The information
includes its IP address, along with the network's name server, gateway, and proxy addresses including the
netmask. Nothing has to be configured manually on the local system, except to specify the DHCP server it
should get its network configuration from. If an IP address is assigned according to the MAC address of the
client's NIC, the same IP addresscan be leased to the client every time the client requests one. DHCP makes
network administration easier and less prone to error.
Configure dhcp server
We will configure a dhcp server and will lease ip address to clients. we are usingtwo systems one linux server
one linux clients. dhcp rpm is required to configure dhcp server.
Step 1 :- First we have to check whether DHCP is available on our machine ornot that we can check with rpm
command.
#rpm –qa dhcp
Step 2:- If DHCP package is not installed. Use the following command toinstall DHCP Package.
First move to Package Folder.
#cd /media/RHEL/Package

#pwd
Output : -/media/RHEL/PackageNow install DHCP Package #rpm –ivh DHCP*
NOTE :- rpm is executable command which is use to run rpm command, I for
inux Administration Practical Manual

install,v for verbose, h for hash format output or human readable format.

#rpm –qa | grep dhcp

Step 3 :- Check the hostname of your linux system.


#hostname

Step 4:- Now check dhcpd service in system service it should beon #setup

To assign IP to dhcp server


DHCP server have a static a IP address. First configure the IP address 192.168.1.3 with netmask of
255.255.255.0 on server. Run setup command formroot user
This will launch a new window select network configuration.

Now a new window will show you all available LAN card select your LAN card( if you don't see any LAN card
here mean you don't have install driver)
Select Use DHCP Option and remove the [*] dhcpd option. now enter static IPAddress.

Click on OK, quit and again quit to come back on root prompt.
Step 5:- Restart the network service so new ip address can take place on LANcard To disable network we use
following command

#ifdown eth0
To disable network we use following command
#ifup eth0
Step 6 :- main configuration file of dhcp server is dhcpd.conf. This file locatedon /etc directory. If this file is not
present there or you have corrupted this file,then copy new file first, if ask for overwrite press “y”.
by default when you install DHCP Package it will create dhcpd.conf.sample filein /usr directory
(/usr/sample/doc/dhcp-4.1.2/dhcpd.conf.sample) now copy the file to /etc directory and replace with the old file.

Step 7 :- Now open /etc/dhcp/dhcpd.conf

#vi /etc/dhcp/dhcpd.conf
default entry is this file look like this.

Change option domain-name “example.org” to option domain-name“Your Machine Domain-name for e.g
tyit.com”
Change option domain-name-servers ns1.example.org, ns2.example.org; to option fully qualify domain-name-
server “Your Machine Domain-name for e.gserver.tyit.com”;
Step 8 :- Uncomment line no. 18 # authoritative (Remove # mark)

Authoritative says that the DHCP server is authenticated server and DHCP clientcan connect to DHCP server, if
the option is not uncommented the DHCP client not able to connect to DHCP Server.
Step 9 :- Comment Line No 27 and 28Change these lines no 32
Subnet 10.254.239.0 netmask 255.255.255.224
{
Range 10.254.239.10 10.254.239.20;
Option routers rtr-239-0-1.example.org,rtr-239-0-2.example.org
}
Following lines after changes
Subnet 198.168.1.0 netmask 255.255.255.0 (subnet ip is the first IP of yournetwork.)
{
Range 192.168.1.10 192.168.1.20; (Range means the range of IP Addressserver want to assign to DHCP Client)
#Option routers rtr-239-0-1.example.org,rtr-239-0-2.example.org }
Save the file.

#service dhcpd start #service dhcpd restart#chkconfig dhcp on #chkconfig –list dhcp #service iptables
stop #setenfor
DHCP Client
How to create Clone Machine :-
First stop DHCP server. Right click on DHCP server virtual machine.

Go to manage and select clone option

It will open Clone Virtual Machine Wizard Click Next to proceed.


Here select the first option The Current State in the virtual machine andclick Next to Proceed.

Now select Create a Full Clone Option and click Next.

Now Provide name to your Virtual Machine or set it default Clone of RedHat Enterprise Linux

Once the clone is created click on close

Now our clone machine is ready to use. First start DHCP Server and thenstart Clone/client virtual machine.
ow we are on client machine and we will check whether through dhcp, ip address can be given to our client
machine or not before that we have to checkcurrently our machine is configured manual or dhcp. Through
wizard we will check on network
→ →
Right click on Network icon at right top corner on desktop- Edit Connection
Select system eth0
→ → →
Click on Edit button - select IPv4 setting option see the methodmanual Change it to DHCP
(Automatically)
# ifconfig
OR
This command is use to check network configuration and IP address.
#vi /etc/sysconfig/network-scripts/ifcfg-eth0 Change BOOTPROTO = dhcp
Save the file.
#service network restart
Now use ifconfig command to check whether dhcp client get the ip address andall network information from
dhcp client or not.
Practical No.7: Configuring DNS Server
Name address resolution is simply the conversion of people friendly namesinto computer friendly numbers.
It means that every interface on the network has a unique group of numberscalled as IP address.
These group of numbers present to the computers in the network but it isdifficult for the users to by heart, learn
or remember them.
DNS makes possible for the users to enter the names and then thes4e namesget converted into numbers.
The main function of name address resolution is to create an efficient userand computer interaction.
For this name address resolution there is need that how to install andconfigure the Domain Name System.
To understand, take a look on the domain and understand its working. Foreg. example.com.
In the above eg: The first part of the domain name is the name of the company or institution or an organization.
The next part after the period/dot is a called as top-level domain (TLD).

There are many TLD listed below


.com - A TLD used to register a business
.edu – A TLD for educational institution
.name – A TLD used to register sites for individuals
.gov – A TLD given to government
.mil – A TLD used for military
.org – A TLD used by a non-commercial organization

Following files are used while Configuring DNS Server.



named.conf– It is main Configuration file that contains global propertiesand other sources. It is
found in / etc/ directory.

named.ca– The file contains the name and address of root servers. Usedfor the purpose of
caching of forward zone. It is found in /var/named.

named.local – The file provides information for resolving the loopback address for the local host.
Also called as named.empty, used for thepurpose of caching of reverse zone.
It is found in /var/named/
The 2 additional files required for the master domain server are:
zone – This file contains the names and addresses of hosts in the localdomain and maps names to IP address.
reverse.zone – This file provides information to map ip-address to namesHence reverse.
DNS Configuration
root@server ~]#ifconfig

root@server ~]#vim /etc

/sysconfig/network-script/ifcfg – etho
root@server ~]#vim /etc/hosts

root@server ~] #vim /etc/sysconfig/network

root@server ~]#vim /etc/resolv.conf


root@server ~]service network restart

To install bind package :-

Desktop -> CD -> Package -> bind -> install


root@server ~]vim /etc/named.conf.

Line no.11 :- Listen – on port 53 {192.168.1.3}

Change this from 127.0.0.1 to currentMachine IP address.


Line no.12 :- Comment it using “#”
# listen –on – v6 port 53{ : : 1:};
Line no.17 :- allow – query{any;}

Check and Notedown the last line of the file :-

root@server ~] #vim /etc/named.rfc1912.zones


Save the file :- :wq

root@server ~]#cd /var/named


root@server named]#vim forward.zone

root@server named]#vim reverse.zone


root@server named]#chgrp named forward.zone

root@server named]#chgrp named reverse.zone

root@server named]#server named start

To check whether DNS is working type the following

1) dig server.tyit.com
2) dig -x 192.168.1.3
To check in the network,type thefollowing (i)ns lookup
>server.tyit.com
>192.168.1.3
>exit.
Practical no 8 : Configure a Linux Server and transferfiles to windows
client.(Setting up NFS File Server)

The Network File System (NFS) is a way of mounting Linux directoriesover a network. An NFS server can
export one or more directories that can then be mounted on a remote Linux machine.
The main use of NFS in the home context is to share out data on acentral server to all the PC’s in the house.
This way you can have a single copy of data accessible from acentral location.
The Network File System is the mostly used method for providingfile sharing services on Linux networks.
It enables local access to remote disks and file system in adistributed manner.
NFS uses a standard Client-Server architecture.
The NFS contains all those file systems that user wants to share alongwith daemon making those shares visible.
This way of sharing file by NFS is called as NFS exports.
The NFS server daemons provide remote access to the expected file system, enabling file locking over the
network and allows to enable diskquotas on the NFS exports.
On the Client side, NFS Client simply mounts the expected file systemlocally.
The mounted file system is known as NFS mount.Setting Up NFS Server:
Verify the package of NFS whether installed as shown below:
If not installed on your system, then execute the following command:

Verify IP address of the linux machine to be setup as NFS Server:

Make a directory to be exported, create few files into it and give itfull permission, as follows:

Open the configuration file of NFS, i.e, /etc/exports and writethe following lines under it:
[root@diamond ~] # vi /etc/exports.
The above entry says that server export directory has been exported to thenetwork 192.168.1.3
Save and quit the file. Restart the service of nfs and enable it fromboot as shown below :

Stop the Firewalls and check the status whether it is stopped.

Showmount command shows you all shared directories in givenIP address.(Server)

Stop the ftp service - vsftpd services and NFS services clash with each other.
Give full permissions to the shared folder.

NFS Client:
As NFS Client make a directory /nfsclient and mount the server exporteddirectory on it, as shown:

On listing, it show up the content of server export directory.


Practical no 9: Configure to the Internet
Proxy servers operate as an intermediary between a local network and Internet. Requests from local clients for
web services can be handled by the proxy server. Squid is a high-performance HTTP and FTP caching proxy
server. It is also known as a Web proxy cache. As it stores data from frequently used Web pages and files, it can
often give your users the data they need without their systems having to look to the Internet.
From squid web proxy server you can control what should be access on yournetwork from internet. It could
be act as a filter that could filter everything fromporn site to advertise , videos.
In our example we will configure squid web proxy server and filter sites and deny permission to specific host
from accessing internet.
First we set Network Adapter cards in VM-ware. We required two NIC cards.
First NIC Directly connected to ISP for internet connection
Second NIC is used to connect client and give internet connection to Client andalso used to control internet
access to client.
We require one NIC card to communicate with windows which receives internet connection from Windows
(ISP). So set it as NAT. and second NIC we set as Host- Only .
Configure squid web proxy server
Step 1 :- rpm query is used to check whether squid is install or not.
#rpm -qa squid the

If the package is not installed install with following command.move to Package Directory.
#cd /media/THEL_6.0\ i386\ Disc\ 1/Package
Now use rpm command to install SQUID Package.
#rpm –ivh squid*
Step 2 :- check the hostname and ip address of server it will be use in editing ofsquid.conf
#hostname#ifconfig

Main Squid configuration file is squid.conf in the /etc/squid/ directory. But only afew are active by default. Most
of this file is filled with comments that describe most directives and associated options.
To make editing easier use show line numbers options and locate desire tag fromline number.( set the line
numbers by :set nu)open /etc/squid/squid.conf for editing.
#Vi /etc/squid/squid.conf

Squid.conf file
Insert to Line no 34 write acl deny_host src 192.168.1.14
The above line deny access to IP Address 192.168.1.14 network.Insert Line no 35 write acl allow_network src
192.168.1.0/24
The above line allow to 192.168.1.all network IP to access internet via192.168.1.1 server.
Insert Line no 36 write acl web_deny dstdomain “/etc/squid/web_deny” The above line block access to web site
enter in web deny file. At presentthe web_deny file is not there we have to create that file.
Now we apply above acl rules. Go to line no .55 and insert following line afterline No. 55

Squid proxy server uses port no 3128 for communication.

:wq
Save the file.
Now we create web_deny file which we declare at line no. 36. At /etc/squid directory. Open thefile with
command # vi /etc/squid/web_deny and add web site name www.yahoo.com

Now save and close file with :wq


Now restart the service so the changes get applied.
#service squid start
Now set the squid service to start at boot time.
#chkconfig squid on

Now restart the squid service


#service squid restart

We are done with the squid server configuration.

SQUID CLIENT Configuration


Go to client side/clone side
Go to firefox browser-open firefox
→ → → →
Go to Edit Preference advance network tools click settings-
d
→ →
select manual proxy configuration HTTP Proxy and enter Squid proxyserver IP Address 192.168.1.1
and Port no as 8080
Click on OK and Apply
Practical no 9: Configuring Mail Server
A number of Mail Transport Agents are available for RedHat Enterprise Linux .
MTA is a program which plays a vital role in transferring the mail. It isresponsible for sending messages across
the network.
The most widely used MTA is send mail.
Sendmail is not a client program, which you use to read your email.
Sendmail is one of the behind-the-scenes programs which move email over the
internet.Normally it runs as a background daemon.
Can even be run out of the super daemon (xinetd)
Configuring Sendmail (Server Side)
Before configuring sendmail, verify whether it is installed or not as follows:
#rpmquery –qa | grep sendmail
It gives the output that whether sendmail is installed and also shows the version of the installed package
ifinstalled
If not found , then install the package as follows:
#rpm –ivh sendmail*

By default, Sendmail Server allows to connect to localhost only

So we should edit the /etc/mail/sendmail.mc file to allow connect to other hosts.To open the configuration file of
sendmail, the command is as follows:
# vim /etc/mail/sendmail.mc

Show hidden line with :se nu option on vi editor command mode.Go to line number 116
DAEMON_OPTIONS (‘Port = smtp , Addr =192.168.1.1, Name=’MTA’)
You can allow other computers to use your sendmail server by commenting.
In the sendmail.mc file, lines that begin with dn1 , which stands to delete newline are constant.
Some lines end with dn1, but lines ending with dn1 are not comments.
Comment this line with dn1 keyword followed by # sign
dn1 # DAEMON_OPTIONS (‘Port = smtp , Addr =192.168.1.1
, Name=’MTA’)
Save this file with :wq and Exit
Now generate new sendmail.cf file by using m4 command as shown below.
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
m4 is a macro processor i.e. a tool that follows principle of shorthand writing.Macro is a symbolic link for a
long string of characters.

Now check DNS Configuration:


A linux server with IP address 192.168.1.3 and hostname server.tyit.com
A Configured DNS server on Linux server
Updated /etc/hosts file
Running portmap and xinetd services ( service xinetd stop , serviceportmap stop )
Firewall should be off on server ( service iptables stop ) We haveconfigured all these steps in
our pervious article.
Check DNS server
Before start configuration of sendmail server we have to check whether ourDNS is properly configured or not .
Eg: use dig command ( dig server.svkm.com & dig -x 192.168.1.1).
Now open forward.zone file from named directory
# vi /var/named/forward.zone
Add MX Entry in forward.zone as follows:
IN MX 192.168.1.3

Now restart sendmail service


# service sendmail restart

If sendmail service restart without any error means you have configuredsendmail successfully.

Configuring sendmail Client Side


Here we are going to test sendmail server by sending and receivingmails. Now create one user
# useradd test
Set the password for that user
# passwd test
# mail [email protected]
It will ask for the Subject and Body of the mailExample: Subject: testmail
Body: Hi Everyone.
This is my First sendmail program.
Save the file by pressing keys <ctrl+d> which indicates End of file.

Type su – test
The above command switch to the user name test.To check whether mailhas received or not , type mail
command
# mail
The above command open the mailbox for the current login user.It will giveyou the details of mail received by
the subject name.

New emails are shown with letter N at starting and unread mail shown with letter U at starting. Once you read
the mail U and N notification get cleared.
To read that mail type the number which will be given in previous output
#1
You can now read the contents of mail.To exit type <Ctrl+d>
Practical no 10: Configure FTP Server on Linux server

FTP server is used to transfer files between server and clients.


All major operating system supports FTP.
FTP is the most used protocol over internet to transfer files. Likemost Internet operations, FTP works on a
client/ server model.
FTP client programs can enable users to transfer files to and from aremote system running an FTP server
program.
Any Linux system can operate as an FTP server.
It has to run only the server software—an FTP daemon with the appropriate configuration. Transfers are made
between user accounts onclient and server systems.
A user on the remote system has to log in to an account on a server andcan then transfer files to and from that
account's directories only.
A special kind of user account, named FTP, allows any user to log in toit with the username “anonymous.”
This account has its own set of directories and files that are considered public, available to anyone on the
network who wants to download them.
The numerous FTP sites on the Internet are FTP servers supporting FTPuser accounts with anonymous login.
Any Linux system can be configured to support anonymous FTP access,turning them into network FTP sites.
Such sites can work on an intranet or on the Internet.
Configuring the FTP Server
The vsftpd RPM package is required to configure a Red HatEnterprise Linux system as an ftp server.
If it is not already installed, install it with rpm commands.
After it is installed, start the service as root with the command servicevsftpd start .
The system is now an ftp server and can accept connections.
To configure the server to automatically start the service at boottime, execute the command chkconfig vsftpd on
as root.
To stop the server, execute the command service vsftpd stop.

To verify that the server is running, use the command service vs ftpd status.
Verify the package vsftpd for FTP. If installed create few files in pub. itis shown below.
#rpm –qa | grep vsftpd
This command returns the version of vsftpd.If package vsftpd is not installedthen install using following
command.
#rpm – ivh vsftpd*#rpm –ivh ftp*
Check whether the package is install or not with #rpm –qa | grep ftp command

Now use following command to start vsftpd services at boot time usingchkconfig command.
# chkconfig vsftpd on

# cd /var/ftp/pub/#cat > ftpfil


This is my ftp file for testing.Use ctrl+d to save and exit.
Verify IP address of linux machine to be configured as FTP.
#ifconfig
Set IP Address to 192.168.1.1

Open the configuration file and make the following changes :


Uncomment anonymous _enable = YES
Uncomment local_enable = YES
Uncomment anonymous_upload_enable = YES
Uncomment listen = YES
All the required steps are as follows:

#vi /etc/vsftpd/vsftpd.conf
Once the file is open do the above changes to configuration file And restartthe vsftpd service.
#service vsftpd restart

Login with anonymous user.


Now you can login with ftp 192.168.1.1
We can use Username: anonymous and password for same is blank.Here you can use ls –a command to view the
content of ftp home directory. ftp> ls –a

To Log off from ftp we use bye command


Now allow ftp anonymous write enable as follows:
#getsebool –a | grep ftp
#setsebool –P allow_ftp_annon_write on or = 1#getsebool –a | grep ftp
Allow System user to get access to ftp server.

#getsebool –a | grep ftp #setsebool –P ftp_home_dir on#getsebool –a | grep ftp


By default /var/ftp is ftp user Home directory. Check the context offile /var/ftp/pub and change to ftp
#ls –ldz /var/ftp/pub #chgrp ftp /var/ftp/pub #chown ftp /var/ftp/pub#ls –ldz /var/ftp/pub

now go to pub directory and create one file.


#cd /var/ftp/pub #touch T1 T2 T3 #cat > ftptest Welcome to ftp server
To save the document use ctrl+d

Restart the service of vsftpd and enable it fromboot. Also give full permission to the directory
/var/ftp/pub. service vsftpd start#service vsftpd restart #chkconfig vsftpd on #chkconfig –list | grep vsftpd
Now FTP is configure.Test as FTP client from other machine.
Use the following command.
#ftp 192.168.1.1
It will prompt for username and password. If your using ftp as username it willnot prompt for password as ftp is
anonymous user
Disabling anonymous FTP login :

Open configuration file.


#vi /etc/vsftpd/vsftpd.conf
Go to directive anonymous _enable = YES and make itanonymous _enable = NO.
Go to directive anonymous_upload_enable = YES and makeit anonymous_upload_enable = NO.
Now restart the vsftpd service.
#service vsftpd restart
And try to login with username anonymous. It will not allow to loginwith anonymous username and gives you
login fail message
#ftp 192.168.1.1

Block System user (normal user) for ftp login :


Now add two users to your system. e.g. add new user manish andshreyash We use following command to add
user.
#useradd manish
#passwd manish //this command use to set password.#useradd shreyash
#passwd shreyash

Now try to login with users one by one.


When you login with system user ftp home directory change to login userhome directory
ftp>pwdftp>ls ftp>bye
we can use ftp_users and users_list files to user control the access to ftp server.Suppose I want to block user
manish to get access to ftp server. Then open the user_list file and add user name manish at the end of directory.
Save and exit from file.
#vi /etc/vsftpd/user_list

Restart the vsftpd services


#service vsftpd restart.
And try to login with user name manish.
It will block the user name and gives you error message.

8) get and put command to upload and download the file.


Now create one txt file at shreyash /home directory
#cd /home#pwd
#cd shreyash#pwd
#cat > test.txt
hi… this file is created by shreyash.To save and exit press ctrl+d
ogin with user name shreyash
#ftp 192.168.1.1
now get command to download file from ftp server and it is downloaded toyour present working directory.
ftp> get test.txt

Same way create one text file in your current directory and try to upload thesame with put command.
ftp> put test_new.txt
To exit from ftp use bye command.
Practical No 11 : Configuring Apache Web Server In Linux

When you view a web page over the Internet, the code to create thatpage must be retrieved from a server
somewhere on the Internet.
The server that sends your web browser the code to display a web pageis called a web server.
There are countless web servers all over the Internet servingcountless websites to people all over the world.
Whether you need a web server to host a website on the Internet a RedHat Enterprise Linux server can function
as a web server using the Apache HTTP server.
The Apache HTTP server is a popular, open source server application that runs on many UNIX-based systems
as well as Microsoft Windows.
Since we had created DNS named as server.nm.com but on Linux browserit is showing unable to connect
because we need to configure apache web server , so that we can display out html page on web browser with the
helpof our own DNS server.nm.com
Configure web server
We will configure a web server. The necessary rpm for web server is httpd,httpd-level and check them for
install.

#rpm –ivh httpd* #rpm –qa | grep httpd

The above command give you the version no and name of package. Now configure the IP address to
192.168.1.1 and check it#ifconfig eth0 192.168.1.1
#ifconfig
start httpd daemons and verify its running status
#chkconfig httpd on #service httpd start #service httpd status Configure virtual hosting
In this example we will host a website www.nm.com to apache web server.Create a documents root directory
for this website and a index page
#mkdir –p /var/www/virtual/www.svkm.com/html

#vim /var/www/virtual/www.svkm.com/html/index.html

for testing purpose we are writing basic html code in its index page.
<html>
<head>
<title> Linux Apache Website</title>
<body>
Today we complete Apache web server practical.
</body>
</head>
</html>
Save file : wq and exitCheck IP Address:-

Check for DNS by following command:


# dig –x 192.168.1.1

Now open /etc/httpd/conf/httpd.conf main configuration file of apacheserver. #vim /etc/httpd/conf/httpd.conf


Locate virtual host tag
Now go in the end of file and copy last seven lines [ virtual host tag ] and paste them in the end of file. Change
these seven lines as shown in following.

Remove the comments from all 7 lines


<Virtual Host *:80> [email protected]
Document Root /var/www/virtual/server.svkm.com/htmlServerName www.svkm.com
ErrorLog logs/server.svkm.com-error_log CustomLog logs/server.svkm.com-access_logcommon
</Virtual Host>
now save this file :wq and exit from it

You have done necessary configuration now restart the httpd service and testthis configuration run links
command.
#service httpd restart
chmod –R 777 /var/www/virtual/www.svkm.com/html

Go to the Clone and open browser andtype server.svkm.com OR 192.168.1.1 You can view your web page.
#links 192.168.1.1

If links command retrieve your home page means you have successfully configured the virtual host now test it
with site name.
#links www.svkm.com
In output of links command you should see the index page of site
Practical no 12: Linux System Administration
Becoming super user:

Create a user account to grant him the privilege of superuser, as shown below:

Open the file /etc/sudoers and the following lines forsmith: MITH ALL = (ALL) ALL
It is as shown below:

Run the command visudo:

#visudo Test the configuration by making smith to login andperform any administrative
activity as shown below:
Add user Jackson using sudo:

Changing password of john using sudo:

Temporarily changing identity with the help of su command:


When root changes identity temporarily, with the helpof su command, the system never asks for password:

But when any local user tries to change the identitytemporarily, redhat system asks for the password as shown
below:

Administrative Commands:
useradd command with its options:

The file /etc/passwd also shows the entry of the user as follow:
chage command to change the age of user’s password :

The above command also affects the file /etc/shadow as follows:

passwd command to lock or unlock user’s password:


chsh command to change the shell of user:

Groupadd command to create a new group and gpasswd command to add members and administrator inthe
group:

The above command also affect the file /etc/group as shown:

rpm:
The packages can be installed with the help of rpm command. For that purpose, we need to mount disk image of
RedHat on linux machine. Afterinstallation, this disk image is already mounted. We can simply switch to it
under media. It is as shown in the screenshot.,

The directory Packages has all the packages. For eg, to install vsftpd,use rpm command with ‘i’ option to install.
To query and verify use rpmquery or rpm -qa, as shown below:
Shutdown command:
To shutdown after 5 mins:

To shutdown with a particular broadcast message:

To reboot after 5 mins:

To with specific broadcast message:

Administrative Files:
/etc/aliases (will be done in sendmail)

/etc/passwd
/etc/shadow

/etc/motd

/etc/issue
Graphical Tools:
To add user graphically:

Useradd dialog box comes. Write username, full name, password, shellname, home dir and click OK.

To add a group graphically, system->Administration->user.Click add group and provide the group name. Click
OK.

You might also like