Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Gokul NA Lab

Download as pdf or txt
Download as pdf or txt
You are on page 1of 88

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


Experiment: 1
Date

DEMONSTRATION OF THE
INSTALLATION OF
LINUX SERVER OPERATING SYSTEM
AND IT'S
CONFIGURATION
AIM:

Demonstration of the installation of


Linux server operating system and it’s
configuration
THEORY:

To Install a virtual box and install and


configure Linux server operating
system in windows operating system
PROCEDURE:
1.After installing virtual box, latest
Ubuntu Server ISO file downloaded,
and we have to create new virtual
machine. Click “New” button to create
new virtual machine.
2.In name field insert any meaningful
name, I named it as gokul and click
next button.

3.In hardware step you can increase


RAM and CPU properties based on
your local machine capabilities. If not
sure, you can leave as it and change
these settings after installation. I
increased base memory to 4 GB and
number of processors to 1.

4.In Hard Disk step I recommend


Only changing disk size, I allocated
25 GB for virtual machine.
5.Next windows shows the summary
now you can press the “finish”
button which will start the Ubuntu
Server installation.
6.Next click on the “start” button to
start configuration.
INSTALL UBUNTU SERVER
ON VIRTUALBOX

1.first step will be to select your


language.
2.Next you have to select your
keyboard layout.
3.At the next window select the
network adapter and accept the IP
address if your system is in a network
with a DHCP server.
4.Leave the empty proxy address if you
are not going to use proxy connection.
5.use default mirror image, no need to
change it.
6.Next click Custom storage layout
option and click done.
7.Next step click on VBOX and select
add GPT partition for root, boot and
home.
8.press “done” button on storage
confirmation step and it will display a
warning message . Select “continue”
and hit enter key.
9.In profile setup insert username and
password and select “done” and hit
enter key.
10.In the page SSH setup skip that
page, you won’t be able to login
through SSH connection.
11.Once you click “done” button
Ubuntu Server installation starts.
Installation is going to take some time.
When installation is complete you have
to reboot the virtual machine.
12. The next page is the login page
enter the appropriate username and
password at this page.
13.At least we get page which means
that the Linux server operating system
is completed.
Result:
Installation and configuration of Linuxserver has
been successfully completed.
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.
Experiment :3
Date :

FAMILIARIZATION FOR PERMISSION FOR


AUTHENTICATION AND AUTHORIZATION

Aim : To familiarize commands which


provide authentication and
authorization.
Theory
1.To list all the users in the system.
Commands:
#cat/etc/passwd
#getend passwd
#cat/etc/shadow(encrypted
password)
2. To list all the groups in the
system.
Commands:
#cat/etc/group
#getent group
3.To find the details of the login
users.
Commands :
#who
4. Create five groups.
Command :#sudo groupadd
groupname
5. Create six users.
Command:#sudo useradd username
6. To change password of the users
Command:#sudo passwd username
7. Assign each users to any two
groups.
Command:
#usermod -a -G group1,group2
username
8. Change primary group of any two
users.
Command:
#usermod -g group username
9. Create additional two groups.
Command:#sudo groupadd
groupname
10. Create additional two users.
Command:#sudo useradd username
11. Remove new users.
Command:#userdel username
12. Remove new groups.
Command:#groupdel groupname
13. Create five directories in users
home
directory.
Command:#mkdir directory name
14. Create 6 files in each directory.
Command:#touch {1..6}
15. Grant read/write/execute
permission to two users on all
directories and files.
Command:#chmod 777 directory
name
16. Grant read/write permission on
all files of any two directories to all
users.
Command:#chmod 660 directory
name
Result: Familiarized authentication
and authorization successfully.
Experiment No.4
Date:

HARDDISK PARTITION USING FDISK


Aim: To partition a hard disk using fdisk.
Procedure
1.For creating partition in a hard disk we use fdisk
command.
#sudo fdisk /dev/sdb
2. To create partition we use n command in fdisk.
#n
-Click enter to select primary or extended partition
-P for primary partition.
#p
-Give appropriate size for the partition
[eg.+500M,1G]
3.Repeat the steps to create the other two
partitions.
4.To create extended partition use n command.
-Click enter e command for extended partition.
#e
-Give appropriate size for the partition
[eg.+500M,1G]

5.For creating logical partition use n command.


#n
6.To create the file system use the command.
#sudo mkfs.ext4 /dev/sdb1

7.Creating mounting point.


#sudo mkdir /mnt/documents
8.Mount the partition against the appropriate
mounting point.
#sudo mount /dev/sdb1 /mnt/document

9.For seeing the mount use the command.


#lsblk
10.For mounting partition automatically while
booting time use fstab.
#sudo nano /etc/fstab -Inside fstab;
/dev/sdb1 /mnt/document ext4 defaults 0 0
10.#lsblk for seeing the mounting.

Result: hard disk partition using fdisk is executed


and output is verified.
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 gdisk gptc partition table is created.


6) Add three partitions ,one is swap
• 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 below steps
Create a mount point for each partition using mkdir command (ex: mkdir
/mtn/downloads)
mount the directories against each partition using mount command (ex: 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
(ex: /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 herddisk using fdisk utility.

Result: Hard disk partioning Using fdisk has been successfully completed.
Experiment no.06

HARDDISK PARTITION USING PARTED

Aim: Hardisk partition using parted.

Procedure:

1) To create partitions in a particular hard disk, start parted command and select hard
disk
#sudo parted /dev/sdd.
• Mk label ms dos
• Mk part.
• Primary partition.
• lsblk to 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 (ex: mkdir
/mtn/program)
5) Mount the directories against each partition using mount command (ex: mount
/dev/sdd1 /mnt/program)

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
(ex: /dev/sdd1/mnt/programext4 defaults 0 0 )
Reboot the server and check whether the partitions are mounted or not. This
completes the partitioning of harddisk using parted utility
Result: Harddisk partition using parted is successfully completed.
Experiment no.07

CREATE SWAP PARTITIONING USING GDISK.


Aim: To create swap partitioning using gdisk.

Procedure:

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


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

• To create Partition.
• Give appropriate size for the Partition
• To Provide the type of file system we use ‘8200’ for swap

For seeing the mount.


5) Activatingswap
Using mkswap command
#mkswap /dev/sdc3
Using swapon command to activate swap
#sudo swapon /dev/sdc3
#lsblk
7) For mounting Partition automatically.
#sudonano/etc/fstab
InsideFstab
/dev/sdc3 swap swap default 0 0
Result: create swap partitionUsing gdisk has been successfully completed.
Experiment no.08

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
a. select Adapter 1tab
b. Check Enable Network adapter option
c. Select NAT in Attached to option
d. Select Adapter 2 tab
e. Check Enable Network adapter option
f. Select Host-only Adapter Attached to option
g. 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.50.1
Result :Successfully configure network in Linux server.
Experiment no.09

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.


#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.
Result: Successfully Download and install puTTY for windows. Can use as SSH client.
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


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