You are on page 1of 150

LINUX ADMINISTRATION

PRACTICAL1: Date:
Installation of RHEL 6.X
1.Creating new virtual machine click on “Create a new virtual machine”.

2.After click on new virtual machine “Select Typical(recommended)”->Click on Next.

3.After that check radio button “Select Installer disk image file” and browse the disk file and After
click on I will install the operating system later option.Click on Next.

R.J.College,IT Department pg. 1


LINUX ADMINISTRATION

4.After that select Guest operating system for that click on “Linux” option select the version of
Linux that is “Red Hat Enterprise Linux 6 64-bit”.Click on Next.

5.After that Give name to your virtual machine in “Virtual machine name” and set the Location or
you can use Default Location which is theirs. Click on Next.

R.J.College,IT Department pg. 2


LINUX ADMINISTRATION

6.After that Specify Disk Capacity in which choose the option as “Split virtual disk into multiple
files”. Click on Next.

7.After that click on “Customize Hardware” button.

R.J.College,IT Department pg. 3


LINUX ADMINISTRATION

8. A window gets opened in which following settings has to be done:


1.Click on New CD/DVD option Select the option of “Use ISO image file” and Browse the ISO image
file

R.J.College,IT Department pg. 4


LINUX ADMINISTRATION

2.Click on Network Adapter option select the option “Host-only option” after that click on close.

9.Click on Finish.

R.J.College,IT Department pg. 5


LINUX ADMINISTRATION

10.After that click on Power on virtual machine.

11.After that click on Skip button.

R.J.College,IT Department pg. 6


LINUX ADMINISTRATION

Click next.

12.After that choose the language as English click on Next.

R.J.College,IT Department pg. 7


LINUX ADMINISTRATION

13. Select the appropriate Keyboard option as U.S. English and click on Next.

R.J.College,IT Department pg. 8


LINUX ADMINISTRATION

14. Select what type of devices will your installation involve? In that you choose Basic Storage
Device option and click next.

15.After that click on Re-initialize all.

R.J.College,IT Department pg. 9


LINUX ADMINISTRATION

16. Now here we assign our Hostname change the hostname as you desire or let it be as
localhost.localdomain and click on Next.

R.J.College,IT Department pg. 10


LINUX ADMINISTRATION

17.After that select city as “Asia/Kolkata” and click on Next.

18.Enter the root Password. Click on Next. And click on Use Any way.

R.J.College,IT Department pg. 11


LINUX ADMINISTRATION

19.After that select “Create Custom Layout” option.Click on Next

R.J.College,IT Department pg. 12


LINUX ADMINISTRATION

20.Affter create a disk partition.

R.J.College,IT Department pg. 13


LINUX ADMINISTRATION

1 /(root)Ext4 10000 MB

R.J.College,IT Department pg. 14


LINUX ADMINISTRATION

2 - /swap 4000 MB
3 /boot Ext4 2000 MB
4.After that click on Next.And Format Button.
5.After that Click on “Write Changes to disk”.

R.J.College,IT Department pg. 15


LINUX ADMINISTRATION

21.Click on Next.

R.J.College,IT Department pg. 16


LINUX ADMINISTRATION

22.After click on Next Choose two option from one part choose “Desktop” and for another part
click on Customize Now option and click on Next.

23. We have to do some changes for software selection.


1.Select Base System (Networking Tools, Performance Tools, Security Tools)

R.J.College,IT Department pg. 17


LINUX ADMINISTRATION

2.Select Servers (E-mail server, FTP server, NFS File server, Print server)

3.Select Web Services(Web server, Web servlet Engine)

R.J.College,IT Department pg. 18


LINUX ADMINISTRATION

4.Select Databases (MYSQL Database Client, MYSQL Database Server)

R.J.College,IT Department pg. 19


LINUX ADMINISTRATION

5.Select System Management (Messaging Client Support, Messaging Server Support)

6.Select Desktops(KDE Desktops, X-Windows System)

R.J.College,IT Department pg. 20


LINUX ADMINISTRATION

24.After that installation gets started.

R.J.College,IT Department pg. 21


LINUX ADMINISTRATION

Click on reboot

R.J.College,IT Department pg. 22


LINUX ADMINISTRATION

25.After that Click on Forward button.

26. Select the option “Yes,I agree to the Licence Agreement”. Click on Forward button.

R.J.College,IT Department pg. 23


LINUX ADMINISTRATION

27.Click on Forward button.

R.J.College,IT Department pg. 24


LINUX ADMINISTRATION

28.Click on Forward button. And fill the username and password.Click on Forward button.

R.J.College,IT Department pg. 25


LINUX ADMINISTRATION

29. Click on Finish button.

R.J.College,IT Department pg. 26


LINUX ADMINISTRATION

30.The login screen appears.This means installation is successful.

R.J.College,IT Department pg. 27


LINUX ADMINISTRATION

R.J.College,IT Department pg. 28


LINUX ADMINISTRATION

PRACTICAL2: Date:
Graphical User Interface and Command Line Interface and Processes
a.The Command Line Interface :
1.Use man and man -k to find out how to change the current date on your computer. Set the date
to yesterday (and don’t forget to set it back when you’re done with the exercise).

For instance, use man -k time | grep 8. You’ll find the date command. Use date mmddhhmm to set
the date.

R.J.College,IT Department pg. 29


LINUX ADMINISTRATION

2. Create a directory with the name /tempdir. Copy all files from the /etc directory that start with
an a, b, or c to this directory. mkdir /tempdir, cp /etc/[abc]* /tempdir

3. Find out which command and which specific options you will need to show a timesortedlist of
the contents of the directory /etc.
Use man ls. You’ll find the -t option, which allows you to sort ls output on time.

R.J.College,IT Department pg. 30


LINUX ADMINISTRATION

4. Find all files on your server that have a size greater than 100 MB find / -size +100M

b.MANAGING PROCESSES
(i)Move a job that was started as a foreground job into the background.
(ii)Start a few processes to make the parent-child relationship between these processes visible.
Then kill the parent process.
(iii)Using nice to Change Process Priority
(iv)Create a user account to run a cron job that sends an email message to user root on your system.

(i)Move a job that was started as a foreground job into the background.

open a terminal, and from that terminal, start the system-config-users program.

You will see that the terminal is now occupied by the graphical program you’ve just started and
that you cannot start any other programs.

R.J.College,IT Department pg. 31


LINUX ADMINISTRATION

Click in the terminal where you started system-config-users, and use the Ctrl+Z key sequence. This
temporarily stops the graphical program and returns the prompt on your terminal.

Use the bg command to move the job you started by entering the system-config-users command to
the background. You can now continue using the graphical user inter face and, at the same time,
have access to the terminal where you can start other jobs by entering new commands

From the terminal window, type the jobs command. This shows a list of all jobs that are started
from this terminal. You should see just the system-config-users command. Every job has a unique
job number in the list displayed by the jobs command. If you have just one job, it will always be
job 1.

To put a background job back into the foreground, use the fg command. By default, this command
will put the last command you started in the background into the foreground. If you want to put
another background job into the foreground, use fg followed by the job number of the job you
want to manage; for instance,
use fg 1.

R.J.College,IT Department pg. 32


LINUX ADMINISTRATION

(ii)Start a few processes to make the parent-child relationship between these processes visible.
Then kill the parent process.

Use the bash command to start Bash as a subshell in the current terminal window.

Use ssh -X localhost to start ssh as a subshell in the Bash shell you just opened.When asked if you
want to permanently add localhost to the list of known hosts,enter yes. Next enter the password
of the user root.

Type gedit & to star t gedit as a background job.

Type ps afx to show a listing of all current processes, including the parent-child
relationship between the commands you just entered.
One of the output lines shows the ssh -X localhost command you just entered. Note the PID
that you see in that output line.

R.J.College,IT Department pg. 33


LINUX ADMINISTRATION

Use kill followed by the PID number you just found to close the ssh shell. Because the ssh
environment is the parent of the gedit command, killing ssh will also kill the gedit window.

(iii)Using nice to Change Process Priority

Type the command dd if=/dev/zero of=/dev/null &, and repeat this four times.

Now star t top. You’ll see the four dd commands listed at the top. In the PR column, you can see
that the priority of all of these processes is set to 20. The NI column, which shows the actual
process niceness, indicates a value of 0 for all of the dd processes, and, in the TIME column, you
can see that all of the processes use about the same amount of processor time.

R.J.College,IT Department pg. 34


LINUX ADMINISTRATION

Now, from within the top inter face, press r. On the PID to renice prompt, type the PID of one of the
four dd processes, and press Enter. When asked Renice PID 2826 to value, type 5, and press Enter.

With the previous action, you lowered the priority of one of the dd commands. You
should immediately star t seeing the result in top, because one of the dd processes will
receive a significantly lower amount of CPU time.

R.J.College,IT Department pg. 35


LINUX ADMINISTRATION

Repeat the procedure to adjust the niceness of one of the other dd processes. Now use a
niceness value of -15. You will notice that this process now tends to consume all of the available
resources on your computer. Thus, you should avoid the extremes when working with nice.

Use the k command from the top interface to stop all processes where you adjusted the niceness.

R.J.College,IT Department pg. 36


LINUX ADMINISTRATION

(iv)Create a user account to run a cron job that sends an email message to user root on your
system.

After that login as root permition

R.J.College,IT Department pg. 37


LINUX ADMINISTRATION

R.J.College,IT Department pg. 38


LINUX ADMINISTRATION

PRACTICAL 3: Date:
Storage Devices and Links, Backup and Repository

a. Working with Storage Devices and Links


(i)create a new partition and unmount it
(ii)Create a logical volume using logical volume management
(iii)create a hard link as well as a symboliclink to a file to demonstrate the differences

(i)create a new partition and unmount it

Before creating the partition we need to check the current partitions and file systems.
To view all existing disk partitions we use ‘fdisk –l’ command.
fdisk command helps to create,view,resize,delete,change,copy and move partitions on a hard
drive. It allows creating four new primary partitions, and number of logical partitions(extended
partitions) based on the size of the hard disk by dividing from one of the primary partitions.

‘-l’ stands for listing all partitions.The above o/p shows there are currently 3 partitions
as /dev/sda1,/dev/sda2 and /dev/sda3.

View all fdisk commands using fdisk Command m

R.J.College,IT Department pg. 39


LINUX ADMINISTRATION

Step1: Create a new partition of defined space


To add new partition : n
It will ask whether to create a primary or extended partition.
th
Here,since we have already 3 primary partitions created,we can add one 4 paimary partition.
Type ‘p’ for primary partition
Select partition number : 4
Press Enter (first cylinder)
And specify the size of partition(last cylinder): +20M
To write(save) partition and exit fdisk utility :w

Step2:Command to inform kernel about a new partition


Use partx –a command.
partx : extended partition
-a : all

Type the command twice.


th
Second time it refreshes and adds 4 partition
th
To check whether the 4 partition is successfully added use fdisk –l command

R.J.College,IT Department pg. 40


LINUX ADMINISTRATION

Step3:Inform the Hard Disk about the file system of partition


Command to make the file system is #mkfs.ext4 /dev/sda4

Step4:Mount the partition


A]First create a directory named as file1 under root for mount
point B]To configure file to do mounting is fstab

Mount the partitions in /etc/fstab

R.J.College,IT Department pg. 41


LINUX ADMINISTRATION

At last type the following line by going to insert mode

Save and quit by using :wq!


Use mount command:#mount –a

To chech whether it is mounted we use df –hT command

R.J.College,IT Department pg. 42


LINUX ADMINISTRATION

Unmounting the created partition.


th
Step1:To unmount the created 4 partition i.e /dev/sda4 use “umount” command

Step2:Unmount the extended partition


A]First remove a directory for mount point using rmdir command

B]Unmount the partitions i.e file system in /etc/fstab

First open the file /etc/fstab and then remove the last line which was added.

Save and quit by using :wq!

C]Now delete the created partition 4 by fdisk Command d


Delete partition number: 4
Save the changes : w

Step3:Command to inform kernel about a deleted partition

R.J.College,IT Department pg. 43


LINUX ADMINISTRATION

Step4:Check whether partition is successfully deleted

(ii)Create a logical volume using logical volume management

Step1:Checking disk space of /(root),/home and lv(LVM) partitioned.


By Using df –h command

Create one physical volume /dev/sda5 and one volume group as tybscit-A then create one
logical volume user1 and finally mount this volume to directory /user1.

R.J.College,IT Department pg. 44


LINUX ADMINISTRATION

Extend partition
A] Press ‘n’ for new partition
B] Press ‘e’ to extended partition
C] Press ‘Enter’ on first and last sector
D] Press ‘p’ to print the partition

Now create new partition from extended partition(/dev/sda4)


A] Press ‘n’ new partition
B] Press ‘Enter’ on first and last sector
C] Press ‘t’ to change partition types
D] Give value ‘5’ partition number
E] Enter partition type ‘8e’ for linux LVM

R.J.College,IT Department pg. 45


LINUX ADMINISTRATION

Once you have completed all the steps reboot the system by using init 6 command

And print the partition table by using fdisk /dev/sda Command p


After this press ctrl+c

Create Physical Volume(pv),Volume Group(vg),Logical Volume(lv)

Create physical volume by using pvcreate command

To check your physical volume use pvs command

Create Volume group name of tybscit-A by using vgcreate command

To check your volume groups name,size and free space use vgs command

R.J.College,IT Department pg. 46


LINUX ADMINISTRATION

Create logical volume name of user1 with 2GB space from tybscit-A group by using lvcreate
command

To check your logical volume use lvs command

Setting LVM path

Make file system to ext4

Mount the Logical volume


Now,mount the logical volume tybscit--A-user1 to /user1 directory
Create one new directory /user1 under mapper directory

R.J.College,IT Department pg. 47


LINUX ADMINISTRATION

Mount the volumes to these directory

Finally check the partition using df –h command

Deleting all the volumes created


Unmount the logical volume

Remove logical volume(lv) by using lvremove command

Remove Volume group(vg) by using vgremove command

Remove Physical volume(pv) by using pvremove command

(iii)create a hard link as well as a symbolic link to a file to demonstrate the differences

Create a hard link as well as a symbolic link to the file /etc/hosts, and you will see how both behave
differently
Open a terminal and make sure you have root permissions.
Using the command ln –s /etc/hosts ~/symhosts. This creates a symbolic link with the name
symhosts in your home directory.

R.J.College,IT Department pg. 48


LINUX ADMINISTRATION

Using the command ln /etc/hosts ~/hardhosts. This creates a hard link with the name hardhosts in
your home directory.

Using the command ls –il /etc/hosts ~/symhosts ~/hardhosts .The option –I shows the inode
number.You can see the inode number is same for /etc/hosts and ~/hardhosts like all other properties
of a file.

Use rm /etc/hosts.Try to read the contents of ~/symhosts and ~/hardhosts.You will see
the difference.

Restore the original situation by recreating the /etc/hosts file.You can do that easily by making a
new hardlink using ln ~/hardhosts /etc/hosts

b.Creating a Repository
Create a repository for Yum and install httpd package using yum
Step1: Check the DVD for Packages
cd:change directory and ls:list the files under the directory

Step2: Make directory named as RHEL6 under root

R.J.College,IT Department pg. 49


LINUX ADMINISTRATION

Step3: Copying whole DVD in RHEL6 folder


[root@localhost /]#cd RHEL6/
[root@localhost RHEL6]#cp –vr /media/RHEL_6.0\ x86_64\ Disc\ 1/* /RHEL6/
While packages are getting copied from cd/packages to /RHEL6 directory

Check the folder RHEL6 to see whether the packages have been copied properly by using
ls command

Go to /etc/yum/pluginconf.d directory

Step4: Create a repository for yum

If this error comes install createrepo using rpm and install all the dependency packages until
no dependency is found

R.J.College,IT Department pg. 50


LINUX ADMINISTRATION

Now the command for creating repository will work by changing the directory to pluginconf.d

Step5:Make changes in rhel.repo file located at /etc/yum.repos.d folder

The directory /etc/yum.repos.d/ contains two .repo files which should be removed or moved to
other directory,so that YUM server will check default.repo file it self.If you don’t move or
remove the default .repo files from /etc/yum.repos.d/ folder then every time when you try to
install packages through YUM,your yum will check all these files for repositories for getting
packages which will or will not work and most probably delay is increased in getting those
packages from online servers.

R.J.College,IT Department pg. 51


LINUX ADMINISTRATION

Save the file:Press Esc key and :wq!


Come out of the yum.repos.d directory by cd command and check whether your yum server
is configured or not
In order to use yum repository we have to clean the yum meta data,so before installing
any package first time use yum clean all command.

If this error occurs


Create repo.disabled inside /etc/yum.repos.d/

Then move all the .repo files into “repo.disabled” folder

List out the updated files and folders inside /etc/yum.repos.d/

Only folder repo.disabled should be exist.


Run yum clean all to clear up your yum cache directory:

R.J.College,IT Department pg. 52


LINUX ADMINISTRATION

Now Repeat Step5:Make changes in rhel.repo file located at /etc/yum.repos.d folder


[rhel]
name=rhel6
baseurl=file:///RHEL6/Packages
Save and quit by using wq!
Now run the yum command as usual

Step6:Installing httpd package using yum install

As the httpd package is already install therefore the package is not been installed.You can try
with nmap package

R.J.College,IT Department pg. 53


LINUX ADMINISTRATION

R.J.College,IT Department pg. 54


LINUX ADMINISTRATION

Practical4: Date:
Working with RPMsm Storage and Networking
a.Using Query Options
(i) Various Query Option
Before that go into Packages.using command :

1.How to Install an RPM Package.

2.how to check the dependencies of installed RPM Package.


Using -qR option.

3.How to Check dependencies of RPM Package before Installing.


Using -qpR option.

R.J.College,IT Department pg. 55


LINUX ADMINISTRATION

4.How to Install a RPM Package Without Dependencies.


Using - -nodeps option.

5.How to check an Installed RPM Package.


Using -q option.

6.How to List all files of an installed RPM package.


Using -ql option.

7. How to List all file before installing RPM package. Using -qpl option.

R.J.College,IT Department pg. 56


LINUX ADMINISTRATION

8.How to List Recently Installed RPM Packages.

9.How to List All Installed RPM Packages.


Using -qa option. Pacakages]# rpm -qa

10.How to Upgrade a RPM Packages.


Using -Uvh option.

R.J.College,IT Department pg. 57


LINUX ADMINISTRATION

11.How to Remove a RPM Package.


Using -e option.

12.How to Remove an RPM Package Without Dependencies.


Using --nodeps option.

13.How to Query a file the belongs which RPM Package.


Using -qf option with file name.

14.How to Query a Information of Installed RPM Package.


Using -qi option.

15.Get the Information of RPM Package Before Installing.


Using -qpi command.

R.J.College,IT Department pg. 58


LINUX ADMINISTRATION

16.How to Query documentation of Installed RPM Package.


Using -qd option.

17.How to Query documentation of before Installing RPM Package.


Using -qpd option.

18.How to Verify a RPM Package.


Using -Vp option.

R.J.College,IT Department pg. 59


LINUX ADMINISTRATION

19.How to Verify all RPM Packages.


Using -Va option.

20.How to install a already installed packages in your system.


• This shows that packages is already installed. if we try to install package again. to overcome
this problem use option replacepkgs.

b.Connecting to Network

R.J.College,IT Department pg. 60


LINUX ADMINISTRATION

Restart the system:


To set IP address permanently

R.J.College,IT Department pg. 61


LINUX ADMINISTRATION

To set IP address Graphically

R.J.College,IT Department pg. 62


LINUX ADMINISTRATION

R.J.College,IT Department pg. 63


LINUX ADMINISTRATION

R.J.College,IT Department pg. 64


LINUX ADMINISTRATION

R.J.College,IT Department pg. 65


LINUX ADMINISTRATION

R.J.College,IT Department pg. 66


LINUX ADMINISTRATION

PRACTICAL5: Date:
Working with Users, Groups, and Permissions
A.Becoming super user

Step1: Creating a user account “smith” to grant him the privileges of super user.

Step2: Open the file /etc/sudoers and the following lines for smith:

SMITH ALL = (ALL) ALL

Save and quit by using wq!

Step3: Run the command visudo


Any changes made in the file /etc/sudoers reflect in the file visudo.

R.J.College,IT Department pg. 67


LINUX ADMINISTRATION

Step4: Test the configuration by making smith to login and perform any administrative
activity as shown below:
I]Add user Jackson using sudo:

II]Changing password of Jackson using sudo:

(B) Temporarily changing identity with the help of su command:

(1) When root changes identity temporarily, with the help of su command, the system never
asks for password:

(2) But when any local user tries to change the identity temporarily, redhat system asks for the
password as shown below:

R.J.College,IT Department pg. 68


LINUX ADMINISTRATION

(C)Administrative commands:

(1) useradd command with its options:


-c :Set command for user: ‘jisha’ account.
-u :Sets userID(uid)
-o :Allows non-unique UIDs
-s :Gives shell to user as shell

To check ,the file /etc/passwd shows the entry at


last Use command cat /etc/passwd

(2) chage command is used to change the password of user’s password.


OR
“Create user ‘Jisha’ and change the password ageing policies for the use

To check the details about password in the file /etc/shadow

(3) passwd command to lock or unlock user’s password:

R.J.College,IT Department pg. 69


LINUX ADMINISTRATION

(4) chsh command to change the shell of user:

(5) groupadd command to create a new group and gpasswd command to add members and
administrator in the group:

-A :specifies name of the group administrator


-M :specifies members to be added in the group

The above command also affects the file /etc/group


To check use cat /etc/group
The command displays name of the group:group password:group id:group members

(6) userdel to delete the user

you can check in /etc/passwd,the named “Jisha” no longer exists.

(7) groupdel to delete the group which is no longer used

you can check in /etc/group,the named “friends” no longer exists.

Graphically add user and groups:

R.J.College,IT Department pg. 70


LINUX ADMINISTRATION

After click on “ADD USER” button:

R.J.College,IT Department pg. 71


LINUX ADMINISTRATION

After clicking on “ADD GROUP” button:

R.J.College,IT Department pg. 72


LINUX ADMINISTRATION

R.J.College,IT Department pg. 73


LINUX ADMINISTRATION

R.J.College,IT Department pg. 74


LINUX ADMINISTRATION

PRACTICAL6: Date:
Firewall and Cryptographic services
a.Securing Server with iptables

Iptables command to accept connections by default.

Iptables command to deny all the connections(drop).


Iptables command to reject all network connections(reject).

Accept host with IP address 192.168.1.5


Block all incoming connection to port 22.

R.J.College,IT Department pg. 75


LINUX ADMINISTRATION

Allow all incoming ssh connection.

Allowing outgoing ssh connection for specific address.

Allowing outgoing ssh connection which is established for incoming ssh connection request,
once the incoming connection is allow we also need to allow response back for that incoming ssh
connection

Iptable to drop incoming ping request.

To drop all outgoing telnet connection.

To reject all incoming telnet connection.

To save changes in iptables

R.J.College,IT Department pg. 76


LINUX ADMINISTRATION

b.Setting Up Cryptographic Services


(i)Creating and exchanging gpg key for encrypting and decrypting file

1.Login as root permission and add two user first “linda” nd second “lisa”

2.Login into linda account and generate gpg key

R.J.College,IT Department pg. 77


LINUX ADMINISTRATION

R.J.College,IT Department pg. 78


LINUX ADMINISTRATION

Login into lisa’s account and generate gpg key

R.J.College,IT Department pg. 79


LINUX ADMINISTRATION

R.J.College,IT Department pg. 80


LINUX ADMINISTRATION

R.J.College,IT Department pg. 81


LINUX ADMINISTRATION

Presss Enter [tab].

Login into linda account:

R.J.College,IT Department pg. 82


LINUX ADMINISTRATION

R.J.College,IT Department pg. 83


LINUX ADMINISTRATION

R.J.College,IT Department pg. 84


LINUX ADMINISTRATION

PRACTICAL 7: Date:
Configuring Server for File Sharing
a.Configuring NFS Server and Client
1.Insatallation of nfs package.

2.Verify IP address of the linux machine to be setup as NFS server.

3.Make a directory to be exported,create few files into it and give full permission.

4.Open the configuration file of NFS,i.e, /etc/exports .

R.J.College,IT Department pg. 85


LINUX ADMINISTRATION

5.It will be a blank file write the following.

6.Restart the services of nfs and enable it form boot .

7.stop the Firewall and check the status wheather it is stopped.

8.Showmount command shows you all shared directions in given IP address.

R.J.College,IT Department pg. 86


LINUX ADMINISTRATION

9.Stop the ftp services.

10.Give full permission to the shared folder.

11.List the directory .

12.Create a clone machine.

R.J.College,IT Department pg. 87


LINUX ADMINISTRATION

R.J.College,IT Department pg. 88


LINUX ADMINISTRATION

R.J.College,IT Department pg. 89


LINUX ADMINISTRATION

12.As NFS Client make a directory /clientnfs and mount the server exported directory on it.

R.J.College,IT Department pg. 90


LINUX ADMINISTRATION

13.To unmount the file from the client machine, use the unmount command.

R.J.College,IT Department pg. 91


LINUX ADMINISTRATION

b. Configuring Samba
• 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 to share files and printers.
• Windows use a protocol called Server Message Block (SMB) to communicate with each
other and to share services such as file and print sharing.
• With Samba, the Linux PC icon appears in the Windows Network Places window 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 can browse the
Windows files from your Linux PC. Before using Samba to connect to the Windows computers, it
must first be installed on the Linux PC.
• All current distributions of Linux include three Samba packages:
- Samba
- Samba-client
- Samba-common

1:Create linux users

2: Create a directory /data on the Linux file system on the Samba server.

3:Give full permissions to this directory

4: Set directory with the samba_share_t type, if you want to treat the files as samba share data

5: Create a Samba user account that has access to the share.

6: Define the share in /etc/samba/smb.conf #vi /etc/samba/smb.conf

And make the following changes by going to end of the file->Press Esc->:$

R.J.College,IT Department pg. 92


LINUX ADMINISTRATION

A]At the end of the file copy 7 lines and paste it


B]To copy 7 lines –type 7yy and save

6:Install the samba packages

7:Start the smb service

R.J.College,IT Department pg. 93


LINUX ADMINISTRATION

8:Bring it on thr run level


#chkconfig smb on

9:Turning off firewall


System->Administration->firewall

Press close and disable

R.J.College,IT Department pg. 94


LINUX ADMINISTRATION

Cick on apply and yes

10:Go to windows and Run command Type ping 192.168.214.128

R.J.College,IT Department pg. 95


LINUX ADMINISTRATION

R.J.College,IT Department pg. 96


LINUX ADMINISTRATION

c.Configuring FTP

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. Like most Internet operations, FTP
works on a client/ server model.
• FTP client programs can enable users to transfer files to and from a remote 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 on client and server systems.
• A user on the remote system has to log in to an account on a server and can 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 to it 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 FTP user 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 Hat Enterprise 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 service vsftpd start .
• The system is now an ftp server and can accept connections.
• To configure the server to automatically start the service at boot time, 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.

1: Verify the package vsftpd for FTP. If installed create few files in pub. it is shown below. #rpm –
qa | grep vsftpd

This command returns the version of vsftpd.If package vsftpd is not installed then install using
following command.
#rpm – ivh vsftpd*
#rpm –ivh ftp*

R.J.College,IT Department pg. 97


LINUX ADMINISTRATION

2:Check whether the package is install or not with #rpm –qa | grep ftp command

3:Now use following command to start vsftpd services at boot time using chkconfig command.
# chkconfig vsftpd on

4:Create a file in pub directory


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

Use ctrl+d to save and exit


5:Verify IP address of linux macine to be configured as FTP

R.J.College,IT Department pg. 98


LINUX ADMINISTRATION

6:Open the configuration file


#vi /etc/vsftpd/vsftpd.conf
1.Uncomment anonymous_upload_enable = YES

Save and exit


7:Restart the vsftpd service

8: 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

R.J.College,IT Department pg. 99


LINUX ADMINISTRATION

To log off from ftp we use bye command


9:Allow ftp anonymous write enable as follows:
#getsebool –a | grep ftp
#setsebool –P allow_ftp_annon_write on( or = 1)

10:Allow System user to get access to ftp server


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

R.J.College,IT Department pg. 100


LINUX ADMINISTRATION

11: By default /var/ftp is ftp user Home directory. Check the context of file /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

12:Create a file in the 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

13:Restart the service of vsftpd and enable it from root


Also give full permission to the directory /var/ftp/pub. service vsftpd start
#service vsftpd restart
#chkconfig vsftpd on
#chkconfig –list | grep vsftpd

R.J.College,IT Department pg. 101


LINUX ADMINISTRATION

14:Now FTP is configure.Test as FTP client from other machine. Use the following
command. #ftp:192.168.21.129/pub/

After opening the file ftpfile.txt

R.J.College,IT Department pg. 102


LINUX ADMINISTRATION

PRACTICAL 8: Date:
DNS, DHCP and Mail Server
a.Configuring DNS
Name address resolution is simply the conversion of people friendly names into computer
friendly numbers.
It means that every interface on the network has a unique group of
numbers called as IP address.
These group of numbers present to the computers in the network but it is difficult for the users to
by heart, learn or remember them.
DNS makes possible for the users to enter the names and then thes4e names

get converted into numbers.


The main function of name address resolution is to create an efficient user and
computer interaction.
For this name address resolution there is need that how to install and

configure the Domain Name System.


To understand, take a look on the domain and understand its working. For eg.
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 properties and other sources. It
is found in / etc/ directory.
named.ca – The file contains the name and address of root servers. Used for 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 the purpose of caching of reverse zone.
It is found in /var/named/
The 2 additional files required for the master domain server are:
(i) zone – This file contains the names and addresses of hosts in the local domain and maps names
to IP address.
(ii) reverse.zone – This file provides information to map ip-address to names Hence reverse.

DNS Configuration

Step1:Check your machine’s IP Address


#ifconfig

R.J.College,IT Department pg. 103


LINUX ADMINISTRATION

Step2: #vim /etc/sysconfig/network-scripts/ifcfg – etho

Step3:#vim /etc/hosts

R.J.College,IT Department pg. 104


LINUX ADMINISTRATION

Step4:Enter the hostname


#vim /etc/sysconfig/network

R.J.College,IT Department pg. 105


LINUX ADMINISTRATION

Step5: #vim /etc/resolv.conf

Step6:Restart the network


#service network restart

R.J.College,IT Department pg. 106


LINUX ADMINISTRATION

Step7:To install the bind package


Desktop->CD->Packages->bind->install OR use command rpm –ivh bind*
Query to chech whether bind package is installed

#cd

Step8:vim /etc/named.conf.

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


Change this from 127.0.0.1 to current Machine 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 :-

R.J.College,IT Department pg. 107


LINUX ADMINISTRATION

Copy the last line “/etc/named.rfc1912.zones”

Save and quit

Step9: #vim /etc/named.rfc1912.zones

Following changes has to be done:


Line no 13:change zone “localhost.localdomain” IN to zone “tyit.com”
IN Line no 15:change file “named.localhost” to file “forward.zone”
Line no 31:change zone “1.0.0.127.in-addr.arpa” IN to zone “21.168.192.in-addr.arpa” IN
Line no 33:change file “named.loopback” to file “reverse.zone”

Save and quit

Step10:Go to named directory present in var


#cd /var/named
Step11:#cp named.localhost forward.zone
Step12:#cp named.localhost reverse.zone

After this type ls to list the files.


You can see two files are copied i.e forward.zone and reverse.zone

R.J.College,IT Department pg. 108


LINUX ADMINISTRATION

Step13:Open forward.zone

Step14:Open reverse.zone

129 is the last digit of IP Address

R.J.College,IT Department pg. 109


LINUX ADMINISTRATION

Step15:# chgrp named forward.zone


Step16:# chgrp named reverse.zone

Step17: #service named start

DNS configuration s successful


To check whether DNS is working

Step18:Use dig command


#dig server.tyit.com

R.J.College,IT Department pg. 110


LINUX ADMINISTRATION

OR
#dig –x 192.168.21.129

R.J.College,IT Department pg. 111


LINUX ADMINISTRATION

b.Configuring DHCP

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 address can 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 using two
systems one linux server one linux clients. dhcp rpm is required to configure dhcp server.

1: First we have to check whether DHCP is available on our machine or not that we can check
with rpm command.

2.Query the installed dhcp package.

3.Check the hostname of your linux system.

4.Run the setup command from root user


[root@server Packages]#setup
To aign IP to dhcp server

5.DHCP server havea static a IP address.First configure the IP address 192.168.43.243 with
netmask255.255.255.0 on server.

R.J.College,IT Department pg. 112


LINUX ADMINISTRATION

6.This will launch a new window select Network Configuration.

7.Select Device Configuration.

R.J.College,IT Department pg. 113


LINUX ADMINISTRATION

8.Select your LAN card(If you don’t see any LAN card here means you haven’t installed the driver)

R.J.College,IT Department pg. 114


LINUX ADMINISTRATION

9.Select Use DHCP option and remove the[*] dhcpd option.


To remove [*]press Spacebar
Now Enter static IP Address

R.J.College,IT Department pg. 115


LINUX ADMINISTRATION

10.Click on ok,Quit and again Quit to come back on root prompt.


11. To disable network we use following command.

12. To enable network we use following command.

13.Open the configuration file dhcpd.conf which represent in /etc/dhcpd directory.

R.J.College,IT Department pg. 116


LINUX ADMINISTRATION

14.Restart the dhcp service, stop the firewall.

R.J.College,IT Department pg. 117


LINUX ADMINISTRATION

15.After that create a clone machine.

R.J.College,IT Department pg. 118


LINUX ADMINISTRATION

R.J.College,IT Department pg. 119


LINUX ADMINISTRATION

16.The final output is that IP address which given as a range.

R.J.College,IT Department pg. 120


LINUX ADMINISTRATION

c.Setting Up a Mail Server


1.configuring mail with mutt
2.Install and configure postfix mail server

1.configuring mail with mutt


1.Installation of sendmail packages.

2.Create anew user and set a password.

3.Writing a mail.

R.J.College,IT Department pg. 121


LINUX ADMINISTRATION

4.Reading mail from root.

R.J.College,IT Department pg. 122


LINUX ADMINISTRATION

R.J.College,IT Department pg. 123


LINUX ADMINISTRATION

2.Install and configure postfix mail server


1.Installation of postfix packages.
2.Restart the basic services.

R.J.College,IT Department pg. 124


LINUX ADMINISTRATION

3.Open the configuration file.

4.Change the myhostname to your fully qualified domain name.

5.Uncomment the line and changes my networkfrom 169.100.189.0./28 to 192.168.1.0/28

6.Uncomment the mail_spool_directory=/var/spool/mail

7.Restart the postfix service.

R.J.College,IT Department pg. 125


LINUX ADMINISTRATION

R.J.College,IT Department pg. 126


LINUX ADMINISTRATION

R.J.College,IT Department pg. 127


LINUX ADMINISTRATION

R.J.College,IT Department pg. 128


LINUX ADMINISTRATION

Practical9: Date:
Web Server
a.Configuring Apache on Red Hat Enterprise Linux
• When you view a web page over the Internet, the code to create that page must be
retrieved from a server somewhere on the Internet.
• The server that sends your web browser the code to display a web page is called a web
server. There are countless web servers all over the Internet serving countless websites to people all over
the world.
• Whether you need a web server to host a website on the Internet a Red Hat 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.tyit.com but on Linux browser it 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 help of our own DNS server.tyit.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

#chkconfig httpd on
#service httpd start
#service httpd status

R.J.College,IT Department pg. 129


LINUX ADMINISTRATION

Configure virtual hosting


In this example we will host a website www.tyit.com to apache web server. Create a documents
root directory for this website and a index page

Check for DNS by following command:


# dig –x 192.168.21.129

R.J.College,IT Department pg. 130


LINUX ADMINISTRATION

Now open /etc/httpd/conf/httpd.conf main configuration file of apache server.


#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

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

R.J.College,IT Department pg. 131


LINUX ADMINISTRATION

Go to the Clone and open browser and type server.tyit.com OR 192.168.21.129


You can view your web page.
#elinks http://192.168.21.129

R.J.College,IT Department pg. 132


LINUX ADMINISTRATION

R.J.College,IT Department pg. 133


LINUX ADMINISTRATION

b.Writing a Script to Monitor Activity on the Apache Web Server

1:Creating a new script

2:Write the code

Save this file as test.sh


3:Assign execute permission and execute the script
#chmod –R 777 test.sh
#sh test.sh

R.J.College,IT Department pg. 134


LINUX ADMINISTRATION

Open another terminal and stop httpd.

After stopping httpd service the script will start the httpd service automatically

c. Using the select Command Write a simple script that asks the user to enter the name of an RPM
or fi le that the user wants to query. Write the script to present a menu that provides different
options that allow the user to do queries on the RPM database The following options must be
presented:
a. Find the RPM from which this file originates.
b. Check that the RPM where the user has provided the name is installed.
c. General info of this RPM.
d. Remove this RPM.

R.J.College,IT Department pg. 135


LINUX ADMINISTRATION

R.J.College,IT Department pg. 136


LINUX ADMINISTRATION

R.J.College,IT Department pg. 137


LINUX ADMINISTRATION

R.J.College,IT Department pg. 138


LINUX ADMINISTRATION

Practical:10 Date:
Shell script
a.Writing Shell Scripts:
Write a shell script to accept two numbers and to print its
a. addition
b. product
c. a / b.
d. (a + b) – c
1.Login as root permission on file in vi editor.

2.write a code and save it.

3.Give permission to file for execution.

R.J.College,IT Department pg. 139


LINUX ADMINISTRATION

2.Write a shell script to print


(i) Current working directory
(ii) Calendar for the month April 2002.
(ii) Today's date
(iii) Processes running

R.J.College,IT Department pg. 140


LINUX ADMINISTRATION

3.Write a shell script to check whether a number is positive or


negative using if with test statement.

R.J.College,IT Department pg. 141


LINUX ADMINISTRATION

4.Write a shell script to check whether the file 'newfile' exists or


not without using test in if.

R.J.College,IT Department pg. 142


LINUX ADMINISTRATION

5.Write a shell script to read a number between 1 to 7 and print day of the week using case in.

R.J.College,IT Department pg. 143


LINUX ADMINISTRATION

6. Modify the above script to accept Number as the first positional parameter. (console parameter)

7. Write a shell script to find the type of character typed (lower case, upper case, symbol)

R.J.College,IT Department pg. 144


LINUX ADMINISTRATION

3.Wrire a shell script to create a menu driven program to perform following tasks.
1. To see all files in /etc
2. To see list of users
3. To print current working directory
4. To call another script.
5. To exit.

R.J.College,IT Department pg. 145


LINUX ADMINISTRATION

R.J.College,IT Department pg. 146


LINUX ADMINISTRATION

R.J.College,IT Department pg. 147


LINUX ADMINISTRATION

R.J.College,IT Department pg. 148


LINUX ADMINISTRATION

b. Configuring Booting with GRUB.

Change From Red Hat Enterprise Linux to Red Hat Recovery in grub.conf file

Right click on below given tab Power ->Restart.

Before complete counting press any key from Keyboard.

R.J.College,IT Department pg. 149


LINUX ADMINISTRATION

R.J.College,IT Department pg. 150

You might also like