0% found this document useful (0 votes)
56 views17 pages

Final Lab Experiments

Uploaded by

mohiddinmtech
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)
56 views17 pages

Final Lab Experiments

Uploaded by

mohiddinmtech
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/ 17

Lab Experiment - 1

To develop proficiency in fundamental command-line operations and


AIM
redirection techniques in a Linux environment.
Description Use the shell prompt, execute commands, I/O Redirection, grep, ssh
Pre-Lab
ls, cd, mkdir, pwd, rmdir, mv, touch, cp, cat, passwd, head, tail, grep
Create a directory structure for the project:
• Create a main directory named ProjectWorkspace.
• Inside ProjectWorkspace, create three subdirectories: docs, scripts,
and data.
Navigate the directory structure:
• Change to the docs directory and create an empty file named
project_notes.txt.
• Change back to the ProjectWorkspace directory.
File and directory operations:
• Inside the scripts directory, create two empty files named setup.sh and
cleanup.sh.
• Copy the file project_notes.txt from the docs directory to the data
directory.
File content operations:
• Inside the docs directory, create a file named instructions.txt and write
In Lab the first few lines of text, using any editor or the echo command.
• Display the first 5 lines of instructions.txt using the head command.
• Display the last 5 lines of instructions.txt using the tail command.
Password management:
• Change your user password using the passwd command (if
permissions allow).
Search and filtering:
• Create a file named log.txt inside the ProjectWorkspace directory.
Populate it with some text that includes the words "error", "warning",
and "info".
• Use the grep command to filter and display lines containing the word
"error".
Directory cleanup:
• Remove the cleanup.sh file from the scripts directory.
• Remove the data directory along with its contents.

1. What is a shell?
2. What is Bash Shell?
3. What is the difference when the shell is running hash (#) and ($)
Viva Questions
character?
4. How to display the contents of multiple files at a time
5. What is a Regular Expression?
Lab Experiment - 2

To manage text files, file permissions, and links within a Linux


AIM environment.

Description create and edit text files, manage file permissions and links

Pre-Lab
Cat, nano, vi, vim, gedit, chmod, chown, chgrp
Commands

1. Use nano or vim to create a text file named notes.txt in your home directory.
Add the text "This is a test file." Save the file and exit the editor. Display the
contents of the file using the cat command. Provide the commands and the
steps taken in the text editor
In Lab
2. Create a file named permissions.txt in your home directory. Set its
permissions to rwxr-xr--. Verify the permissions using the ls -l command.
Change the permissions to rw-rw-r-- and verify again. Provide the
commands and the output

1. How do you save and exit a file in nano?


2. Explain the numeric mode in the chmod command.
Viva Questions 3. How do you change the owner and group of a file?
4. What does the command chmod u+rwx,g+rx,o+rx filename do?
5. How can you change only the group ownership of a file?

1. Create a file named original.txt in your home directory with some sample
text. Create a hard link named hardlink.txt and a soft link named softlink.txt
to original.txt. Verify the links by displaying their details using the ls -l
command. Provide the commands and the output

2. Use the man command to find information about the tar command. Use the
Post Lab
info command to find information about gzip. Finally, locate the
documentation files for the coreutils package in /usr/share/doc and list the
files. Provide the commands and the output.
Lab Experiment - 3

To learn script automation and command processing techniques.


AIM

To develop skills required to conditionally execute code, use looping constructs


Description to process files and command-line input, and process the output of shell
commands within a script.

‘if’ statement, ‘test’ command, [ ] (test command shorthand), elif and


Pre-Lab
else clauses, for loop, while loop, until loop, Bourne shell, C shell, Korn
Commands
shell

1. Write a shell script to create a file in $USER /class/batch directory.


Follow the Instructions
▪ Input a page profile to yourself, copy it into other existing file
▪ Start printing file at certain line
In Lab ▪ Print all the difference between two file, copy the two files at
▪ $USER/CSC/2007 directory.
▪ Print lines matching certain word pattern.

1. What is shell?
2. shell program is stored in which file?
Viva Questions
3. What is a shell variable?
4. What is ‘./’ and where it is used?

1. Write a shell script that receives any number of file names as


arguments checks if every argument supplied is a file or directory and
Post Lab
reports accordingly. whenever the argument is a file it reports no of
lines present in it
Lab Experiment - 4

To understand and apply file archiving, compression, and decompression


AIM
techniques using tar and gzip in a Linux environment.

These experiments cover the creation, listing, extraction, compression, and


decompression of files and directories using the tar and gzip commands.
Description
Students will gain practical experience in managing archives and compressed
files efficiently.

Pre-Lab
Tar, gzip
Commands
1. Create a directory named testdir. Inside testdir, create files named
file1.txt, file2.txt, and file3.txt. Use the tar command to create an archive
named testdir.tar of the testdir directory. List the contents of the
testdir.tar archive without extracting it.

2. Ensure testdir.tar archive from Question 1 exists. Create a directory


named extracted. Extract the contents of testdir.tar into the extracted
directory.
In Lab
3. Create a text file named sample.txt with some sample text. Compress
sample.txt using the gzip command. Command: gzip sample.txt. Verify
that the file has been compressed by listing the directory contents. Note
the new file sample.txt.gz.

4. Ensure sample.txt.gz from Question 3 exists. Decompress sample.txt.gz


using the gunzip command. Verify that the original sample.txt file is
restored.

How do you create a tarball of a directory?


What does the -z option do when used with the tar command?
Viva Questions How do you specify the extraction directory using the tar command?
What does the -x option in the tar command stand for?
What is the file extension for files compressed with gzip?

1. Create a directory named project. Inside project, create files named


doc1.txt, doc2.txt, and doc3.txt. Use the tar command with gzip
Post Lab
compression to create a compressed tarball project.tar.gz. List the
contents of the compressed tarball without extracting it.
Lab Experiment - 5

To learn how to utilize system documentation effectively using man, info, and
AIM
files in /usr/share/doc.

These experiments involve using man and info commands to access system
Description documentation and exploring the documentation files available in the
/usr/share/doc directory.

Pre-Lab
Man, info
Commands

1. Use the man command to access the manual page for the ls command.
Navigate through the manual page using the arrow keys, and search for
specific keywords using / followed by the keyword. Exit the manual page
by pressing q.

2. Use the info command to access the documentation for the grep
command. Navigate through the info page using the arrow keys and
follow links by pressing Enter on the link text. Use the n and p keys to
In Lab move to the next and previous nodes, respectively. Exit the info page by
pressing q.

3. Navigate to the /usr/share/doc directory. List the contents of the


directory to see the available documentation. Choose a software
package directory (e.g., bash) and navigate into it. Open and read the
README file or other documentation files using a text editor like less or
nano.

1. What are the main differences between man and info pages?
2. When would you prefer to use info over man, and vice versa?
Viva Questions
3. How do you exit from man and info pages?

Access the man page for the cp command. Access the info page for the cp
Post Lab command. Compare the structure, detail, and navigation of the man and info
pages. Note any differences in the content provided by man and info.
Lab Experiment - 6

AIM To learn how to manage local users and groups in a Linux system

creating, modifying, and deleting users and groups, managing user


Description
permissions, and configuring password policies

Pre-Lab
useradd, passwd, userdel, usermod, chage, chgrp, touch
Commands

1. Create a new user named user1. Set a password for user1. Verify the
creation of user1 by checking the /etc/passwd file. Delete the user
user1.
2. Create a new group named group1. Add the existing user user1 to
In Lab group1. Verify the addition of user1 to group1 by checking the /etc/group
file. Delete the group group1.
3. Change the home directory of user1 to /home/newuser1. Change the
login shell of user1 to /bin/bash. Change the full name of user1 to "User
One". Verify the changes by checking the /etc/passwd file.

What command is used to create a new user in Linux?


How do you create a new group in Linux?
Viva Questions
What command is used to modify user account details?
What command is used to configure password aging policies?

1. Set the minimum password age for user1 to 7 days. Set the maximum
password age for user1 to 90 days. Set a password expiration warning for
Post Lab
user1 to 7 days. Verify the password aging settings.
Lab Experiment - 7

To understand and manage multiuser environments, handle remote


AIM
systems, and manage user accounts in a Linux system.

These experiments involve managing user accounts and environments in


Description multiuser systems, handling remote systems via SSH, and performing user
management tasks on both local and remote systems.

Pre-Lab
ssh, groupadd, useradd, passwd, chage
Commands

Practice disk partitioning and physical volume creation in Linux systems


• On a local system, create a new group named localgroup.
• Create a new user named localuser and add them to localgroup.
In Lab • Connect to a remote system using SSH.
• On the remote system, create a new group named remotegroup.
• Create a new user named remoteuser and add them to remotegroup.
Verify the group memberships for both local and remote users.

How do you create a new user on a remote system using SSH?


Viva Questions What is the command to set a password for a user on a remote system?
How do you remove a user from a remote system?

***This lab is ideal to be done in Redhat Academy Portal***


You set a default local password policy, create a secondary group for three users,
allow that group to use sudo to run commands as root, and modify the password
policy for one user.
• From the workstation machine, open an SSH session to the serverb
machine as the student user and switch to the root user.
• On the serverb machine, ensure that newly created users must change
their passwords every 30 days.
• Create the consultants group with a GID of 35000. Configure
administrative rights to enable all consultants group members to
Post Lab
execute any command as any user.
• Create the consultant1, consultant2, and consultant3 users with the
consultants group as their secondary group.
• Set the consultant1, consultant2, and consultant3 passwords to redhat.
Set the consultant1, consultant2, and consultant3 accounts to expire in
90 days from the current day.
• Change the password policy for the consultant2 account to require a
new password every 15 days.
Additionally, force the consultant1, consultant2, and consultant3 users
to change their passwords on the first login
Lab Experiment - 8

To understand and practice disk partitioning and physical volume creation


AIM
in Linux systems.

These experiments involve partitioning disks, creating physical volumes, and


Description preparing them for use with logical volume management. Students will gain
practical experience in disk management and volume preparation

Pre-Lab
fdisk, parted, vgcreate , vgextend , vgdisplay, dd, mount
Commands

1. Create, list, and delete partitions on a disk using the fdisk utility.
2. How to use the parted utility to create, modify, and delete disk
partitions.
3. Initialize a disk partition or entire disk as a physical volume using the
In Lab pvcreate command.
4. create a volume group from physical volumes and creating a logical
volume within that group.
5. Format a logical volume with a filesystem and mounting it to make it
accessible.

1. What command is used to format a logical volume with a filesystem?


Viva Questions 2. How do you mount a logical volume in Linux?
3. How can you verify that a logical volume is successfully mounted?

***This lab is ideal to be done in Redhat Academy Portal***


Create partitions on a new disk, formatting some with file systems and
mounting them, and activating others as swap spaces.
• The serverb machine has several unused disks. On the first unused disk,
create a 2 GB GPT backup partition. Because it is difficult to set an exact
size, a size between 1.8 GB and 2.2 GB is acceptable.
• Configure the backup partition to host an XFS file system. Format the
2 GB backup partition with an XFS file system and persistently mount it
to the /backup directory.
Post Lab
• On the same disk, create two 512 MB GPT partitions called swap1 and
swap2. A size between 460 MB and 564 MB is acceptable. Configure the
file-system types of the partitions to host swap spaces.
• Initialize the two 512 MiB partitions as swap spaces and configure them
to activate at boot.
• Set the swap space on the swap2 partition to be preferred over the other.
To verify your work, reboot the serverb machine. Confirm that the system
automatically mounts the first partition onto the /backup directory. Also,
confirm that the system activates the two swap spaces.
Lab Experiment - 9

To understand and perform volume group management and logical volume


AIM
operations using Linux Logical Volume Manager (LVM).

creating, managing, and operating on volume groups and logical volumes using
Description LVM commands. Students will gain practical skills in volume group
management, logical volume creation, resizing, and removal.

Pre-Lab
vgcreate, lvcreate, mkfs, lvcreate , lvremove , lvresize
Commands

1. Create a new volume group named vg2 from a physical volume (e.g.,
/dev/sdb1). Verify the volume group creation. Extend the volume group
vg2 by adding another physical volume (e.g., /dev/sdc1). Verify the
volume group extension. Reduce the volume group vg2 by removing a
physical volume.
In Lab
2. Create a new volume group named vg2 from a physical volume (e.g.,
/dev/sdb1). Verify the volume group creation. Extend the volume group
vg2 by adding another physical volume (e.g., /dev/sdc1). Verify the
volume group extension. Reduce the volume group vg2 by removing a
physical volume.

1. What command is used to create a backup of a logical volume?


Viva Questions 2. How do you restore a logical volume from a backup?
3. How can you verify the data in a restored logical volume?

***This lab is ideal to be done in Redhat Academy Portal***

1) resize an existing logical volume, add LVM resources as necessary, and


then add a new logical volume with a persistently mounted XFS file system
on it.

• On the serverb machine, the serverb_01_lv logical volume mounted on


Post Lab
the /storage/ data1 directory is running out of disk space and needs to be
extended to 768 MiB.
• You must ensure that the serverb_01_lv LV remains persistently
mounted on the /storage/data1 directory.
• The serverb_01_lv LV is present on the serverb_01_vg volume group.
Unfortunately, it has insufficient space to extend the existing logical
volume.
• A 512 MiB partition exists on the /dev/vdb disk. Create a new partition
using the successive 512 MiB size on the /dev/vdb disk. Create the
serverb_02_lv LV with 128 MiB.
• Create the XFS file system on the newly created volume. Mount the newly
created logical volume on the /storage/data2 directory 1. Create a
512 MiB partition on the /dev/vdb disk.
• Initialize this partition as a physical volume, and extend the
serverb_01_vg volume group to use this partition. 2. 3. 4. Extend the
serverb_01_lv logical volume to 768 MiB.
• In the existing volume group, create the new serverb_02_lv logical
volume with 128 MiB. Add an XFS file system and mount it persistently
on the /storage/data2 directory.
• Verify that the newly created LV is mounted with the desired size
Lab Experiment - 10

To understand and practice creating and managing various file systems,


AIM
including vfat, ext4, and xfs.

creating, formatting, and managing different types of file systems, including


Description
vfat, ext4, and xfs.

Pre-Lab
vfat, df, mount, umount, lsblk, ext4, and xfs
Commands

1. Create a partition for the vfat file system (e.g., /dev/sdb1). Format the
partition with the vfat file system. Create a mount point directory. Mount
the vfat partition to the mount point. Verify the mount and file system
type. Unmount the partition.
In Lab
2. Create a partition for the ext4 file system (e.g., /dev/sdb2). Format the
partition with the ext4 file system. Create a mount point directory. Mount
the ext4 partition to the mount point. Verify the mount and file system
type. Unmount the partition.

1. What are the main differences between vfat, ext4, and xfs file systems?
2. How do you compare the performance of different file systems?
Viva Questions
3. What commands can be used to verify the file system type and disk
usage?

1. Create a partition for the xfs file system (e.g., /dev/sdb3). Format the
partition with the xfs file system. Create a mount point directory. Mount
the xfs partition to the mount point. Verify the mount and file system
type. Unmount the partition.
2. Create three partitions for vfat, ext4, and xfs file systems (e.g., /dev/sdb1,
Post Lab /dev/sdb2, /dev/sdb3). Format each partition with its respective file
system. Create mount point directories. Mount each partition to its
respective mount point. Perform basic file operations (e.g., create, copy,
and delete files) on each file system. Compare the performance and
features of each file system using commands such as df -Th and lsblk.
Lab Experiment - 11

To understand and practice mounting and unmounting local and network


AIM
file systems, including NFS (Network File System).

mounting and unmounting various types of file systems, including local file
Description
systems and network file systems via NFS.

1) How do you configure a directory to be shared via NFS?


2) What command is used to mount an NFS share on a client?
Pre-Lab
3) How can you verify that an NFS share is mounted correctly?
4) What is the purpose of the /etc/fstab file?
5) What steps would you take to troubleshoot a mount failure?

1. Create a partition or use an existing one (e.g., /dev/sdb1). Create a file


system on the partition if it does not already exist (e.g., ext4). Create a
mount point directory. Mount the partition to the mount point. Verify the
mount. Unmount the partition. Verify the unmount

2. How to mount and unmount network file systems using NFS.

On the NFS Server:


▪ Install NFS server package.
▪ Configure an NFS export by editing /etc/exports.
In Lab ▪ Create the shared directory and set permissions.
▪ Export the shared directory.
▪ Start the NFS server service.
On the NFS Client:
• Install NFS client package.
• Create a mount point directory.
• Mount the NFS share to the mount point.
• Verify the NFS mount.
• Unmount the NFS share.

1) How do you configure a file system to mount automatically at boot?


Viva Questions 2) What command can be used to apply changes made to /etc/fstab?
3) How can you verify that an NFS share is mounted correctly?
1) To configure persistent mounts for local and network file systems using
the /etc/fstab file.

For Local File Systems:


• Open the /etc/fstab file in a text editor.
Post Lab
• Add an entry for the local file system (e.g., /dev/sdb1).
• Save and close the file.
• Test the new /etc/fstab configuration.
• Verify the mount.
• Verify the mount.
Lab Experiment - 12

To understand and implement configuration and automation for file system


AIM
mounting in Linux.

configuring file systems for automatic mounting at boot and automating file
Description
system management tasks using scripting and configuration tools

Pre-Lab
systemd, crontab, systemctl, df,
Commands

1. Create a shell script to mount a file system


In Lab
2. Create a shell script to unmount the file system.

1) How can you test a shell script for mounting and unmounting file
systems?
Viva Questions
2) How do you schedule tasks using cron in Linux?
3) What is the purpose of the cron job entry for a daily backup?

Post Lab Create a shell script for a file system management task (e.g., a backup script)
Lab Experiment - 13

AIM To configure autofs to handle multiple NFS shares dynamically.

Setting up autofs to automatically mount and manage NFS shares on-demand.


Description Students will gain experience with configuring autofs for automatic and on-the-
fly network file system mounting.

1. What is autofs, and what is its primary purpose?


Pre-Lab 2. How do you configure autofs to manage NFS mounts?
3. How can you verify that multiple NFS shares are mounted correctly?

1. How to set up autofs to manage multiple NFS shares by updating the


configuration to handle various network file systems.
Hint:
In Lab • Open the auto.master File
• Edit the Map File /etc/auto.nfs
• Restart the autofs Service
• Verify the Configuration

1. How do you configure autofs for different types of file systems?


2. What are the required options for mounting a CIFS share using autofs?
Viva Questions
3. How can you verify that different file systems are mounted correctly
using autofs?

If an NFS share path on the server is updated from /oldshare to /newpath, how
Post Lab would you modify the autofs configuration to reflect this change? Include the
necessary steps and any considerations for minimizing disruption to users.
Lab Experiment - 14

To automate log rotation using a cron job to manage log file sizes and
AIM
retention.

creating a cron job to rotate log files periodically, ensuring that log files do not
Description
consume excessive disk space.

1. What is crontab.
2. What is the purpose of log rotation, and how does it benefit system
Pre-Lab maintenance?
Commands 3. How do you create a cron job to run a script at a specific time?
4. How can you verify that a cron job is executing correctly?

1) Create a Cron Job for Log Rotation


Hint:
• Create a Log Rotation Script
In Lab
• Make the script executable
• Schedule the Script Using cron
• Verify the Cron Job

1. How can you combine multiple maintenance tasks into a single cron
job?
Viva Questions 2. What are the benefits of using a single script for multiple tasks?
3. How can you verify that a cron job performing multiple tasks is working
correctly?

1) Create a cron job to back up important directories or files at regular


Post Lab
intervals.
Lab Experiment - 15

To automate advanced system tasks using cron for recurring tasks and at
AIM
for one-time tasks.

These experiments focus on managing complex system deployment and


Description
maintenance tasks.

Pre-Lab
Cron, at
Commands

1. How to set up scheduled tasks using cron for regular maintenance and
at for one-time job scheduling.

2. How to manage and troubleshoot system services using systemctl for


In Lab
service control and monitoring.

3. How to configure and manage boot options and boot loaders for
customized system startup.

1. What is the difference between cron and at in Linux?


Viva Questions 2. How do you schedule a script to run daily using cron?
3. How can you use at to schedule a one-time task?

1. How do you modify GRUB boot parameters in /etc/default/grub?


2. What is the purpose of running update-grub after editing the
Post Lab
configuration?
3. How can you add a custom boot entry in GRUB?

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy