Linux Administration Practical Workbook-Final
Linux Administration Practical Workbook-Final
AUTOMATION
23SDCS11A/E/R
S.No Date Experiment Name In-Lab (25M) Post- Viva Total Faculty
Pre-Lab Program/ Data and Analysis Lab Voce (50M) Signature
(10M) Procedure Results & (10M) (5M)
(5M) (10M) Inference
(10M)
1. Introductory Session -NA-
Develop proficiency in fundamental
2. command-line operations and redirection
techniques in a Linux environment
Manage text files, file permissions, and links
3.
within a Linux environment
learn script automation and command
4.
processing techniques.
Understand and apply file archiving,
compression, and decompression
5.
techniques using tar and gzip in a Linux
environment
Learn how to utilize system documentation
6. effectively using man, info, and files in
/usr/share/doc
Learn how to manage local users and groups
7.
in a Linux system
Understand and manage multiuser
8. environments, handle remote systems, and
manage user accounts in a Linux system
Understand and practice disk partitioning
9. and physical volume creation in Linux
systems
S.No Date Experiment Name In-Lab (25M) Post- Viva Total Faculty
Pre-Lab Program/ Data and Analysis Lab Voce (50M) Signature
(10M) Procedure Results & (10M) (5M)
(5M) (10M) Inference
(10M)
Understand and perform volume group
10. management and logical volume operations
using Linux Logical Volume Manager (LVM).
Understand and practice creating and
11. managing various file systems, including
vfat, ext4, and xfs
Understand and practice mounting and
12 unmounting local and network file systems,
including NFS (Network File System)
Understand and implement configuration
13. and automation for file system mounting in
Linux
Experiment Title: 1
Aim/Objective:
Use the shell prompt, execute commands with correct syntax, utilize input output redirection
techniques
Pre-Requisites:
Basic knowledge of what Linux is and its common distributions (e.g., Ubuntu, CentOS, Fedora).
Pre-Lab:
ls
cd
mkdir
pwd
rmdir
mv
touch
cp
cat
passwd
head
tail
grep
Standard
Input
Redirection
(<)
Standard
Output
Redirection
(>, >>)
Standard
Error
Redirection
(2>, 2>>)
In-Lab:
• Change to the docs directory and create an empty file named project_notes.txt.
• Change back to the ProjectWorkspace directory.
• 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.
• Inside the docs directory, create a file named instructions.txt and write 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).
Directory cleanup:
Procedure/Program:
Procedure/Program:
1. What is a shell?
3. What is the difference when the shell is running hash (#) and ($) character?
Post-Lab:
1) you are provided with a text file named data.txt containing lines of text with varying formats.
Write a command that:
• Searches for lines that contain a valid email address (an email address is defined
as a string with the format [email protected]).
• Extracts only the email addresses from the lines.
• Sorts the extracted email addresses alphabetically.
• Removes any duplicate email addresses.
• Saves the result to a file named emails.txt.
Procedure/Program:
2) Connect to a remote system using SSH with the username student and the IP address
XXX.XXX.XX.XX. After connecting, create a directory named remote_test in the user's home
directory. Provide the SSH command and the commands used on the remote system.(This lab is
ideal to perform in Redhat Academy)
Procedure/Program:
Marks Secured:_____out of 50
Experiment Title: 2
Aim/Objective:
To manage text files, file permissions, and links within a Linux environment.
Description:
create and edit text files, manage file permissions and links
Pre-Requisites:
Basic knowledge of what Linux is and its common distributions (e.g., Ubuntu, CentOS, Fedora).
Pre-Lab:
cat
nano
Vi
vim
gedit
chmod
chown
chgrp
In-Lab:
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
Procedure/Program:
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.
Procedure/Program:
Post-Lab:
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
Procedure/Program:
2. Use the man command to find information about the tar command. Use the 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.
Procedure/Program:
Marks Secured:_____out of 50
Experiment Title: 3
Description:
To develop skills required to conditionally execute code, use looping constructs to process files and
command-line input, and process the output of shell commands within a script.
Pre-Requisites:
Basic knowledge of what Linux is and its common distributions (e.g., Ubuntu, CentOS, Fedora).
Pre-Lab:
‘if’ statement
‘test’ command
[ ] (test
command
shorthand)
for loop
while loop
until loop
In-Lab:
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
▪ Print all the difference between two file, copy the two files at
▪ $USER/CSC/2007 directory.
▪ Print lines matching certain word pattern.
Procedure/Program:
1. What is shell?
Post-Lab:
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 reports accordingly. whenever the argument is
a file it reports no of lines present in it
Procedure/Program:
Marks Secured:_____out of 50
Experiment Title: 4
Aim/Objective:
To understand and apply file archiving, compression, and decompression techniques using tar and
gzip in a Linux environment.
Description:
These experiments cover the creation, listing, extraction, compression, and decompression of files and
directories using the tar and gzip commands. Students will gain practical experience in managing
archives and compressed files efficiently.
Pre-Requisites:
Basic knowledge of what Linux is and its common distributions (e.g., Ubuntu, CentOS, Fedora).
Pre-Lab:
Tar
gzip
pwd
In-Lab:
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.
Procedure/Program:
2. Ensure testdir.tar archive from Question 1 exists. Create a directory named extracted.
Extract the contents of testdir.tar into the extracted directory.
Procedure/Program:
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.
Procedure/Program:
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.
Procedure/Program:
2. What does the -z option do when used with the tar command?
3. How do you specify the extraction directory using the tar command?
Post-Lab:
1. Create a directory named project. Inside project, create files named doc1.txt, doc2.txt, and
doc3.txt. Use the tar command with gzip compression to create a compressed tarball
project.tar.gz. List the contents of the compressed tarball without extracting it.
Procedure/Program:
Marks Secured:_____out of 50
Experiment Title: 5
Aim/Objective:
To learn how to utilize system documentation effectively using man, info, and files in
/usr/share/doc.
Description:
These experiments involve using man and info commands to access system documentation and
exploring the documentation files available in the /usr/share/doc directory.
Pre-Requisites:
Basic knowledge of what Linux is and its common distributions (e.g., Ubuntu, CentOS, Fedora).
Pre-Lab:
Man
info
ls
In-Lab:
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.
Procedure/Program:
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 move to the next and previous nodes, respectively. Exit the
info page by pressing q.
Procedure/Program:
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.
Procedure/Program:
1. What are the main differences between man and info pages?
2. When would you prefer to use info over man, and vice versa?
Post-Lab:
1. Access the man page for the cp command. Access the info page for the cp command. Compare
the structure, detail, and navigation of the man and info pages. Note any differences in the
content provided by man and info.
Procedure/Program:
Marks Secured:_____out of 50
Experiment Title: 6
Aim/Objective:
Description:
Creating, modifying, and deleting users and groups, managing user permissions, and
configuring password policies
Pre-Requisites:
Basic knowledge of what Linux is and its common distributions (e.g., Ubuntu, CentOS, Fedora).
Pre-Lab:
useradd
passwd
userdel
usermod
chage
chgrp
touch
cp
In-Lab:
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.
Procedure/Program:
2. Create a new group named group1. Add the existing user user1 to group1. Verify the addition
of user1 to group1 by checking the /etc/group file. Delete the group group1.
Procedure/Program:
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.
Procedure/Program:
Post-Lab:
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 user1 to 7 days. Verify the password aging
settings.
Procedure/Program:
Marks Secured:_____out of 50
Experiment Title: 7
Aim/Objective:
To understand and manage multiuser environments, handle remote systems, and manage user
accounts in a Linux system.
Description:
These experiments involve managing user accounts and environments in multiuser systems,
handling remote systems via SSH, and performing user management tasks on both local and
remote systems.
Pre-Requisites:
Basic knowledge of what Linux is and its common distributions (e.g., Ubuntu, CentOS, Fedora).
Pre-Lab:
ssh
groupadd
useradd
passwd
chage
In-Lab:
Procedure/Program:
Post-Lab:
1.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 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
Procedure/Program:
Marks Secured:_____out of 50
Experiment Title: 8
Aim/Objective:
To understand and practice disk partitioning and physical volume creation in Linux systems.
Description:
These experiments involve partitioning disks, creating physical volumes, and preparing them for use
with logical volume management. Students will gain practical experience in disk management and
volume preparation
Pre-Requisites:
Basic knowledge of what Linux is and its common distributions (e.g., Ubuntu, CentOS, Fedora).
Pre-Lab:
ls
fdisk
parted
vgcreate
vgextend
vgdisplay
dd
mount
In-Lab:
1. Create, list, and delete partitions on a disk using the fdisk utility.
Procedure/Program:
2. How to use the parted utility to create, modify, and delete disk partitions.
Procedure/Program:
3. Initialize a disk partition or entire disk as a physical volume using the pvcreate command.
Procedure/Program:
4. Create a volume group from physical volumes and creating a logical volume within that group.
Procedure/Program:
Procedure/Program:
Post-Lab:
1.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.
• 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.
Procedure/Program:
Marks Secured:_____out of 50
Experiment Title: 9
Aim/Objective:
To understand and perform volume group management and logical volume operations using Linux
Logical Volume Manager (LVM).
Description:
Creating, managing, and operating on volume groups and logical volumes using LVM
commands. Students will gain practical skills in volume group management, logical volume
creation, resizing, and removal.
Pre-Requisites:
Basic knowledge of what Linux is and its common distributions (e.g., Ubuntu, CentOS, Fedora).
Pre-Lab:
vgcreate
lvcreate
mkfs
lvcreate
lvremove
lvresize
Create
cp
In-Lab:
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.
Procedure/Program:
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.
Procedure/Program:
Post-Lab:
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 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
Procedure/Program:
Marks Secured:_____out of 50
Experiment Title: 10
Aim/Objective:
To understand and practice creating and managing various file systems, including vfat, ext4, and
xfs.
Description:
Creating, formatting, and managing different types of file systems, including vfat, ext4, and
xfs.
Pre-Requisites:
Basic knowledge of what Linux is and its common distributions (e.g., Ubuntu, CentOS, Fedora).
Pre-Lab:
vfat
df
mount
umount
lsblk
ext4
xfs
cp
In-Lab:
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.
Procedure/Program:
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.
Procedure/Program:
1. What are the main differences between vfat, ext4, and xfs file systems?
3. What commands can be used to verify the file system type and disk usage?
Post-Lab:
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.
Procedure/Program:
2. Create three partitions for vfat, ext4, and xfs file systems (e.g., /dev/sdb1, /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.
Procedure/Program:
Marks Secured:_____out of 50
Experiment Title: 11
Aim/Objective:
To understand and practice mounting and unmounting local and network file systems, including NFS
(Network File System).
Description:
Mounting and unmounting various types of file systems, including local file systems and
network file systems via NFS.
Pre-Requisites:
Basic knowledge of what Linux is and its common distributions (e.g., Ubuntu, CentOS, Fedora).
Pre-Lab:
In-Lab:
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
Procedure/Program:
Procedure/Program:
Post-Lab:
1) To configure persistent mounts for local and network file systems using the /etc/fstab file.
Procedure/Program:
Marks Secured:_____out of 50
Evaluator Remark (if Any):
Experiment Title: 12
Aim/Objective:
To understand and implement configuration and automation for file system mounting in Linux.
Description:
Configuring file systems for automatic mounting at boot and automating file system management
tasks using scripting and configuration tools.
Pre-Requisites:
Basic knowledge of what Linux is and its common distributions (e.g., Ubuntu, CentOS, Fedora).
Pre-Lab:
systemd
crontab
Systemctl, df
In-Lab:
Procedure/Program:
Procedure/Program:
1) How can you test a shell script for mounting and unmounting file systems?
3) What is the purpose of the cron job entry for a daily backup?
Post-Lab:
1. Create a shell script for a file system management task (e.g., a backup script)
Procedure/Program:
Marks Secured:_____out of 50
Experiment Title: 13
Aim/Objective:
Description:
Setting up autofs to automatically mount and manage NFS shares on-demand. Students will gain
experience with configuring autofs for automatic and on-the-fly network file system mounting.
Pre-Requisites:
Basic knowledge of what Linux is and its common distributions (e.g., Ubuntu, CentOS, Fedora).
Pre-Lab:
3. How can you verify that multiple NFS shares are mounted correctly?
In-Lab:
1. How to set up autofs to manage multiple NFS shares by updating the configuration to handle
various network file systems.
Hint:
• Open the auto.master File
• Edit the Map File /etc/auto.nfs
• Restart the autofs Service
• Verify the Configuration
Procedure/Program:
2. What are the required options for mounting a CIFS share using autofs?
3. How can you verify that different file systems are mounted correctly using autofs?
Post-Lab:
1. If an NFS share path on the server is updated from /oldshare to /newpath, how would you
modify the autofs configuration to reflect this change? Include the necessary steps and any
considerations for minimizing disruption to users.
Procedure/Program:
Marks Secured:_____out of 50
Experiment Title: 14
Aim/Objective:
To automate log rotation using a cron job to manage log file sizes and retention.
Description:
Creating a cron job to rotate log files periodically, ensuring that log files do not consume excessive
disk space.
Pre-Requisites:
Basic knowledge of what Linux is and its common distributions (e.g., Ubuntu, CentOS, Fedora).
Pre-Lab:
1. What is crontab.
2. What is the purpose of log rotation, and how does it benefit system maintenance?
In-Lab:
Procedure/Program:
1. How can you combine multiple maintenance tasks into a single cron job?
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?
Post-Lab:
Procedure/Program:
Marks Secured:_____out of 50
Experiment Title: 15
Aim/Objective:
To automate advanced system tasks using cron for recurring tasks and at for one-time tasks.
Description:
These experiments focus on managing complex system deployment and maintenance tasks.
Pre-Requisites:
Basic knowledge of what Linux is and its common distributions (e.g., Ubuntu, CentOS, Fedora).
Pre-Lab:
ls
Cron
at
In-Lab:
1. How to set up scheduled tasks using cron for regular maintenance and at for one-time job
scheduling.
Procedure/Program:
2. How to manage and troubleshoot system services using systemctl for service control and
monitoring.
Procedure/Program:
3. How to configure and manage boot options and boot loaders for customized system startup.
Procedure/Program:
Post-Lab:
Procedure/Program:
Procedure/Program:
Procedure/Program:
Marks Secured:_____out of 50