Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
17 views81 pages

Linux Practical

Uploaded by

tanishka zemse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views81 pages

Linux Practical

Uploaded by

tanishka zemse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 81

Practical number :-1(A) Date :- / /

Aim:-Exploring the Graphical Desktop.

1. First, create a user student System<Administration>user and Group>Enter


root’s password
Click Add user>Enter All detail>Click Ok
Log off and Login as Student

Name:
Class:T.Y.I.T Roll No:
2. System>Administration>User and Group>Enter root’s password
Select student User and Click Properties>Type New Password>Click OK

Name:
Class:T.Y.I.T Roll No:
3. Application > System Tools >Terminal
This will open terminal> Type “ls” to list all files in current directory

[student@server Desktop]$ ls -l /etc/sysconfig

total 232

-rwxr-xr-x. 1 root root 403 Jun 8 2010 atd

-rw-r-----. 1 root root 646 Jan 14 2010 auditd

-rw-r--r--. 1 root root 363 Sep 21 2017 authconfig

drwxr-xr-x. 2 root root 4096 Sep 21 2017 cbq

-rw-r--r--. 1 root root 486 Jul 14 2010 cgconfig

-rw-r--r--. 1 root root 770 Jul 14 2010 cgred.conf

-rw-r--r--. 1 root root 27 Sep 21 2017 clock

drwxr-xr-x. 2 root root 4096 Sep 1 2010 console

-rw-r--r--. 1 root root 2651 Jul 20 2010 cpuspeed

-rw-r--r--. 1 root root 110 Apr 23 2010 crond

-rw-r--r--. 1 root root 15 Sep 26 01:06 dhcp

-rw-r--r--. 1 root root 16 Sep 21 2017 firstboot

-rw-r--r--. 1 root root 25 Sep 21 2017 grub

Name:
Class:T.Y.I.T Roll No:
4. Right click on the workspace icon at the bottom right corner> Select
Preferences
Enter 4 in the Number of workspaces > Click Close

Name:
Class:T.Y.I.T Roll No:
5. System>Preferences>Network Connections > Select System eth0 > Edit>
Select IPV4 Setting

Name:
Class:T.Y.I.T Roll No:
Name:
Class:T.Y.I.T Roll No:
6. Go to top right corner > current user> Select Account Information>Change
password

Name:
Class:T.Y.I.T Roll No:
Practical number :-1(B) Date :- / /

Aim:-Command line interface.

1) Change and display the date. Use mmddhhmm to set the date

[root@server Desktop]# date

Fri Oct 12 22:25:02 PDT 2018

[root@server Desktop]# date 07131212

Fri Jul 13 12:12:00 PDT 2018

[root@server Desktop]# date 1012181055

date: invalid date `1012181055'

[root@server Desktop]# date 10121810

Fri Oct 12 18:10:00 PDT 2018

2) Create a directory with the name /tempdir.Copy all files from /etc directory that
start with an a,b or c to this directory.

[root@server Desktop]# mkdir /tempdir

[root@server Desktop]# cp /etc/[abc]* /tempdir

cp: omitting directory `/etc/abrt'

cp: omitting directory `/etc/acpi'

cp: omitting directory `/etc/alsa'

cp: omitting directory `/etc/alternatives'

cp: omitting directory `/etc/audisp'

cp: omitting directory `/etc/audit'

Name:
Class:T.Y.I.T Roll No:
cp: omitting directory `/etc/avahi'

cp: omitting directory `/etc/bash_completion.d'

cp: omitting directory `/etc/blkid'

cp: omitting directory `/etc/bluetooth'

cp: omitting directory `/etc/bonobo-activation'

cp: omitting directory `/etc/chkconfig.d'

[root@server Desktop]# ls /tempdir/

adjtime anacrontab bashrc cron.deny csh.cshrc

aliases asound.conf cgconfig.conf crontab csh.login

aliases.db at.deny cgrules.conf crypttab

[root@server Desktop]# touch a1 a2

[root@server Desktop]# touch a3

[root@server Desktop]# ls -l

total 20

-rw-r--r--. 1 root root 0 Oct 12 18:12 a1

-rw-r--r--. 1 root root 0 Oct 12 18:12 a2

-rw-r--r--. 1 root root 0 Oct 12 18:12 a3

-rwxrwxrwx. 1 root root 561 Oct 11 22:22 a.sh

-rw-r--r--. 1 root root 0 Oct 4 00:59 Dev.conf-

drwxr-xr-x. 2 root root 4096 Oct 8 00:55 dir1

-rw-r--r--. 1 root root 0 Oct 4 00:59 eth0

Name:
Class:T.Y.I.T Roll No:
3) Find out which command and which specific options you will need to show a time sorted
list of the contents of the directory /etc.

[root@server Desktop]# ls -l --sort=time

total 20

-rw-r--r--. 1 root root 0 Oct 12 18:12 a3

-rw-r--r--. 1 root root 0 Oct 12 18:12 a1

-rw-r--r--. 1 root root 0 Oct 12 18:12 a2

-rwxrwxrwx. 1 root root 561 Oct 11 22:22 a.sh

lrwxrwxrwx. 1 root root 4 Oct 8 00:56 symdir -> dir1

lrwxrwxrwx. 1 root root 8 Oct 8 00:56 symtest -> test.txt

drwxr-xr-x. 2 root root 4096 Oct 8 00:55 dir1

-rw-r--r--. 1 root root 12 Oct 8 00:54 hardtest

-rw-r-----. 1 root root 651 Oct 6 00:45 tmprequest

-rwxrwxrwx. 1 root root 411 Oct 4 21:53 p.sh

-rw-r--r--. 1 root root 0 Oct 4 00:59 Dev.conf-

-rw-r--r--. 1 root root 0 Oct 4 00:59 eth0

-rw-r--r--. 1 root root 0 Oct 4 00:59 Network

4) Create a file in your home directory and fill it all with errors that are generated if you try
to run the command grep –R root * from the /proc directory as an ordinary user.

[student@server Desktop]$ cd ~

[student@server Desktop]$ pwd

/home/student

[student@server Desktop]$ cd /proc


Name:
Class:T.Y.I.T Roll No:
[student@server proc]$ grep –R root * 2 > ~/processors.txt

[student@server proc] cat ~/processors.txt

5) Working with files

[root@server Desktop]# cat>sample.txt

[root@server Desktop]#

[root@server Desktop]# head -n 3 sample.txt

[root@server Desktop]# tail -n 4 sample.txt

Name:
Class:T.Y.I.T Roll No:
j

[root@server Desktop]# cat sample.txt

[root@server Desktop]# tac sample.txt

Name:
Class:T.Y.I.T Roll No:
f

[root@server Desktop]#

Name:
Class:T.Y.I.T Roll No:
Practical number :-1(C) Date :- / /

Aim:-Managing Processes.

A)

Step 1:

Start the command dd if=/dev/sda of=/dev/zero three times as abackground job.

(Use & at end of command to put it in background.

[root@server Desktop]# dd if=/dev/sda of=/dev/zero &

[1] 2779

[root@server Desktop]# dd if=/dev/sda of=/dev/zero&

[2] 2780

[root@server Desktop]# dd if=/dev/sda of=/dev/zero&

[3] 2782

Step 2:

Find the PID of the three dd processes you just started and change the nice value of one of the process
to -5.

[root@server Desktop]# ps aux|grep dd

root 2 0.0 0.0 0 0? S 21:35 0:00 [kthreadd]

root 1965 0.0 0.0 3816 1140 ? S 21:35 0:00 hald-addon-input: Listening on
/dev/input/event2 /dev/input/event0

68 1971 0.0 0.0 3456 1068 ? S 21:35 0:00 hald-addon-acpi: listening on acpid socket
/var/run/acpid.socket

root 2410 0.0 0.0 13708 1524 ? Ssl 21:37 0:00 /bin/dbus-daemon --fork --print-pid 5 --print-
address 7 --session

Name:
Class:T.Y.I.T Roll No:
root 2779 28.1 0.0 4196 644 pts/0 R 21:40 0:07 dd if=/dev/sda of=/dev/zero

root 2780 22.8 0.0 4196 644 pts/0 R 21:40 0:05 dd if=/dev/sda of=/dev/zero

root 2782 22.6 0.0 4196 648 pts/0 R 21:40 0:04 dd if=/dev/sda of=/dev/zero

root 2791 0.0 0.0 4316 748 pts/0 S+ 21:41 0:00 grep dd

[root@server Desktop]# renice -5 2780

2780: old priority 0, new priority -5

Step 3:

Start the command dd if=/dev/zero of=/dev/sda as a foreground job.Next use the appropriate
procedure to put it in the background.Then verify that it indeed runs as a background job.

[root@server Desktop]# dd if=/dev/zero of=/dev/sda

^Z

(Press CTRL+ z to put a foreground job to background)

[5]+ Stopped dd if=/dev/zero of=/dev/sda

[root@server Desktop]# ps aux|grep dd

root 2 0.0 0.0 0 0? S 21:35 0:00 [kthreadd]

root 1965 0.0 0.0 3816 1140 ? S 21:35 0:00 hald-addon-input: Listening on
/dev/input/event2 /dev/input/event0

68 1971 0.0 0.0 3456 1068 ? S 21:35 0:00 hald-addon-acpi: listening on acpid socket
/var/run/acpid.socket

root 2410 0.0 0.0 13708 1524 ? Ssl 21:37 0:00 /bin/dbus-daemon --fork --print-pid 5 --print-
address 7 --session

root 2826 0.0 0.0 4200 696 pts/0 T 21:43 0:00 dd

root 2834 11.9 0.0 4196 648 pts/0 T 21:44 0:02 dd if=/dev/zero of=/dev/sda

root 2841 0.0 0.0 4316 748 pts/0 S+ 21:44 0:00 grep dd

Name:
Class:T.Y.I.T Roll No:
Step 4:

Use the most efficient procedure to terminate all of the dd commands.

[root@server Desktop]# killall dd

[root@server Desktop]#

B) Using the top Interface

[root@server Desktop]# dd if=/dev/sda of=/dev/zero &

[1] 2880

[root@server Desktop]# dd if=/dev/sda of=/dev/zero &

[2] 2881

[root@server Desktop]# dd if=/dev/sda of=/dev/zero&

[3] 2883

[root@server Desktop]# top

top - 21:46:50 up 11 min, 2 users, load average: 0.66, 0.71, 0.43

Tasks: 178 total, 4 running, 174 sleeping, 0 stopped, 0 zombie

Cpu(s): 4.7%us, 45.5%sy, 0.0%ni, 0.0%id, 48.2%wa, 1.0%hi, 0.7%si, 0.0%st

Mem: 2071700k total, 1122088k used, 949612k free, 783476k buffers

Swap: 4161528k total, 0k used, 4161528k free, 138780k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND

2880 root 20 0 4196 648 552 D 17.9 0.0 0:04.63 dd

2881 root 20 0 4196 648 552 R 14.6 0.0 0:02.38 dd

2883 root 20 0 4196 648 552 R 13.6 0.0 0:01.84 dd

Name:
Class:T.Y.I.T Roll No:
2218 root 20 0 63376 18m 6400 S 2.6 0.9 0:03.83 Xorg

2862 root 20 0 45316 11m 9376 S 1.0 0.6 0:00.40 gnome-terminal

26 root 20 0 0 0 0 S 0.7 0.0 0:02.12 kswapd0

15 root 20 0 0 0 0 R 0.3 0.0 0:00.10 kblockd/0

1 root 20 0 2824 1408 1200 S 0.0 0.1 0:01.28 init

2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd

3 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/0

a) Press “r “to change the renice value

top - 21:47:05 up 11 min, 2 users, load average: 1.25, 0.84, 0.47

Tasks: 178 total, 3 running, 175 sleeping, 0 stopped, 0 zombie

Cpu(s): 3.3%us, 88.0%sy, 0.0%ni, 0.0%id, 8.0%wa, 0.3%hi, 0.3%si, 0.0%st

Mem: 2071700k total, 1121500k used, 950200k free, 783720k buffers

Swap: 4161528k total, 0k used, 4161528k free, 138784k cached

PID to renice: 2883

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND

2880 root 20 0 4196 648 552 R 47.8 0.0 0:09.87 dd

2881 root 20 0 4196 648 552 D 20.6 0.0 0:04.50 dd

2883 root 20 0 4196 648 552 D 20.3 0.0 0:03.88 dd

2862 root 20 0 45252 11m 9388 S 1.3 0.6 0:00.45 gnome-terminal

b) After providing the PID of process system asks you to enter the renice value. Enter -5 as the renice
value.

top - 21:47:05 up 11 min, 2 users, load average: 1.25, 0.84, 0.47

Tasks: 178 total, 3 running, 175 sleeping, 0 stopped, 0 zombie

Cpu(s): 3.3%us, 88.0%sy, 0.0%ni, 0.0%id, 8.0%wa, 0.3%hi, 0.3%si, 0.0%st

Name:
Class:T.Y.I.T Roll No:
Mem: 2071700k total, 1121500k used, 950200k free, 783720k buffers

Swap: 4161528k total, 0k used, 4161528k free, 138784k cached

Enter the renice value : -5

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND

2880 root 20 0 4196 648 552 R 47.8 0.0 0:09.87 dd

2881 root 20 0 4196 648 552 D 20.6 0.0 0:04.50 dd

2883 root 20 0 4196 648 552 D 20.3 0.0 0:03.88 dd

2862 root 20 0 45252 11m 9388 S 1.3 0.6 0:00.45 gnome-terminal

c)

Observe the reniced process will be shifted upwards. Use qto quit the top interface.

top - 21:47:05 up 11 min, 2 users, load average: 1.25, 0.84, 0.47

Tasks: 178 total, 3 running, 175 sleeping, 0 stopped, 0 zombie

Cpu(s): 3.3%us, 88.0%sy, 0.0%ni, 0.0%id, 8.0%wa, 0.3%hi, 0.3%si, 0.0%st

Mem: 2071700k total, 1121500k used, 950200k free, 783720k buffers

Swap: 4161528k total, 0k used, 4161528k free, 138784k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND

2883 root 20 -5 4196 648 552 D 20.3 0.0 0:03.88 dd

2880 root 20 0 4196 648 552 R 47.8 0.0 0:09.87 dd

2881 root 20 0 4196 648 552 D 20.6 0.0 0:04.50 dd

2862 root 20 0 45252 11m 9388 S 1.3 0.6 0:00.45 gnome-terminal

Name:
Class:T.Y.I.T Roll No:
Practical number :-2(A) Date :- / /

Aim:-Working with links.


Step 1:

Create a text file and a directory. Symbolic link can be created for file as well as directory
using ln –s command.

[root@server Desktop]# cat>test.txt

Hello World

[root@server Desktop]# mkdir dir1

[root@server Desktop]# ln -s test.txt symtest

[root@server Desktop]# ln -s dir1 symdir

Step 2:

Hardlink can be created only for files using lncommand(Without option)

[root@server Desktop]# ln test.txt hardtest

Step 3:

Observe that the inode numbers of hardlink and the original file will be same whereas that
of ofsymlink will be different.

[root@server Desktop]# ls-il

total 24

524807 -rwxrwxrwx. 1 root root 540 Oct 4 22:08 a.sh

524730 -rw-r--r--. 1 root root 0 Oct 4 00:59 Dev.conf-

663906 drwxr-xr-x. 2 root root 4096 Oct 8 00:55 dir1

524731 -rw-r--r--. 1 root root 0 Oct 4 00:59 eth0

Name:
Class:T.Y.I.T Roll No:
524795 -rw-r--r--. 2 root root 12 Oct 8 00:54 hardtest

524721 -rw-r--r--. 1 root root 0 Oct 4 00:59 Network

524646 -rwxrwxrwx. 1 root root 411 Oct 4 21:53 p.sh

524732 lrwxrwxrwx. 1 root root 4 Oct 8 00:56 symdir -> dir1

524553lrwxrwxrwx. 1 root root 8 Oct 8 00:56 symtest -> test.txt

524795 -rw-r--r--. 2 root root 12 Oct 8 00:54 test.txt

525039 -rw-r-----. 1 root root 651 Oct 6 00:45 tmprequest

Step 4:

If you delete the original file the symbolic link will no longer be there but the hardlink will
continue to exist.

[root@server Desktop]# cat symtest

Hello World

[root@server Desktop]# cat hardtest

Hello World

[root@server Desktop]# rm test.txt

rm: remove regular file `test.txt'? y

[root@server Desktop]# cat symtest

cat: symtest: No such file or directory

[root@server Desktop]# cat hardtest

Hello World

Name:
Class:T.Y.I.T Roll No:
Practical number :-2(B) Date :- / /

Aim:-Making a Backup.

Code:-

Step 1:

Create a backup of /tmp directory in an archive with the name /tmp.tar

Syntax: tar options destination source

[root@server Desktop]# mkdir /back

[root@server Desktop]# tar zcvf /back/tmp.tar /tmp

tar: Removing leading `/' from member names

/tmp/

/tmp/tmp_tWLq0/

/tmp/tmp80CuA6/

/tmp/tmptHRU2r/

/tmp/tmpM1ym1p/

/tmp/tmpXwj3eF/

/tmp/.esd-506/

tar: /tmp/.esd-506/socket: socket ignored

/tmp/tmp10jnkF/

/tmp/virtual-ckt.LoY7Lf/

/tmp/tmpsOFjs8/

Name:
Class:T.Y.I.T Roll No:
/tmp/linda.key

/tmp/.X0-lock

/tmp/tmpi9yyZP/

/tmp/tmpc6tL3K/

tar: /tmp: file changed as we read it

Step 2:

Verify the file .

[root@server Desktop]# file /back/tmp.tar

/back/tmp.tar: gzip compressed data, from Unix, last modified: Mon Oct 8 01:15:28 2018

Step 3:

Extract the tar file using #tar xvf /back/tmp.tar command.

[root@server Desktop]# cd /back

[root@server back]# tar xvf /back/tmp.tar

tmp/

tmp/tmp_tWLq0/

tmp/tmp80CuA6/

tmp/tmptHRU2r/

tmp/tmpM1ym1p/

tmp/tmpXwj3eF/

tmp/.esd-506/

tmp/tmp10jnkF/

Name:
Class:T.Y.I.T Roll No:
Practical number :-2(C) Date :- / /

Aim:-Creating a Repository.

Code:-

Install the createrepo package first and open the terminal in RHEL’s Packages directory.

[root@server Packages]# mkdir/myrepo

[root@server Packages]# cp * /myrepo

[root@server Packages]# createrepo /myrepo

124/2679 - mesa-libGLU-devel-7.7-2.el6.i686.rpm

iso-8859-1 encoding on Ville Skytt

<[email protected]> - 2.8.2-2

2679/2679 - rt61pci-firmware-1.2-7.el6.noarch.rpm

Saving Primary metadata

Saving file lists metadata

Saving other metadata

[root@server Packages]# yum repolist

Loaded plugins: refresh-packagekit, rhnplugin

This system is not registered with RHN.

RHN support will be disabled.

repolist: 0

[root@server Packages]# yum searchnmap

Loaded plugins: refresh-packagekit, rhnplugin

Name:
Class:T.Y.I.T Roll No:
This system is not registered with RHN.

RHN support will be disabled.

================================ Matched: nmap =================================

nmap.i686 : Network exploration tool and security scanner

[root@server Packages]# vi /etc/yum.repos.d/myrepo.repo

[i]

[myrepo]

name=myrepo

baseurl=file:///myrepo

gpgcheck=0

Esc :wq

[root@server Packages]# yum repolist

Loaded plugins: refresh-packagekit, rhnplugin

This system is not registered with RHN.

RHN support will be disabled.

myrepo | 1.3 kB 00:00 ...

myrepo/primary | 1.3 MB 00:00 ...

myrepo 2679/2679

repo id repo name status

myrepomyrepo 2,679

repolist: 2,679

[root@server Packages]# yum install squid

Loaded plugins: refresh-packagekit, rhnplugin

Name:
Class:T.Y.I.T Roll No:
This system is not registered with RHN.

RHN support will be disabled.

Setting up Install Process

Resolving Dependencies

--> Running transaction check

---> Package squid.i686 7:3.1.4-1.el6 set to be updated

--> Processing Dependency: perl(DBI) for package: 7:squid-3.1.4-1.el6.i686

--> Running transaction check

---> Package perl-DBI.i686 0:1.609-4.el6 set to be updated

--> Finished Dependency Resolution

Dependencies Resolved

================================================================================

Package Arch Version Repository Size

================================================================================

Installing:

squid i686 7:3.1.4-1.el6 myrepo 1.7 M

Installing for dependencies:

perl-DBI i686 1.609-4.el6 myrepo 707 k

Transaction Summary

================================================================================

Name:
Class:T.Y.I.T Roll No:
Install 2 Package(s)

Upgrade 0 Package(s)

Total download size: 2.4 M

Installed size: 7.1 M

Is this ok [y/N]: y

Downloading Packages:

Total 50 MB/s | 2.4 MB 00:00

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

Installing : perl-DBI-1.609-4.el6.i686 1/2

Installing : 7:squid-3.1.4-1.el6.i686 2/2

Installed:

squid.i686 7:3.1.4-1.el6

Dependency Installed:

perl-DBI.i686 0:1.609-4.el6

Complete!

Name:
Class:T.Y.I.T Roll No:
Practical number :-3(A) Date :- / /

Aim:- Using Query Options.


-q To query about your packagae.
-qa Query all installed packages
-l List all files in a package
-c List all Configuration files
-d List all Documentation files
(NOTE: The corresponding packages must first be installed before querying rpm about package.)

Name:
Class:T.Y.I.T Roll No:
Name:
Class:T.Y.I.T Roll No:
Name:
Class:T.Y.I.T Roll No:
Practical number :-3(B) Date :- / /

Aim:-Extracting files from RPMs.

Code:-

Extract the package that contains the dhcp file so that you can copy the original
configuration file out of the package to its target destination.

Steps:

Copy rpm package from RHEL to linuxDesktop using following commands.

Step 1: Ensure that your current working directory is Packages directory from RHEL.

[root@server Packages]# cp dhcp-4.1.1-12.P1.el6.i686.rpm /home/ckt/Desktop

Step 2: Here ckt is home directory of normal user.Change to the Desktop of any normal
user account that exists on your machine rather than ckt.

[root@server Packages]# cd /home/ckt/Desktop

Step 3:

[root@server Desktop]# rpm2cpio dhcp-4.1.1-12.P1.el6.i686.rpm | cpio -idmv

./etc/dhcp

./etc/dhcp/dhcpd.conf

./etc/dhcp/dhcpd6.conf

./etc/openldap/schema/dhcp.schema

./etc/rc.d/init.d/dhcpd

./etc/rc.d/init.d/dhcpd6

./etc/rc.d/init.d/dhcrelay

Name:
Class:T.Y.I.T Roll No:
./etc/sysconfig/dhcpd

./etc/sysconfig/dhcpd6

./etc/sysconfig/dhcrelay

./usr/bin/omshell

./usr/sbin/dhcpd

./usr/sbin/dhcrelay

./usr/share/doc/dhcp-4.1.1

./usr/share/doc/dhcp-4.1.1/3.0b1-lease-convert

./usr/share/doc/dhcp-4.1.1/IANA-arp-parameters

./usr/share/doc/dhcp-4.1.1/LICENSE

./usr/share/doc/dhcp-4.1.1/README

./usr/share/doc/dhcp-4.1.1/RELNOTES

4292 blocks

[root@server Desktop]#

Name:
Class:T.Y.I.T Roll No:
Practical number :-4
Date :- / /

Aim:-Setting up Local Area Network and Networking through manual


(Statically) by Using Setup command or through wizard.

Code:-
[root@ server Desktop]# setup
[root@server Desktop]# system-config-network

Name:
Class:T.Y.I.T Roll No:
Name:
Class:T.Y.I.T Roll No:
[root@server Desktop]# service network restart
Shutting down interface eth0: Device state: 3 (disconnected) [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: Active connection state: activated
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/3[OK ]

[root@server Desktop]# ifconfig


eth0 Link encap:EthernetHWaddr 00:0C:29:9B:13:37
inet addr:172.16.0.174 Bcast:172.16.3.255 Mask:255.255.252.0
inet6addr: fe80::20c:29ff:fe9b:1337/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:379 errors:0 dropped:0 overruns:0 frame:0 TX
packets:109 errors:0 dropped:0 overruns:0 carrier:0collisions:0
txqueuelen:1000
RX bytes:48422 (47.2 KiB) TX bytes:17907 (17.4 KiB)
Interrupt:19 Base address:0x2024

lo Link encap:Local Loopback inet


addr:127.0.0.1 Mask:255.0.0.0

Name:
Class:T.Y.I.T Roll No:
inet6addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:568 errors:0 dropped:0 overruns:0 frame:0TX
packets:568 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:42160 (41.1 KiB) TX bytes:42160 (41.1 KiB)

[root@server Desktop]# ifconfig lo


lo Link encap:Local Loopback inet
addr:127.0.0.1 Mask:255.0.0.0inet6addr:
::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:574 errors:0 dropped:0 overruns:0 frame:0TX
packets:574 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:42700 (41.6 KiB) TX bytes:42700 (41.6 KiB)

BASIC NETWORK CONFIGURATION EXAMPLE AND IMPLEMENTATION

[root@server Desktop]# hostname


server

[root@server Desktop]# vi /etc/sysconfig/network


NETWORKING=yes
HOSTNAME=server

Name:
Class:T.Y.I.T Roll No:
Name:
Class:T.Y.I.T Roll No:
Practical number :-5
Date :- / /

Aim:-Working with Users,Groups and Permissions.

Code:-

Step 1:

Create the user accounts fy,sy,ty and msc and assign them passwords.

[root@server Desktop]# useradd fy

[root@server Desktop]# passwd fy

Changing password for user fy.

New password:

BAD PASSWORD: it is based on a dictionary word

BAD PASSWORD: is too simple

Retype new password:

passwd: all authentication tokens updated successfully.

[root@server Desktop]# useradd sy

[root@server Desktop]# passwd sy

Changing password for user sy.

New password:

BAD PASSWORD: it is based on a dictionary word

BAD PASSWORD: is too simple

Retype new password:

Name:
Class:T.Y.I.T Roll No:
passwd: all authentication tokens updated successfully.

[root@server Desktop]# useradd ty

[root@server Desktop]# passwd ty

Changing password for user ty.

New password:

BAD PASSWORD: it is based on a dictionary word

BAD PASSWORD: is too simple

Retype new password:

passwd: all authentication tokens updated successfully.

[root@server Desktop]# useradd msc

[root@server Desktop]# passwd msc

Changing password for user msc.

New password:

BAD PASSWORD: it is based on a dictionary word

BAD PASSWORD: is too simple

Retype new password:

passwd: all authentication tokens updated successfully.

Step 2:

Create 2 groups support and sales and assign fy,sy as members of support group and
ty,msc as members of sales group.

[root@server Desktop]# groupadd support

[root@server Desktop]# groupadd sales

[root@server Desktop]# usermod -g support fy

Name:
Class:T.Y.I.T Roll No:
[root@server Desktop]# usermod -g support sy

[root@server Desktop]# usermod -g sales ty

[root@server Desktop]# usermod -g sales msc

Step 3:

Create the directories /data/support and /data/sales and change the owner and group
owner of these directories.

[root@server Desktop]# mkdir –p /data/sales

[root@server Desktop]# mkdir -p /data/support

[root@server Desktop]# chgrp sales /data/sales

[root@server Desktop]# chgrp support /data/support

[root@server Desktop]# ls -l /data

total 8

drwxr-xr-x. 2 root sales 4096 Oct 8 00:36 sales

drwxr-xr-x. 2 root support 4096 Oct 8 00:36 support

[root@server Desktop]# chown fy /data/support

[root@server Desktop]# chown ty /data/sales

[root@server Desktop]# ls –l /data

total 8

drwxr-xr-x. 2 ty sales 4096 Oct 8 00:36 sales

drwxr-xr-x. 2 fy support 4096 Oct 8 00:36 support

Name:
Class:T.Y.I.T Roll No:
Step 4:

Changing advanced directory permissions setuid,setgid and sticky bit.

[root@server Desktop]# chmod u+s /data/*

[root@server Desktop]# ls -l /data

total 8

drwsr-xr-x. 2 ty sales 4096 Oct 8 00:36 sales

drwsr-xr-x. 2 fy support 4096 Oct 8 00:36 support

[root@server Desktop]# chmod g+s /data/*

[root@server Desktop]# ls –l /data

total 8

drwsr-sr-x. 2 ty sales 4096 Oct 8 00:36 sales

drwsr-sr-x. 2 fy support 4096 Oct 8 00:36 support

[root@server Desktop]# chmod +t /data/*

[root@server Desktop]# ls -l /data

total 8

drwsr-sr-t. 2 ty sales 4096 Oct 8 00:36 sales

drwsr-sr-t. 2 fy support 4096 Oct 8 00:36 support

Name:
Class:T.Y.I.T Roll No:
Practical number :- 6
Date :- / /

Aim:-Setting server with iptables.


[root@server Desktop]# iptables -L -v
Chain INPUT (policy ACCEPT 4498 packets, 346K bytes)

pkts bytes target prot opt in out source destination

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)

pkts bytes target prot opt in out source destination

Chain OUTPUT (policy ACCEPT 5 packets, 316 bytes)

pkts bytes target prot opt in out source destination

[root@server Desktop]# iptables -P INPUT ACCEPT

[root@server Desktop]# iptables -P OUTPUT ACCEPT

[root@server Desktop]# iptables -P FORWARD ACCEPT

[root@server Desktop]# iptables -F

[root@server Desktop]# iptables -P INPUT DROP

[root@server Desktop]# iptables -P OUTPUT DROP

[root@server Desktop]# iptables -P FORWARD DROP

[root@server Desktop]# iptables -L -v

Chain INPUT (policy DROP 406 packets, 31642 bytes)

pkts bytes target prot opt in out source destination

Chain FORWARD (policy DROP 0 packets, 0 bytes)

pkts bytes target prot opt in out source destination

Name:
Class:T.Y.I.T Roll No:
Chain OUTPUT (policy DROP 0 packets, 0 bytes)

pkts bytes target prot opt in out source destination

[root@server Desktop]# iptables -A INPUT -i lo -j ACCEPT

[root@server Desktop]# iptables -A OUTPUT -o lo -j ACCEPT

[root@server Desktop]# iptables -A INPUT –p tcp --dport 22 -j ACCEPT

[root@server Desktop]# iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

[root@server Desktop]# iptables -A INPUT -p tcp --dport 80 -j ACCEPT

[root@server Desktop]# iptables -A INPUT -m multiport -p tcp --port 21,20 -j ACCEPT

[root@server Desktop]# iptables -L -v

Chain INPUT (policy DROP 117 packets, 9335 bytes)

pkts bytes target prot opt in out source destination

0 0 ACCEPT all -- lo any anywhere anywhere

0 0 ACCEPT tcp -- any any anywhere anywheretcpdpt:ssh

0 0 ACCEPT tcp -- any any anywhere anywheretcpdpt:http

0 0 ACCEPT tcp -- any any anywhere anywhere multiport ports ftp,ftp-data

Chain FORWARD (policy DROP 0 packets, 0 bytes)

pkts bytes target prot opt in out source destination

Chain OUTPUT (policy DROP 0 packets, 0 bytes)

pkts bytes target prot opt in out source destination

0 0 ACCEPT all -- any lo anywhere anywhere

0 0 ACCEPT all -- any any anywhere anywhere state RELATED,ESTABLISHED

Name:
Class:T.Y.I.T Roll No:
Practical number :- 7

Date :- / /

Aim:- Setting up Cryptographic services.

Code:-

[root@server Desktop]# genkey --days 365 server

Name:
Class:T.Y.I.T Roll No:
Name:
Class:T.Y.I.T Roll No:
Name:
Class:T.Y.I.T Roll No:
Name:
Class:T.Y.I.T Roll No:
/usr/bin/keyutil -c makecert -g 1024 -s "CN=server, O=My Company Ltd, L=Newbury, ST=Berkshire,
C=GB" -v 12 -a -z /etc/pki/tls/.rand.2727 -e password12 -o /etc/pki/tls/certs/server.crt -k
/etc/pki/tls/private/server.key

cmdstr: makecert

cmd_CreateNewCert

command: makecert

keysize = 1024 bits

subject = CN=server, O=My Company Ltd, L=Newbury, ST=Berkshire, C=GB

valid for 12 months

random seed from /etc/pki/tls/.rand.2727

key encryption password = ****

output will be written to /etc/pki/tls/certs/server.crt

output key written to /etc/pki/tls/private/server.key

Generating key. This may take a few moments...

Made a key

Opened tmprequest for writing

(null) Copying the cert pointer

Created a certificate

Wrote 1014 bytes of encoded data to /etc/pki/tls/private/server.key

Wrote the key to:

/etc/pki/tls/private/server.key

[root@server Desktop]#

Name:
Class:T.Y.I.T Roll No:
Practical number :- 8
Date :- / /

Aim:- Configuring NFS server and client.


Code:

[root@server Desktop]# ifconfig

eth0 Link encap:EthernetHWaddr 00:0C:29:9B:13:37

inet addr: 172.16.0.146 Bcast:172.16.3.255 Mask:255.255.252.0

inet6addr: fe80::20c:29ff:fe9b:1337/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:16 errors:0 dropped:0 overruns:0 frame:0

TX packets:149 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000

RX bytes:2544 (2.4 KiB) TX bytes:13004 (12.6 KiB)

Interrupt:19 Base address:0x2024

lo Link encap:Local Loopback

inet addr:127.0.0.1 Mask:255.0.0.0

inet6addr: ::1/128 Scope:Host

UP LOOPBACK RUNNING MTU:16436 Metric:1

RX packets:82 errors:0 dropped:0 overruns:0 frame:0

TX packets:82 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0

RX bytes:6804 (6.6 KiB) TX bytes:6804 (6.6 KiB)

Name:
Class:T.Y.I.T Roll No:
[root@server Desktop]# rpm -qa|grep nfs

sblim-cmpi-nfsv4-1.1.0-1.el6.i686

nfs4-acl-tools-0.3.3-5.el6.i686

nfs-utils-1.2.2-7.el6.i686

sblim-cmpi-nfsv3-1.1.0-1.el6.i686

nfs-utils-lib-1.1.5-1.el6.i686

[root@server Desktop]# chkconfig nfs on

[root@server Desktop]# cd /root

[root@server ~]# mkdir TYIT

[root@server ~]# cd TYIT

[root@server TYIT]# touch abc pqr

[root@server TYIT]# cat> tynfsex.txt

Welcome to nfs practical

This practical is done by TYIT Students learning linux.

[ctrl+d]

[root@server TYIT]# vi /etc/exports

(Press i)

/root/TYIT * (rw,sync)

ESC :wq

[root@server TYIT]# service nfs start

Starting NFS services: [ OK ]

Starting NFS quotas: [ OK ]

Starting NFS daemon: [ OK ]

Name:
Class:T.Y.I.T Roll No:
Starting NFS mountd: [ OK ]

[root@server TYIT]# service nfs restart

Shutting down NFS mountd: [ OK ]

Shutting down NFS daemon: [ OK ]

Shutting down NFS quotas: [ OK ]

Shutting down NFS services: [ OK ]

Starting NFS services: [ OK ]

Starting NFS quotas: [ OK ]

Starting NFS daemon: [ OK ]

Starting NFS mountd: [ OK ]

[root@server TYIT]# showmount -e 172.16.0.146

Export list for 172.16.0.146:

/root/TYIT *

[root@server TYIT]# service iptables stop

[root@server TYIT]# service iptables status

iptables: Firewall is not running.

[root@server TYIT]# chmod -R 777 /root/TYIT

[root@server TYIT]# service vsftpd stop

Shutting down vsftpd: [ OK ]

[root@server TYIT]# service vsftpd status

vsftpd is stopped

Name:
Class:T.Y.I.T Roll No:
[root@server TYIT]#

client

[root@server Desktop]# cd /home

[root@server home]# mkdir nfsTYclient

[root@server home]# service iptables stop

[root@server home]# service vsftpd stop

Shutting down vsftpd: [OK]

[root@server home]# service vsftpd status

vsftpd is stopped

[root@server home]# mount -t nfs 172.16.0.146:/root/TY /home/nfsTYclient

[root@server home]# cd /home/nfsTYclient

[root@server nfsTYclient]# ls

abc pqr tynfsex.txt

Name:
Class:T.Y.I.T Roll No:
Practical number :- 9 Date :- / /

Aim:- Configuring Samba Server.

Code:-

[root@localhost Desktop]# yum install samba

Loaded plugins: aliases, changelog, downloadonly, kabi, presto, protect-packages, refresh-packagekit,


rhnplugin, security, tmprepo, verify, versionlock

This system is not registered with RHN.

RHN support will be disabled.

Loading support for Red Hat kernel ABI

Setting up Install Process

Nothing to do

[root@localhost Desktop]# rpm -qa|grep samba

samba-winbind-3.5.4-68.el6.i686

samba-winbind-clients-3.5.4-68.el6.i686

samba-3.5.4-68.el6.i686

sblim-cmpi-samba-1.0-1.el6.i686

samba-client-3.5.4-68.el6.i686

samba-common-3.5.4-68.el6.i686

[root@localhost Desktop]# cd /home

Name:
Class:T.Y.I.T Roll No:
[root@localhost home]# mkdir TYsmb

[root@localhost home]# cd TYsmb

[root@localhost TYsmb]# touch f1 f2 f3

[root@localhost TYsmb]# ls

f1 f2 f3

[root@localhost TYsmb]# cat> TYsamba.txt

Welcome to Samba Practical

This Pract is done by TY Learners..

[root@localhost TYsmb]# ls

f1 f2 f3 TYsamba.txt

[root@localhost b2smb]# vi /etc/samba/smb.conf

workgroup = WORKGROUP

server string = Samba Server Version %v

; netbios name = MYSERVER

(Uncomment these two lines)

interfaces = lo eth0 172.16.0.

hosts allow =127. 172.16.0.

(ADD THE FOLLOWING SHARE AT END OF FILE):

[TYsmb]

comment =TY samba sharing Stuff

path = /home/TYsmb

public = yes

writable = yes

Name:
Class:T.Y.I.T Roll No:
Browseable=yes

write list =Administrator

[root@localhost b2smb]# service smb start

Starting SMB services:

[root@localhost b2smb]# service smb restart

Shutting down SMB services: [ OK ]

Starting SMB services: [ OK ]

[root@localhost b2smb]# chkconfig smb on

[root@localhost b2smb]# testparm

Load smbconfig files from /etc/samba/smb.conf

rlimit_max: rlimit_max (1024) below minimum Windows limit (16384)

params.c:Parameter() - Ignoring badly formed line in configuration file: specifiy it as a per share option
as well

Processing section "[homes]"

Processing section "[printers]"

Processing section "[b2smb]"

Loaded services file OK.

Server role: ROLE_STANDALONE

Press enter to see a dump of your service definitions

(Here Press Enter Key on Keyboard)

[global]

Name:
Class:T.Y.I.T Roll No:
server string = Samba Server Version %v

log file = /var/log/samba/log.%m

max log size = 50

cups options = raw

[homes]

comment = Home Directories

read only = No

browseable = No

[printers]

comment = All Printers

path = /var/spool/samba

printable = Yes

browseable = No

[TYsmb]

comment =TY sharing Stuff

path = /home/TYsmb

public = yes

writable = yes

Browseable=yes

write list =Administrator

Name:
Class:T.Y.I.T Roll No:
[root@localhost TYsmb]# service iptables stop

iptables: Flushing firewall rules: [ OK ]

iptables: Setting chains to policy ACCEPT: mangle natfilte[ OK ]

iptables: Unloading modules: [ OK ]

[root@localhost TYsmb]# service iptables status

iptables: Firewall is not running.

[root@localhost TYsmb]# getsebool -a

samba_enable_home_dirs --> off

[root@localhost TYsmb]# setsebool samba_enable_home_dirs=1

[root@localhost TYsmb]# getsebool -a

samba_enable_home_dirs --> on

[root@localhost TYsmb]# service smb restart

Shutting down SMB servicse : [OK]

Starting SMB services : [OK]

[root@localhost TYsmb]# useradd TYsmbuser

[root@localhost TYsmb]# smbpasswd -a TYsmbuser

Name:
Class:T.Y.I.T Roll No:
New SMB password:

Retype new SMB password:

Added user TYsmbuser.

[root@localhost TYsmb]#ifconfig

eth0 Link encap:Ethernet HWaddr 00:0C:29:45:9D:D9

inet addr:172.16.0.146 Bcast:172.16.3.255 Mask:255.255.252.0

inet6 addr: fe80::20c:29ff:fe45:9dd9/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:47675 errors:0 dropped:0 overruns:0 frame:0

TX packets:91 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:4635463 (4.4 MiB) TX bytes:9751 (9.5 KiB)

Interrupt:19 Base address:0x2024

[root@localhost TYsmb]# smbclient //172.16.0.146/home/TYsmb –U TYsmbuser

Enter TYsmbuser’s password:

Domain-[WORKGROUP] OS-[UNIX] Server-[Samba-3.5.4-68.016]

Tree_connect_failed : NT_STATUS_BAD_NETWORK_NAME

[root@localhost TYsmb]#service smb restart

Shutting down SMB servicse : [OK]

Starting SMB services : [OK]

[root@localhost TYsmb]#chmod –R 777 /home/TYsmb

Name:
Class:T.Y.I.T Roll No:
Practical number :- 10 Date :- / /

Aim:-Configuring FTP Server.


Code:-

[root@localhost NFS]# yum install vsftpd

Loaded plugins: aliases, changelog, downloadonly, kabi, presto, protect-packages, refresh-packagekit,


rhnplugin, security, tmprepo, verify, versionlock

This system is not registered with RHN.

RHN support will be disabled.

Loading support for Red Hat kernel ABI

Setting up Install Process

Nothing to do

[root@localhost NFS]# rpm -qa|grep vsftpd

vsftpd-2.2.2-6.el6.i686

[root@localhost NFS]# vi /etc/vsftpd/vsftpd.conf

[Uncomment the line]

anon_upload_enable=YES

[root@localhost NFS]# service vsftpd start

Starting vsftpd for vsftpd: [ OK ]

[root@localhost NFS]# service vsftpd restart

Name:
Class:T.Y.I.T Roll No:
Shutting down vsftpd: [ OK ]

Starting vsftpd for vsftpd: [ OK ]

[root@localhost NFS]# getsebool -a|grep ftp

allow_ftpd_anon_write --> off

[root@localhost NFS]# setsebool allow_ftpd_anon_write=1

[root@localhost NFS]# getsebool -a|grep ftp

allow_ftpd_anon_write --> on

[root@localhost NFS]# ls -ldZ /var/ftp/pub/

drwxr-xr-x. root root system_u:object_r:public_content_t:s0 /var/ftp/pub/

[root@localhost NFS]# chown ftp /var/ftp/pub/

[root@localhost NFS]# chgrp ftp /var/ftp/pub/

[root@localhost NFS]# ls -ldZ /var/ftp/pub/

drwxr-xr-x. ftp ftp system_u:object_r:public_content_t:s0 /var/ftp/pub/

[root@localhost NFS]# cd /var/ftp/pub

[root@localhost pub]# touch f1 f2 f3

[root@localhost pub]# cat> akftp.txt

Hello We have learned to configure even FTP Now!

copyright@Ak

[ctrl +d]

[root@localhost pub]# service vsftpd restart

Shutting down vsftpd: [ OK ]

Starting vsftpd for vsftpd: [ OK ]

Name:
Class:T.Y.I.T Roll No:
[root@server Desktop]# ifconfig

eth0 Link encap:EthernetHWaddr 00:0C:29:9B:13:37

inet addr:172.16.0.146 Bcast:172.16.3.255 Mask:255.255.252.0

inet6addr: fe80::20c:29ff:fe9b:1337/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:379 errors:0 dropped:0 overruns:0 frame:0

TX packets:109 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:48422 (47.2 KiB) TX bytes:17907 (17.4 KiB)

Interrupt:19 Base address:0x2024

lo Link encap:Local Loopback

inet addr:127.0.0.1 Mask:255.0.0.0

inet6addr: ::1/128 Scope:Host

UP LOOPBACK RUNNING MTU:16436 Metric:1

RX packets:568 errors:0 dropped:0 overruns:0 frame:0

TX packets:568 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:42160 (41.1 KiB) TX bytes:42160 (41.1 KiB)

For Client open the browser in linux and in addressbar type the url:

ftp://IP Address Of Server

e.g ftp://172.16.0.146

Name:
Class:T.Y.I.T Roll No:
Practical number :- 11 Date :- / /

Aim:-Configuring Domain Name System (DNS).


Code:-

[root@localhost Desktop]# ifconfig

[root@localhost Desktop]# vi /etc/sysconfig/network-scripts/ifcfg-eth0

[press i]

DEVICE=eth0

NM_CONTROLLED=yes

ONBOOT=no

BOOTPROTO=none

NETMASK=255.255.252.0

TYPE=Ethernet

HWADDR=00:1F:D0:36:5B:6A

IPADDR=172.16.0.146

GATEWAY=172.16.0.1

DNS1=172.16.0.146

IPV6INIT=no

USERCTL=no

[:wq]

Name:
Class:T.Y.I.T Roll No:
[root@localhost Desktop]# vi /etc/hosts

172.16.0.146 server.ckt.com server [add at end of file]

127.0.0.1 localhost.localdomainlocalhost

::1 localhost6.localdomain6 localhost6

[root@localhost Desktop]# vi /etc/sysconfig/network

NETWORKING=yes

HOSTNAME=server

[root@localhost Desktop]# vi /etc/resolv.conf

# Generated by NetworkManager

search ckt.com

nameserver 172.16.0.146

[root@localhost Desktop]# service network restart

Shutting down interface eth0: Device state: 3 (disconnected) [ OK ]

Shutting down loopback interface: [ OK ]

Bringing up loopback interface: [ OK ]

Bringing up interface eth0: Active connection state: activated

Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/3[OK ]

[root@server Desktop]# yum install bind*

Loaded plugins: aliases, changelog, downloadonly, kabi, presto, protect-packages, refresh-packagekit,


rhnplugin, security, tmprepo, verify, versionlock

This system is not registered with RHN.

RHN support will be disabled.

Name:
Class:T.Y.I.T Roll No:
Loading support for Red Hat kernel ABI

Setting up Install Process

Nothing to do

[root@server Desktop]# vi /etc/named.conf

options {

listen-on port 53 { 172.16.0.146; };

# listen-on-v6 port 53 { ::1; };

directory "/var/named";

dump-file "/var/named/data/cache_dump.db";

statistics-file "/var/named/data/named_stats.txt";

memstatistics-file "/var/named/data/named_mem_stats.txt";

allow-query { any; };

recursion yes;

dnssec-enable yes;

dnssec-validation yes;

dnssec-lookaside auto;

/* Path to ISC DLV key */

bindkeys-file "/etc/named.iscdlv.key";

};

[root@server Desktop]# vi /etc/named.rfc1912.zones

(EDIT THE FIRST and FOURTH ZONES IN THIS FILE)

Zone"ckt.com" IN {

type master;

Name:
Class:T.Y.I.T Roll No:
file"forward.zone";

allow-update { none; };

};

zone "0.16.172.in-addr.arpa" IN {

type master;

file "reverse.zone";

allow-update { none; };

};

[root@server Desktop]# cd /var/named/

[root@server named]# cp named.localhost forward.zone

[root@server named]# cp named.loopback reverse.zone

[root@server named]# vi forward.zone

$TTL 1D

@ IN SOA server.ckt.com. root.server.ckt.com. (

0 ; serial

1D ; refresh

1H ; retry

1W ; expire

3H ) ; minimum

IN NS server.ckt.com.

server IN A 172.16.0.146

Name:
Class:T.Y.I.T Roll No:
[root@server named]# vi reverse.zone

$TTL 1D

@ IN SOA server.ckt.com. root.server.ckt.com. (

0 ; serial

1D ; refresh

1H ; retry

1W ; expire

3H ) ; minimum

IN NS server.ckt.com.

146 IN PTR server.ckt.com.

[root@server named]# chgrp named forward.zone

[root@server named]# chgrp named reverse.zone

[root@server named]# service named restart

Stopping named: umount: /var/named/chroot/var/named: device is busy.

(In some cases useful info about processes that use

the device is found by lsof(8) or fuser(1)) [ OK ]

Starting named: [ OK ]

[root@server named]# dig server.ckt.com

; <<>>DiG 9.7.0-P2-RedHat-9.7.0-5.P2.el6 <<>> server.ckt.com

;; global options: +cmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1978

;; flags: qraardra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0

Name:
Class:T.Y.I.T Roll No:
;; QUESTION SECTION:

;server.ckt.com. IN A

;; ANSWER SECTION:

server.ckt.com. 86400 IN A 172.16.0.146

;; AUTHORITY SECTION:

ckt.com. 86400 IN NS server.ckt.com.

;; Query time: 1 msec

;; SERVER: 172.16.0.146#53(172.16.0.146)

;; WHEN: Fri Aug 8 09:43:17 2014

;; MSG SIZE rcvd: 62

[root@server named]# dig -x 172.16.0.146

; <<>>DiG 9.7.0-P2-RedHat-9.7.0-5.P2.el6 <<>> -x 172.16.0.146

;; global options: +cmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 20268

;; flags: qraardra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:

;146.0.16.172.in-addr.arpa. IN PTR

;; AUTHORITY SECTION:

Name:
Class:T.Y.I.T Roll No:
0.16.172.in-addr.arpa. 10800 IN SOA erver.ckt.com. root.server.ckt.com. 0 86400 3600
604800 10800

;; Query time: 0 msec

;; SERVER: 172.16.0.146#53(172.16.0.146)

;; WHEN: Fri Aug 8 09:43:35 2014

;; MSG SIZE rcvd: 104

[root@server named]# nslookup

> 172.16.0.146

Server: 172.16.0.146

Address: 172.16 0.146#53

146.0.16.172.in-addr.arpa name = server.ckt.com.

>exit

[root@server named]# nslookup

> server.ckt.com

Server: 172.16.0.146

Address: 172.16 0.146#53

Name: server.ckt.com

Address: 172.16.0.146

>exit

Name:
Class:T.Y.I.T Roll No:
Practical number :- 12 Date :- / /

Aim:-Configuring DHCP Server.


Code:-

[root@serverDesktop]# rpm -qa|grep dhcp

dhcp-4.1.1-12.P1.el6.i686

[root@server ~]# hostname

server

[root@serverDesktop]# vi /etc/sysconfig/network

NETWORKING=yes

HOSTNAME=server.ckt.com

[root@serverDesktop]# hostname

server.ckt.com

[root@server Desktop]# setup

(In this wizard do the setting to “USE DHCP” by placing * for its value.(Hit spacebar to place *)

[root@server Desktop]# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf

cp: overwrite `/etc/dhcp/dhcpd.conf'? y

[root@server Desktop]# vi /etc/dhcp/dhcpd.conf

[press i]

# option definitions common to all supported networks...

option domain-name "ckt.com";

Name:
Class:T.Y.I.T Roll No:
option domain-name-servers server.ckt.com;

# This is a very basic subnet declaration.

subnet 172.16.0.0 netmask 255.255.255.0 {

range 172.16.0.2 172.16.0.200;

option routers 172.16.0.1;

[:wq]

[root@server Desktop]# dhcpd -cf /etc/dhcp/dhcpd.conf eth0

Internet Systems Consortium DHCP Server 4.1.1-P1

Copyright 2004-2010 Internet Systems Consortium.

All rights reserved.

This version of ISC DHCP is based on the release available

on ftp.isc.org. Features have been added and other changes

have been made to the base software release in order to make

it work better with this distribution.

Please report for this software via the Red Hat Bugzilla site:

http://bugzilla.redhat.com

exiting.

[root@server Desktop]# service dhcpd stop

[root@server Desktop]# service dhcpd start

Starting dhcpd: [ OK ]

Name:
Class:T.Y.I.T Roll No:
DHCP CLIENT :-

[root@server Desktop]# ifconfig

eth0 Link encap:EthernetHWaddr 00:0C:29:9B:13:37

inet addr:172.16.0.173 Bcast:172.16.3.255 Mask:255.255.252.0

inet6addr: fe80::20c:29ff:fe9b:1337/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:16 errors:0 dropped:0 overruns:0 frame:0

TX packets:149 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:2544 (2.4 KiB) TX bytes:13004 (12.6 KiB)

Interrupt:19 Base address:0x2024

lo Link encap:Local Loopback

inet addr:127.0.0.1 Mask:255.0.0.0

inet6addr: ::1/128 Scope:Host

UP LOOPBACK RUNNING MTU:16436 Metric:1

RX packets:82 errors:0 dropped:0 overruns:0 frame:0

TX packets:82 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:6804 (6.6 KiB) TX bytes:6804 (6.6 KiB)

Name:
Class:T.Y.I.T Roll No:
[root@server Desktop]# vi /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0

BOOTPROTO=dhcp

NM_CONTROLLED=yes

ONBOOT=yes

TYPE=Ethernet

PREFIX=22

DNS1=172.16.0.1

DEFROUTE=yes

IPV4_FAILURE_FATAL=yes

IPV6INIT=no

NAME="System eth0"

UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03

USERCTL=no

HWADDR=00:0c:29:9b:13:37

MTU=1500

PEERDNS=yes

[root@server Desktop]# vi /etc/sysconfig/dhcp

(You have to type following line in file)

DHCPDRAGS=eth0

[root@server Desktop]# service network restart

Shutting down interface eth0: Device state: 3 (disconnected) [ OK ]

Name:
Class:T.Y.I.T Roll No:
Shutting down loopback interface: [ OK ]

Bringing up loopback interface: [ OK ]

Bringing up interface eth0: Active connection state: activated

Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/1 [OK ]

[root@server Desktop]# ifconfig

eth0 Link encap:EthernetHWaddr 00:0C:29:9B:13:37

inet addr:172.16.0.18 Bcast:192.168.3.255 Mask:255.255.252.0

inet6addr: fe80::20c:29ff:fe9b:1337/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:16 errors:0 dropped:0 overruns:0 frame:0

TX packets:149 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:2544 (2.4 KiB) TX bytes:13004 (12.6 KiB)

Interrupt:19 Base address:0x2024

lo Link encap:Local Loopback

inet addr:127.0.0.1 Mask:255.0.0.0

inet6addr: ::1/128 Scope:Host

UP LOOPBACK RUNNING MTU:16436 Metric:1

RX packets:82 errors:0 dropped:0 overruns:0 frame:0

TX packets:82 errors:0 dropped:0 overruns:0 carrier:0


collisions:0 txqueuelen:0
RX bytes:6804 (6.6 KiB) TX bytes:6804 (6.6 KiB)

Name:
Class:T.Y.I.T Roll No:
Practical number :-13 Date :- / /

Aim:-Writing a script to monitor activity on the Apache web server.

Step 1:

Create a new script

[root@server Desktop]# cd /var/www/html

[root@server html]# vi test.sh

[Press i]

#!/bin/bash

COUNTER=0

while ps aux|grep httpd|grep -v grep >/dev/null

do

COUNTER=$((COUNTER+1))

sleep 1

echo counter is $COUNTER

done

logger HTTPMONITOR: httpd stopped at 'date'

service httpd start

[ press esc]:wq

Step 2:

Assign execute permission

[root@server html]# chmod -R 777 test.sh

Step 3:

Name:
Class:T.Y.I.T Roll No:
Execute the script

[root@server html]# sh test.sh

counter is 1

counter is 2

counter is 3

counter is 4

counter is 5

counter is 6

counter is 7

counter is 8

counter is 9

counter is 10

counter is 11

counter is 12

counter is 13

counter is 14

counter is 15

Step 4:

Open another terminal and stop httpd.After stopping httpd service counter will stop(Loop will be exited)
and the script will start httpd service automatically.

Name:
Class:T.Y.I.T Roll No:
Name:
Class:T.Y.I.T Roll No:
Practical number :-14 Date :- / /

Aim:-Using the select command.

[root@server Desktop]# vi selectb3.sh

[Press i]

Name:
Class:T.Y.I.T Roll No:
Name:
Class:T.Y.I.T Roll No:
Name:
Class:T.Y.I.T Roll No:
Practical number:-15
Aim : Introduction to GRUB.CONF

[root@server Desktop]# vi /boot/grub/grub.conf

grub.conf generated by anaconda

# Note that you do not have to rerun grub after making changes to this file

# NOTICE: You have a /boot partition. This means that

# all kernel and initrd paths are relative to /boot/, eg.

# root (hd0,0)

# kernel /vmlinuz-version ro root=/dev/sda2

# initrd /initrd-[generic-]version.img

#boot=/dev/sda

default=1

timeout=5

splashimage=(hd0,0)/grub/splash.xpm.gz

hiddenmenu

title Red Hat Enterprise Linux Server (2.6.32-71.el6.i686.debug)

root (hd0,0)

kernel /vmlinuz-2.6.32-71.el6.i686.debug ro root=UUID=09bd4ea6-c86d-41f9-bbce-c50d81fca800


rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16
KEYBOARDTYPE=pc KEYTABLE=us crashkernel=auto rhgb quiet

initrd /initramfs-2.6.32-71.el6.i686.debug.img

Name:
Class:T.Y.I.T Roll No:
title Red Hat Enterprise Linux (2.6.32-71.el6.i686)

root (hd0,0)

kernel /vmlinuz-2.6.32-71.el6.i686 ro root=UUID=09bd4ea6-c86d-41f9-bbce-c50d81fca800


rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16
KEYBOARDTYPE=pc KEYTABLE=us crashkernel=auto rhgb quiet

initrd /initramfs-2.6.32-71.el6.i686.img

 Default=1

This command tells GRUB to boot the second listing beginning with title.If you had two entries
beginning with title,you could set this numbers to 0 and boot the first entry.

 Timeout=5

This command tells GRUB to boot the default entry after 5 seconds.To change the time ,increase or
decrease the number as desired.

 splashimage=(hd0,0)/grub/splash.xpm.gz

This command tells GRUB where to look for splash image it displays for the menu.You can create your
own image ifdesired.Just be sure to follow the same format shown here.

 Hiddenmenu

This command tells GRUB not to display the menu and to boot default after timeout expires.You can still
see the menu by pressing any key.

 Title

This command tells GRUB to boot list name on the menu using whatever is following the title
command.In this example the title is Red Hat Enterprise Linux Server (2.6.32-71.el6.i686.debug), which
is the name of O.S and kernel version number.

 Root(hd,0)

Name:
Class:T.Y.I.T Roll No:
This line tells GRUB to boot the system from the first portion of the first hard drive.

 Kernel…

This command tells GRUB the location of the kernel ,as well as passes kernel parameter to the kernel.

 Initrd…

This line tells GRUB the location of initial RAM disk image that is used to load special drivers for the
system.

Name:
Class:T.Y.I.T Roll No:

You might also like