0% found this document useful (0 votes)
27 views106 pages

Abhishek J NA Lab

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)
27 views106 pages

Abhishek J NA Lab

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/ 106

GOVERNMENT POLYTECHNIC

COLLEGE
ATTINGAL

…………………………………………

LABORATORY RECORD
Certified that this is the bonafide record of experiment done
by Miss/Mr...................................of...........................Year/Semester
(RollNo.........................of....................................................Branch)
in the.........................................during the year........................

Name of Subject......................................................

Reg No................................................................

Internal Examiner Lecturer in charge

External Examiner Head of Section


INDEX
SI.NO NAME OF PRACTICAL DATE PAGE INITIAL OF
NO. TEACHER

1 INSTALLATION AND CONFIGURATION OF LINUX


SERVER OPERATING SYSTEM

2 FAMILIARISATION OF FILE STRUCTURE IN LINUX


SERVER

3 AUTHENTICATION AND AUTHORISATION IN


LINUX SERVER

4 HARD DISK PARTIONING F DISK

5 HARD DISK PARTIONING G DISK

6 HARD DISK PARTIONING PART D

7 CREATE SWAP PARTIONING USING G DISK

8 NETWORK CONFIGURATION IN LINUX SERVER

9 INSTALLATION OF SSH IN LINUX SERVER

10 BACK UP AND RESTORE


Exp No. 1
Date : 01-01-2024

INSTALLATION AND CONFIGURATION OF LINUX SERVER


OPERATING SYSTEM AND ITS CONFIGURATION
Aim :
To demonstrate the installation of Linux server
operating system and its configuration

Theory :

To install a Virtual Box and install and configure


Linux Server operating system in Windows
Procedure :

◼ Install Virtual Box


◼ Open Virtual Box and
select New

Next steps are as follows:


1. Type Name, select ISO Image, give permssion to skip
unattended installation and press Next
2. Adjust Base memory and Processors then press
Next
3. Give the Virtual Hard Disk size and select Next
4. Click on finish
5.Click On Start
6.Select language (English) and Click Done
8. Select the network adapter and accept the IP
address if your system is in a network with a DHCP
Server and press Done
9. You will get this to input the proxy address.
Otherwise you will press Done
10. This shows the mirror address and we can also
change it with our own choice then press Done
11. Select Custom Storage Layout and click Done
12. This is the storage configuration screen We want
to reset it so click Reset button
• Partition for Root
• Press Create
• Partition for Swap (change format to swap)
• Press Create
• Partition for Home( change format to ext4 and
mount to /home)
• Press create
13. Verify it and Then press Done
14. Press Continue
15. This interface is to input our server's name,
username and password
Enter the name, username, password and click Done.
16. In this page we can choose to install the openSSH
server package to enable secure remote to our server
No need to do anything in this page so press Done
17. The installation is complete
Press Reboot Now
Finally our server is created. We can only enter into our
server with our username and password so don't forget
it....
Then we want to shutdown the server type init 0.
Result :

Successfully completed the installation of Linux Server


operating system and its configuration.
Experiment no :

Date :

FAMILIARISATION OF FILE STRUCTURE IN LINUX SERVER


(Directory structure)
Aim: To familiarize about the file structure in Linux server.

Theory:

About the important subdirectories


/bin : Contain ready-to -run programs(also known as executable)including most
basic Unix Commands asls and cp.
/dev : Contains device files.
/etc : This core system configuration directory contain the user, password, boot,
device, Networking and other setup files. Many items in /etc are specific to
machines hardware.
/home : Holds personal directories for regular user.
/lib : An abbreviation for library, this directory holds library files containing code
that Executables can use. There are two types of libraries static and shared. The
/lib directory Should only contain shared libraries, but other lib directories such as
/usr/lib contain both Varieties as well as other auxiliary files.
/sbin : This directory is similar to the /bin directory. The only difference is that,
this Contains the binaries that can only be run by root or a sudo user.
/usr : User binary and program data contain all the executable files, libraries,
source of most Of the system program.
/usr/bin : Contains basic user commands
/usr/sbin: Contains additional commands for administrator.
/usr/lib: Contains the system libraries.
/usr/share: Contains documentation or common to all libraries.
/usr/local: contains locally installed software and other files.
/tmp: This directory holds temporary files typically cleared on reboot.
/var: This directory is where programs store runtime information like system
logging, user Tracking, caches, and other files that system programs create and
manage.
Exp no : 3
Date :

F A M I L IA R IS A T IO N O F F O R
P E R M IS S IO N F O R A U T H E N T IC A T IO N
A N D A U T H O R IS A T IO N

Aim: To familiarize commands which provide for authentication and


authorization.
Theory
1. list all the users in the system
# c a t /e tc /p a s s w d
# g e te n t p a s s w d
# c a t /e tc /s h a d o w - e n c ry p te d
p a s s w o rd .
2. list all the groups in the system
# c a t /e tc /g ro u p
# g e te n t g ro u p

3. find details of login users


#w ho
4. create 5 groups
# s u d o g ro u p a d d g ro u p n a m e

5. create 6 users
# s u d o u s e ra d d u s e rn a m e
6. change password of all users
#sudo passwd u s e rn a m e

7. assign each users to any two groups

#sudo usermod -a -G groupname username


8. change primary group of any 2 users
# s u d o u s e rmo d -g g ro u p n a m e
u s e rn a m e

9. create additional 2 users


#sudo useradd username
10. create additional 2 groups
# s u d o g ro u p a d d g ro u p n a m e

11. remove new users

#sudo userdel username


12. remove new groups
#sudo groupdel groupname

13. create 5 directories in users home directory


#sudo mkdir name
14. create 6 files in each directory
# s u d o to u c h / c a t

15. grant read/write/execute permssion to 2 users on all directories and files


# c h mo d 7 7 7 [file n a m e ]
16. grant read/write persmision on all files of any two directory to all users
# c h mo d 6 6 0 [file n a m e ]

Result : Commands are executed and output is verified.


Experiment no:04
Date:
HARDDISK PARTIONING USING FDISK
Aim: Familiarize partitioning of Hard Disk using fdisk command in Linux Server.

Procedure:

1 ) Add additional Hard disks in Linux sever virtual machine.


2 ) To list available hard disk and partitions

Open Linux sever and enter a command and enter lsblk command
#lsblk
3 ) To create partitions in a particular hard disk, start Fdisk command and
select hard disk
# sudo fdisk /dev/sdb
4 ) To see available option in fdisk, type m.
5 ) Then enter #p command to print partition information. In the beginning the
partition list will be empty
6 ) To create a new partition type n. Default partition table is MBR.
7 ) Add three primary partitions and one extended partition
and create 3 logical partitions.
* First create primary partition and give +2G.
* Second create primary partition of +1G size.
* Third partition also a primary with +500m size.
* Then create extended partition and three
logical partitions
8 ) For Creating primary partition type p in partition type.
9 ) For creating extended partition type e in partition type.
10 ) Use default value partition number
11 ) Use default value for First sector
12 ) Choose appropriate value for Last sector (Example +2G for
2GB partition)
13 ) Repeat steps 8-12 to create additional partitions
14 ) Type w to save the partition information.
15 ) The next step to create file system. mkfs command is used for this purpose
Use Mkfs.ext4 /dev/sdb1 command to create file system in
sdb1 partition.Using the same command create file systems in
other partitions also
16 ) The next step is mouting the partition againt a mount point. Follow the
below steps
Create a mount point for each partition using mkdir command
(eg: mkdir /mnt/documents)
mount the directories against each partition using mount command
(eg: mount /dev/sdb1 /mnt/documents)
17 ) To automatically mount all the partitions during booting, modify fstab file and
add allthe mount points and corresponding partition. Follow the below steps
a ) #nano /etc/fstab.
b ) Add each partitions into the file using the format
Partition namemount point file system defaults 0 0
(ex: /dev/sdb1/mnt/documentsext4defaults 0 0 )
18 ) Reboot the server and check whether the partitions are mounted
or not.This completes the partitioning of harddisk using
fdisk utility.

Result: Hard disk partioning Using fdisk has been successfully completed.
Experiment No : 05

HARDDISK PARTITIONING USING GDISK

Aim: Familiarize partitioning of Hard Disk using gdisk command in Linux


Server.
Procedure:
1. To list available hard disk and partitions
Open Linux sever and enter a command and enter lsblk
command
#lsblk
2. To create partitions in a particular hard disk, start gdisk command
and select hard disk
# sudo gdisk /dev/sdc
3.To see available option in gdisk, type ?.

4. Then enter #p command to print partition information. In


the beginning the partition list will be empty
5. To create a new partition type n. In gdiskgptc partition table is
created.
6.Add three partitions ,one isswap
• First create partition of size +1G.hex code or GUID is default (8200).
• Second create partition of +1G size. Hex code or GUID is default (8200)
• Third swap with +2G size. hex code or GUID is (8300).
8.Use default value partition number
9.Use default value for First sector
10. Choose appropriate value for Last sector (Example +2G for 2GB
partition)
11.Repeat steps 8-12 to create additional partitions

12.Type w to save the partition information.


And enter y to proceed.
13.The next step to create file system. mkfs command is used for this
purpose

Use mkfs.ext4 /dev/sdc1 command to create file system in sdc1


partition.Using the same command create file systems in other
partitions also excluding swap.
14. The next step is mouting the partition againt a mount point.
Follow the steps below.
Create a mount point for each partition using mkdir command (eg: mkdir
/mnt/downloads)
mount the directories against each partition using mount command (eg:
mount /dev/sdc1 /mnt/downloads)
15.To automatically mount all the partitions during booting, modify
fstab file and add all the mount points and corresponding partition.
Follow the below steps
a. #nano /etc/fstab.
b. Add each partitions into the file using the format
Partition name Mount point file system defaults 0 0
Eg: /dev/sdc1 /mnt/downloads ext4 defaults 0 0
16. Reboot the server and check whether the partitions are
mounted or not. This completes the partitioning of hard disk using
gdisk utility

Result: Harddisk partition using gdisk is successfully completed.


Experiment No: 06

CREATE SWAP PARTITIONING USING GDISK

Aim : To create Swap partition using gdisk


Procedure :

1.To create partitions in a particular hard disk, start gdisk comm


and select hard disk
#sudo gdisk /dev/sdc
2. To create partition use #n command

• Then give appropriate size for the partition


• Provide the type of file system we use "8200" for
swap
3. Use mkswap command for format the partition
#sudo mkswap /dev/sdc4
4. Use swapon command for activate the swap partition
#sudo swapon /dev/sdc3
5. For mounting partition automatically
#sudo nano /etc/fstab

Inside fstab
/dev/sdc4 swap swap defaults 0 0
6.#lsblk for seeing the mount

Result: Created swap partition using gdisk.


Experiment No: 07

HARDDISK PARTITION USING PARTED

Aim :To partitioning harddisk using parted


Procedure:

1. To create partitions in a particular hard disk, start parted


command and select hard disk

#sudo parted /dev/sdd


• mklabel ms dos
• mkpart
• primary partition
• lsblk for check the status.
2. The next step to create file system. mkfs command is used
for this purpose
Use mkfs.ext4 /dev/sdd1 command to create file system in sdd1
partition.Using the same command create file systems in other
partitions also
#sudo mkfs. ext4 /dev/sdd1
3.The next step is mouting the partition againt a mount point.
Follow the below steps
4.Create a mount point for each partition using mkdir
command (eg: mkdir /mnt/program)

5.Mount the directories against each partition using mount


command (eg: mount /dev/sdd1 /mnt/program)
6.To automatically mount all the partitions during booting,
modify fstab file and add all the mount points and
corresponding partition. Follow the below steps
#nano /etc/fstab.
Add each partitions into the file using the format
Partition name mount point file system defaults 0 0
(eg: /dev/sdd1 /mnt/program ext4 defaults 0 0 )
Reboot the server and check whether the partitions are
mounted or not using #lsblk. This completes the
partitioning of harddisk using parted utility

Result : Harddisk partition using parted is successfully


completed.
Experiment no.08
Date :

NETWORK CONFIGURATION IN LINUX SERVER

Aim:To configure network in linux server to connect the guest to host


machine and internet.

Procedure:
1) Configure NAT and Host-only adapter in virtual machine.
Add additional host-only adapter from tools->network
manager option in Virtual Box management tool
Setup default gate for new host-only adapter
Host-only-adapter#2 ->configure
manually ->192.168.100.1/255.255.255.0 -> apply
2 ) From setting of virtual machine Select Network
* select Adapter 1tab
* Check Enable Network adapter option
* Select NAT in Attached to option
* Select Adapter 2 tab
* Check Enable Network adapter option
* Select Host-only Adapter Attached to option
* Select newly created host-only adapter in Name option
(VirtualBox Host-Only Ethernet Adapter 2).
3 ) Start Linux server and find yaml file(network configuration file)available in
/etc/netplan directory.
4 ) Open/Edit the yaml file using nano
#Cd /etc/netplan
#Sudo nanofilename.yaml(ex:00-installer-config.yaml)
Enter the following to that file and save and exit from nano
network:
ethernets:
enp0s3:
dhcp4:true
enp0s8:
dhcp: no
addresses: [192.168.100.10/24]
nameservers:
addresses: [8.8.8.8]
version:2
5 ) Apply configuration changes using command
#sudo netplan apply
6 ) Confirm ip address configuration using
ip a command.
7 ) Check network connection between host and
internet using ping command
8 ) Between server and internet using ping google.com
9 ) Between server and host machine using ping
host-ip-address.
10 ) Check connection between host and server
from host machine using ping server-address
6) To check the network configuration, ping the ip address which got from
commandprount.
#ping 192.168.100.10

Result : Network is configured and output is verified.


Experiment no. 09

Date :
INSTALLATION OF SSH IN LINUX SERVER
Aim: installation of SSH.
Procedure:
1 ) Configure network with NAT and Host-only-adapter
2 ) Check the presence of SSH.
#sudo systemctl status ssh
3 ) If SSH is not present install SSH.
#sudo apt update
#sudo apt install ssh
Then check status of ssh.
4 ) Check port used by SSH
#sudo ss -ltn
5 ) Check Ubuntu firewall status
#sudo ufw status
6 ) If Ubuntu firewall is inactive enable it.Using the
command below
#sudo ufw enable
7 ) Then enable rules for port 22/tcp
#ufw allow 22/tcp
8 ) Check Ubuntu firewall status again
#sudo ufw status
9 ) Make sure port 22/tcp is existing.
* Install OpenSSH client in windows
10 ) Go to apps & features -> optional features -> add a feature
* Choose OpenSSH Client and click install
* Windows will download and install openSSH Client
* Once insalled, it will appear in installed features lis
* Open command prompt (cmd) in windows
* Connect to Linux sever using ssh username@ipaddress
(of sever).
* Download and Enter ip address [192.168.100.10] in putty.
Then check the network configuration by list or make file
in one and check status in both.
In command prompt..
Result : ssh is installed and output is verified.
Experiment no.10

Date:

Backup and restore

Aim: File compressing mechanisam using tar Gzip and gunzip.

Procedure:File compression helps to reduce file size and share files efficiently. And compressed
files are also easier to copy to remote servers. Also compress older and rarely used files and save

Them for future use which helps you conserve disk space.
Tar

The tar command is used to create an archive, grouping multiple files in a single file.Its name

Comes from the past and means tape archive.

Syntax

Tar [flags] destinationFileName sourceFileNames

This command creates an archive named archive.tar with the content of file1 and file2:

Tar -cvf archive.tar file1 file2

C stands for create. The f option is used to write to file the archive. The v is providing details
Of the files that have been archived.
• To remove the original files after creating an archive, use the –remove-files flag.

Tar -cvf archive.tar * --remove-files

• list the files contained in an archive:

Tar -tf archive.tar

T flag stands for viewing the contents of the archive

• To find a particular file inside the archive

Tar -tvf archive.tar filename


• To extract files from an archive in the current folder, use:

Tar -xvf archive.tar

The x option stands for extract

• To extract them to a specific directory, use:

Tar -xf archive.tar -C directory

• Tar is often used to create a compressed archive, gzipping the archive. This is done
using the z option:

Tar -czf archive.tar.gz file1 file2

This is just like creating a tar archive, and then running gzip on it.
• To extract files from a compressed archive in the current folder, use:

Tar -xzvf archive.tar.gz

-z specifies that the archive is gzip.

• To unarchive a gzipped archive, use gunzip , or gzip -d , and then unarchive it, but tar -
xf will recognize it’s a gzipped archive

Tar -xf archive.tar.gz

• To Delete files from the archive, use the –delete option

Tar –delete -f archive.tar file_name


Gzip

Gzip (GNU zip) is a compressing tool, which is used to truncate the file size. By default
original file will be replaced by the compressed file ending with extension (.gz).

Compress a file using the gzip compression protocol using the gzip command.

Gzip filename

This will compress the file, and append a .gz extension to it. The original file is deleted.

To prevent deleting files, you can use the -c option and use output redirection to write
the output to the filename.gz file:

Gzip -c filename > filename.gz

Or

Use -k (keep) option:

Gzip -k filename

There are various levels of compression. The more the compression, the longer it will take to
compress (and decompress). Levels range from 1 (fastest, worst compression) to 9 (slowest,
better compression), and the default is 6.

Choose a specific level with the -<NUMBER> option:

Gzip -1 filename
• Compress multiple files by listing them:

Gzip filename1 filename2

• Compress all the files in a directory, recursively, using the -r option:

Gzip -r a_folder

• The -v option prints the compression percentage information. Example to used along
with the -k option:

Gzip -kv wget-log


• Gzip can also be used to decompress a file, using the -d option:

Gzip -d filename.gz

• The compression ratio or how much the original file has compressed, use -l option.

Gzip -l filename.gz

Gunzip

The gunzip command is basically equivalent to the gzip command, except the -d option is always
enabled by default.

• The command can be invoked in this way:

Gunzip filename.gz

This will gunzip and will remove the .gz extension, putting the result in the

Filename file.
• If that file exists, it will overwrite that.

Extract to a different filename using output redirection using the -c option:

Gunzip -c filename.gz > anotherfilename

• To keep both the compressed and decompressed file

Gunzip -k filename.gz

• To recursively decompresses all files in a given directory, use the -r option:

Gunzip -r directory
• List the Compressed File Contents, use the -l option

Gunzip -l filename.gz

Result:

Successfully executed File compressing mechanisam using tar Gzip and gunzip.

You might also like