You are on page 1of 25

LAB-5

Aim: Compile and Debug Various C Programs Using Different


Options

Objective: The objective of this lab is to familiarize yourself with compiling and debugging C
programs using different options available in the compiler. By the end of this lab, you should
be comfortable compiling C programs and using debugging options to identify and resolve
errors.

Tools/Software Required:

• Text editor (e.g., Vim, Emacs, Sublime Text)

Lab Exercises:

Creating c file in vi:

Click here to enter text.


1. Compiling a Simple C Program

Description: Compile a simple "Hello, World!" C program without any optimization flags.

Commands:

gcc -o hello hello.c

Expected Output: If there are no syntax errors in the program, the compiler should generate
an executable file named "hello".

2. Debugging a C Program

Description: Introduce an error in the "Hello, World!" program and attempt to compile it
with debugging symbols.

Commands:

gcc -o hello_debug -g hello.c

Click here to enter text.


Expected Output: The compiler should generate an executable file named "hello_debug"
with debugging symbols included.

3. Enabling All Warnings

Description: Compile the "Hello, World!" program with all warning messages enabled to
catch potential issues.

Commands:

gcc -o hello_warnings -Wall hello.c

Click here to enter text.


Expected Output: The compiler should display warning messages if there are any potential
issues in the code.

4. Optimizing Compilation

Description: Compile the "Hello, World!" program with optimization flags enabled.

Commands:

gcc -o hello_optimized -O3 hello.c

Expected Output: The compiler should generate optimized machine code for better
performance.

5. Static Analysis with AddressSanitizer

Description: Compile the "Hello, World!" program with AddressSanitizer enabled for
detecting memory errors.

Commands:

Expected Output: The compiler should generate an executable file with AddressSanitizer
enabled for runtime memory error detection.

6. Profiling Compilation

Description: Compile the "Hello, World!" program with profiling flags enabled for
performance analysis.

Commands:

gcc -o hello_asan -fsanitize=address hello.c

Expected Output: The compiler should generate an executable file with profiling support for
analyzing program execution time.

Conclusion: In this lab, you learned how to compile and debug C programs using various
options available in the compiler. Understanding these options is essential for efficient
development and debugging of C programs.

Click here to enter text.


LAB-6

AIM: Learning of Installation and Upgradation of Linux Operating


System

Objective: The objective of this lab is to familiarize yourself with the process of installing and
upgrading a Linux operating system. By the end of this lab, you should be able to perform a
fresh installation of Linux and upgrade an existing Linux installation.

Tools/Software Required:

• Linux distribution ISO file (e.g., Ubuntu, Fedora, CentOS)


• Virtualization software (e.g., VirtualBox, VMware)
• Bootable USB drive (optional)
• Internet connection (for updates and upgrades)

Lab Exercises:

1. Preparing for Installation

Description: Download the ISO file of the Linux distribution you want to install. Optionally,
create a bootable USB drive using tools like Rufus (for Windows) or dd command (for Linux).
If you're using a virtual machine, skip this step.

Commands:

Expected Output: The ISO file is downloaded and/or the bootable USB drive is created
successfully.

2. Installing Linux

Description: Boot your computer from the bootable USB drive or start your virtual
machine. Follow the on-screen instructions to begin the installation process. Choose
appropriate options such as language, keyboard layout, disk partitioning, and installation
type (e.g., minimal, desktop). Complete the installation process by setting up a user account
and configuring network settings.

Commands: No specific commands, as the installation process is mostly GUI-based.

Click here to enter text.


Expected Output: A successful installation of the Linux operating system.

3. Create a Bootable USB stick


To install Ubuntu Desktop, you need to write your downloaded ISO to a USB stick to create
the installation media. This is not the same as copying the ISO, and requires some bespoke
software.

For this tutorial, we’ll use balenaEtcher, as it runs on Linux, Windows and Mac OS. Choose
the version that corresponds to your current operating system, download and install the tool.

Click here to enter text.


Select your downloaded ISO, choose your USB flash drive, and then click Flash! to install
your image.

Click here to enter text.


3. Performing System Updates

Description: After installing Linux, perform system updates to ensure that your system is up-
to-date with the latest security patches and software updates. Use the package manager
provided by your Linux distribution to update the system.

Commands:

# Update package repositories

Expected Output: The system updates are successfully installed.

4. Upgrading Linux Distribution

Description: If you're using an existing Linux installation and want to upgrade to a newer
version, follow the upgrade process provided by your distribution. This may involve using
package managers like apt or dnf to upgrade packages, or running specific commands
provided by the distribution.

Click here to enter text.


Commands:

# Upgrade to a newer version

sudo apt full-upgrade -y

Expected Output: The Linux distribution is successfully upgraded to the newer version.

Conclusion: In this lab, you learned the process of installing and upgrading a Linux
operating system. By following these steps, you can set up a new Linux installation or
upgrade an existing one with ease.

Click here to enter text.


LAB-7

AIM : Install Linux Alongside an Existing Operating System

Objective: The objective of this lab is to guide you through the process of installing Linux on
VirtualBox, a virtualization software, without the need for a bootable USB drive. By the end of
this lab, you should have a fully installed Linux system running within VirtualBox.

Tools/Software Required:

• VirtualBox (Download and install from virtualbox.org)


• Linux distribution ISO file (e.g., Ubuntu, Fedora, CentOS)

Lab Exercises:

1. Download Linux ISO


• Description: Download the ISO file of the Linux distribution you want to
install from its official website or a trusted source.
• Commands/Steps:
• Go to the official website of the Linux distribution.
• Download the ISO file for your desired distribution.
2. Install VirtualBox
• Description: Download and install VirtualBox, a virtualization software that
allows you to run guest operating systems on your host machine.
• Commands/Steps:
• Go to virtualbox.org.
• Download the appropriate version of VirtualBox for your operating
system.
• Install VirtualBox by following the on-screen instructions.
3. Create a New Virtual Machine
• Description: Use VirtualBox to create a new virtual machine for installing
Linux.
• Commands/Steps:
• Open VirtualBox.
• Click on "New" to create a new virtual machine.
• Follow the wizard to set up the virtual machine, including specifying
the OS type and version.

Click here to enter text.


4. Allocate Resources
• Description: Allocate resources such as RAM and virtual hard disk space for
the virtual machine.
• Commands/Steps:
• Customize the virtual machine settings, including RAM size, CPU cores,
and virtual disk size.
5. Mount the Linux ISO
• Description: Mount the Linux ISO file as a virtual optical drive in VirtualBox.
• Commands/Steps:
• In the virtual machine settings, navigate to the "Storage" tab.
• Select the empty optical drive and choose "Choose a disk file".
• Browse and select the Linux ISO file you downloaded.

Click here to enter text.


6. Start the Virtual Machine
• Description: Start the virtual machine and boot from the mounted Linux ISO
file.
• Commands/Steps:
• Start the virtual machine.
• It should boot from the mounted ISO file and launch the Linux
distribution's installation process.
7. Install Linux
• Description: Follow the on-screen instructions to install Linux on the virtual
machine.
• Commands/Steps:
• Follow the installation wizard, choosing language, keyboard layout,
and installation type.
• Partition the virtual disk and select the appropriate options for your
installation.

Click here to enter text.


Click here to enter text.
Click here to enter text.
Click here to enter text.
Click here to enter text.
8. Complete Installation
• Description: After the installation is complete, restart the virtual machine and
configure your Linux system.
• Commands/Steps:
• Restart the virtual machine to complete the installation process.
• Follow the initial setup prompts to configure your Linux system.

Conclusion: In this lab, you learned how to install Linux on VirtualBox without the need
for a bootable USB drive. By creating a virtual machine and mounting the Linux ISO file, you
were able to install and configure Linux within a virtualized environment.

Click here to enter text.


LAB-8

AIM : System Administration Tasks and Scripting

Objective: The objective of this lab is to familiarize you with various system administration
tasks such as user account management, package installation, backups, and scripting for file
and user management. Additionally, you will learn how to create startup and shutdown
scripts using tools like at and cron.

Tools/Software Required:

• Linux distribution (e.g., Ubuntu, CentOS)


• Terminal or command line interface

Lab Exercises:

1. User Account Management

Description: As a supervisor, you will create and maintain user accounts on the system.

Commands/Steps:

# Create a new user

Click here to enter text.


# Delete a user

Expected Output: New user account is created and old user account is deleted successfully.

2. Package Installation

Description: Install packages using package managers like apt (for Debian-based
systems) or yum (for Red Hat-based systems).

Commands/Steps:

# Update package lists

sudo apt update

Click here to enter text.


# Install a package

sudo apt install package_name

Click here to enter text.


Expected Output: Package is installed successfully.

3. Taking Backups

Description: Create backups of important files or directories using tools like tar or rsync.

Commands/Steps:

# Create a tar archive of a directory

tar -czvf backup.tar.gz /path/to/directory

Click here to enter text.


Expected Output: Backup is created successfully.

4. Scripting for File and User Management

Description: Write shell scripts to automate file and user management tasks.

Script Example:

#!/bin/bash

# Create a new user

sudo adduser newuser

# Backup important files

Click here to enter text.


tar -czvf backup.tar.gz /important/directory

# Clean up temporary files

rm -rf /tmp/*

Expected Output: Script executes successfully, creating a new user, taking backups, and
cleaning up temporary files.

5. Startup and Shutdown Scripts with at and cron

Description: Schedule tasks to run at startup and shutdown using at and cron.

Commands/Steps:

# Schedule a task to run at startup

echo "backup_script.sh" | sudo tee -a /etc/init.d/startup_script.sh

sudo update-rc.d startup_script.sh defaults

# Schedule a task to run at shutdown

echo "cleanup_script.sh" | sudo tee -a /etc/init.d/shutdown_script.sh

sudo update-rc.d shutdown_script.sh stop 20 0 6 .

Click here to enter text.


Expected Output: Tasks are scheduled to run at startup and shutdown as configured.

Click here to enter text.


Conclusion: In this lab, you learned essential system administration tasks such as user
account management, package installation, backups, and scripting for automation.
Additionally, you learned how to schedule tasks to run at startup and shutdown using at and
cron. These skills are fundamental for effective system administration and automation in a
Linux environment.

Click here to enter text.

You might also like