Btech Linux Experiment
Btech Linux Experiment
TOOLS/LIABILITIES/SOFTWARE USED:
Bash (Bourne Again Shell)
Linux Distribution(kali)
HARDWARE USED:
Standard PC
Virtual box
login
Description:
Usage:
$ login
Username: subodh
Password:
logout
Description:
The logout command is used to end the current session and log the
user out of the system.
Usage:
Example:
You have been successfully logged out.
who
Description:The who command displays information about users who
are currently logged into the system.
Usage:Type who and press Enter to display the list of logged-in users.
Example:
ls
Description:
The ls command lists the files and directories in the current working
directory.
Usage:
Type ls and press Enter to display the list of files and directories in the
current directory
Example:
tree
Description:
The tree command displays the directory structure in a tree-like format,
starting from the specified directory.
Usage:
Type tree [directory] and press Enter to display the directory structure.
Example:
pwd
Description:
The pwd command prints the current working directory.
Usage:
Type pwd and press Enter to display the current working directory.
Example:
cd
The cd command, short for "change directory," is used to navigate
between different directories in a file system. It allows you to move from
one directory to another within the file system hierarchy.
Syntax:
Parameters:
mkdir
Description:
The mkdir command is used to create new directories.
Usage:
Type mkdir [directory_name] and press Enter to create a new
directory.
Example:
rmdir
Description:
The rmdir command is used to remove empty directories.
Usage:
Example:
cal
Description:
The cal command displays a calendar for the specified month and year.
Usage:
Type cal [month] [year] and press Enter to display the calendar.
Example:
date
Description:
The date command displays the current date and time.
Usage:
Type date and press Enter to display the current date and time.
Example:
Lab-2: Familiarize with Vim editor and Linux GUIs
Vi Editor:
ED
EX
VI
Ed and ex are line editors, meaning line numbers are assigned to the
lines in a file. Vi, on the other hand, is a text editor or screen editor. It
displays as much of the file as it can fit on the screen, allowing the user
to view and edit the entire document at once. Creating and editing files
becomes easier using the vi editor.
Disadvantages of Vi:
Modes of Operation:
To create a file:
To invoke vi, type vi followed by the filename you want to create. When
you type vi and the filename and press Enter, vi clears the screen and
displays a window where you can enter and edit text.
To Add Text to a File:
To save the file and quit from vi, hold the Shift key and press ZZ (Shift +
ZZ). Another way to save a file is to use :wq for saving and quitting.
These commands are given in Ex command mode. You can combine
two commands to save and quit.
To Edit a File:
To edit an existing file, you can add, change, and delete text. Before
performing these tasks, you must load the file from the disk into the
buffer and then move to the part of the file you want to edit.
1. Position the cursor on the last character in the file using cursor
movement keys.
2. Press 'a' to switch from command to text input mode (where 'a'
stands for append).
3. Press the Esc key.
Move the cursor to the character you want to delete and press the 'X'
key (where 'X' is used to delete a character). To erase three characters,
give the command 3X.
To Overwrite Text:
1. Position the cursor at the character from where you want to begin
overwriting.
2. Press 'R' to indicate that whatever you type next should overwrite
the existing text.
3. Press the Esc key when you finish replacing the text.
Undoing Changes:
1. Arithmetic Operations:
Commands:
Script:
OUTPUT
Commands:
Script:
Explanation:
Commands:
Script:
1. Grep Commands:
Commands:
Options:
-c: Prints only a count of the lines that match a pattern.
-h: Displays the matched lines, but does not display the
-i: Ignores case distinctions in patterns and input data.
-l: Displays list of shashinames only.
-n: Display the matched lines and their line numbers.
-v: Prints out all the lines that do not match the pattern.
-e exp: Specifies expression with this option. Can be used
multiple times.
-f shashi: Takes patterns from shashi, one per line.
-w: Match whole word.
-o: Print only the matched parts of a matching line, with each
such part on a separate output line.
-A n: Prints searched line and n lines after the result.
-B n: Prints searched line and n line before the result.
-C n: Prints searched line and n lines after the result.
Script:
Text file
COMMANDS:
2. Using Awk for Data Manipulation and Reporting:
Description: This script showcases the usage of the awk command for
manipulating data and generating reports.
Commands:
Script:
Output :
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:
Lab Exercises:
Description: Compile a simple "Hello, World!" C program without any optimization flags.
Commands:
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:
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:
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:
Expected Output: The compiler should generate optimized machine code for better
performance.
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:
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.
LAB-6: 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:
Lab Exercises:
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.
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:
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.
Commands:
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.
Lab 7 :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:
Lab Exercises:
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.
Lab-8 : 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:
Lab Exercises:
Description: As a supervisor, you will create and maintain user accounts on the system.
Commands/Steps:
Expected Output: New user account is created and old user account is deleted
successfully.
2. Package Installation
Commands/Steps:
3. Taking Backups
Description: Create backups of important files or directories using tools like tar or rsync.
Commands/Steps:
Description: Write shell scripts to automate file and user management tasks.
Script Example:
#!/bin/bash
rm -rf /tmp/*
Expected Output: Script executes successfully, creating a new user, taking backups, and
cleaning up temporary files.
Description: Schedule tasks to run at startup and shutdown using at and cron.
Commands/Steps:
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.