Coverpdf
Coverpdf
Submitted by
Roshan Singh
Roll No- 211587 (B.Tech. 6th Sem.)
Submitted to
Dr. Nitin Goyal
Assistant Professor
Department of Computer Science and Engineering, CUH
Table of Content
S.No. Aim Page no Signature
Logging out, with command “who” command - can knowabout the user who already logged in,
command “exit” - to exit the terminal
Simple Commands :
Date: Date commands prints the systems date andtime
Syntax:date[option] [+%Format]
Date format can be
%D Date - MM/DD/YY
%H Hour - 00 to 23
%I Hour - 00 to 11
%M Minute - 00 to 59
%s Second - 00 to 59
%T Time - HH:MM:SS
%y Year’s last 2 digits
%w Day of the week
%r Time in AM/PM
Clear
to clear the last commands used, commands used is “clear”
Expr
this command is used to perform the arithmetic operations (operation +
addition, - subtraction, * multiplication, % remainder, / division is used) on
integers.
Make Directory
Syntax : mkdir <directory-name>
Creating a new directory -[root@localhost~]# mkdir<directory_name>
This command will create a new subdirectory with name
<directory_name> of current directory
Creating more than one directory
[root@localhost~]# mkdir x y z, this will create3 directories having name
x y zrespectively
Remove Directory
This command is used to remove a directory. Directoryshould be empty before
deletion.
Present Working
This command will display full path name for presentworking directory.
Syntax: pwd
Calendar
This command is used to print the calendar for the current year
Lab - 2
Aim:Familiarize with “vim” editor and Linux GUIs.
Post- Conditions:
ED and EX are the line editor. Where as VI is the text editor or screen editor. It
shows as much of the file as it can fit on screen. It is the first full screen editor.
Which allows the user to view and an edit the entire document at a time.
Creating and editing file becomes easier using vi editor.
Modes Of Operation:
1. Command mode:In this mode all the keys pressed by user are interpreted to
the editor commands that is for moving cursor for left right top bottom etc. in
this the key pressed are not displayed on the screen.
2. Insert Mode: this mode permits insertion of new text editing existing text.
Insertion mode is also know as i/p mode
3. Execution mode: It permits to give command at the command line. Bottom
line of screen is called command line.
e.g. $ vi roshan.txt
to invoke the vi type vi and file name that we want to create. When we type
the vi and the file name and press enter key then vi clears the screen and
display a window in which we can enter and edit text.
‘I’ command :to enter in insert mode ‘I’ key is pressed.To add the text to a file
the following steps are required:
III) To Save the File to the Disk: to save the file and quit for the VI holds the shift
key and press z twice (shift + zz). Another to save file is to use: w and: q for saving
and quitting. This command that begins with colons is given in Ex- command
mode. We can combine two commands to save and quit.
IV) To Edit a File: the edit and existing file you can add, change and delete text,
before you can perform these task you must load the file from the disk to buffer and
then move to the part of the file you want to edit.
VI)Quitting From VI :
to save the change and quit from vi then type vipress shift + zz in command
mode and: wq in Ex - mode
Not to save changes and quit VI then type : q!in Ex-mode and press the enter
key
Backward Search
wq - This command is used to save and exit
Forward Search
Backward search
Less myFile :this command is used to display the file in real mode.
Linux GUIs typically include components such asa file manager, application
launcher, taskbar or panel, system tray, and settings manager.
File managers like Nautilus (GNOME), Dolphin (KDE), Thunar (Xfce), and Nemo
(Cinnamon) allow users to browse files and folders, manage files, and perform
basic file operations.
3. Customization:
Many Linux desktop environments allow extensivecustomization to tailor the user
experience to individual preferences.
Users can customize desktop themes, icons, fonts,window decorations, and
desktop backgrounds.
Some desktop environments offer built-in tools for customization, while others may
rely on third-party applications or manual configuration.
4. Applications:
Linux GUIs support a wide range of applicationsfor productivity, multimedia,
internet browsing, gaming, development, and system administration.
Lab - 3
AIM :Using bash shell develop a simple shell program
Output :
2)TO PRINT A MULTIPLICATION TABLE
i = 1
while [ $i -le 10 ]
do
Output :
#!/bin/bash
reverse=""
temp=$num
fi
Output :
#!/bin/bash
fi
is_prime=true
for (( i=2; i<=num/2; i++ ))
do
if [ $((num%i)) -eq 0 ]; then
is_prime=false
break
fi
done
Output :
5)TO FIND THE FACTORIAL OF A NUMBER.
#!/bin/bash
factorial=1
fi
for (( i=1; i<=$num; i++
)) do
factorial=$((factorial *
i)) done
echo "Factorial of $num is: $factorial"
Output :
Lab - 4
AIM :Develop advanced shell program using awk and grep
POST CONDITION :Able to design shell program using awk and grep
gr ep Command
grep stands for Global Regular Expression Print is a useful command to search for
matching patterns in a file. grep is short for “global regular expression print”.
system admin needs to scrape through log files or a developer trying to find certain
occurrences in the code file, then grep is a powerful command to use.
grep searches for PATTERNS in each FILE. Grep finds each line that matches that
provided PATTERN. It is a good practice to close the PATTERN in quotes when grep is
used in a shell command.
To print how many times given keyword is present in flle:ex; grep -c
“keyword” filename
To search for exact match of the given keyword in a flle:ex; grep -w
“keyword” filename
● To flnd in which line the given keyword is in a flle:ex; grep -n
“keyword”filename
To print the matching line which start with the given keyword in a flle:
ex; grep “^keyword” filename
To print the matching line which end with the given keyword in a flle:
ex ; grep “keyword” filename
We can use egrep command for the multiple keywords search:ex;
egrep “key1|key2|key3” filename
awk command
awk is a scripting language, and it is helpful when working in the command line. It’s
also a widely used command for text processing.
When using awk, we are able to select data - one or more pieces of individual text -
based on a pattern we provide.
The awk command is followed by a set of single quotation marks and a set of
curly braces, with the name of the file we want to search through mentioned
last.
print all the content of the flle using awk:Toprint all the content of a file, the
action we specify inside the curly brace is print $0
To print speciflc columns using awk:When using awk, we can specify certain
columns we want print. Ex ; awk ‘{print $1}’ file_name
If we would like each line to have a line-number count, we would use the NR
built-in variable:Ex ; awk ‘{print NR, $0}’ file_name.
To print the last fleld, we can also use $NF which represent thelastfleld in
the record:Ex ; awk ‘{print $NF}’ file_name.
Print speciflc lines of a column:you can also specify the line we want printed
from our chosen column, print the first column. Then the output of that
command is piped, using the pipe symbol |, to the head command, where its
-num argument selects the first num lines of the column. Ex : awk ‘{print $1}’
file_name | head -num.
Print out lines with a speciflc pattern in awk:we can print a line that starts
with a specific letter, we use the up arrow symbol (^) first, which indicates the
beginning of a line, and then the letter we want a line to start with. Ex : awk
‘/^0/’ file_name
If we want to print out the lines the end in a 0- the $ symbol is used after a
character to signify how a line will end.
Ex ; awk ‘/0$/’ file_name
To count the lines in a flle:Ex ; awk ‘END {print NR}’ file_name
Lab - 5
Input:
#include <stdio.h>
int main() {
int number;
Output:
}
include <stdio.h>
#
int main() {
int num1, num2, sum;
printf("Enter the first number: ");
scanf("%d", &num1);
printf("Enter the second number: ");
scanf("%d", &num2);
// Calculate the sum
sum = num1 + num2;
// Print the result
printf("The sum of %d and %d is %d\n", num1, num2, sum);
}
#include <stdio.h>
int main() {
int num, i, flag = 0;
scanf("%d", &num);
if (num % i == 0) {
flag = 1;
break; } }
else
return 0;
}
##include <stdio.h>
fact *= i; }
return fact;
}
int main() {
int num;
scanf("%d", &num);
} else {
}
return 0;
}
;
}
LAB 6
Objective:
Theoretical Underpinnings:
ow that you've installed your Linux system, let's explore the process of
N
keeping it up-to-date with the latest security patches and features.
his command analyzes the current package list and downloads and
T
installs any updates for existing packages.
Additional Considerations:
Objective:
The objective of this experiment is to install a Linux distribution on a PC that already has
another operating system installed, ensuring that all operating systems remain usable.
Theory:
a. Installation of Linux
Linux can be installed in various ways, including from a DVD, a USB stick, or over a
network using NFS, FTP, or HTTP. The installation process involves several steps:
1.Boot from Installation Media: This could be a bootable DVD, USB stick, or
network boot server.
2.Select Installation Method: Choose the method that best suits your
environment and needs.
3.Partitioning: Partition your hard drive to create space for Linux. This could
involve resizing existing partitions or creating new ones.
5.Installation: The installer copies files to the hard drive, configures the
bootloader, and performs other necessary tasks.
6.Install Boot Loader:As part of the Linux installation, a boot loader (such as
GRUB) will be installed. This allows the user to choose which operating system
to boot into at startup.
7.TesttheInstallation:Aftertheinstallationiscomplete,restartthePC.The
boot loader should present the option to boot into either the original
operating system or the newly installed Linux distribution
Installation Tasks
1.Download:the ISO image of your preferred Linux distribution from its official
website.
2.Create:a bootable USB stick or DVD with the downloaded ISO image.
3.Boot from USB: Restart your computer and boot from the USB drive. You
might need to press a key (often F12, F10, or F2) during startup to change the
boot order.
6.Updates and Other Software: Choose whether you want to download updates
while installing Ubuntu and whether you want to install third-party software for
graphics and Wi- Fi hardware, Flash, MP3, and other media. Then click on
“Continue”.
7.Installation Type: You’ll be asked what type of installation you want. If you want
to install Ubuntu alongside your existing operating system, choose “Install
Ubuntu alongside them”. If you want to erase your entire disk and install Ubuntu,
choose “Erase disk and install Ubuntu”. Be careful with this option as it will erase
all data on the disk!
8.Choose Your Location: If you are connected to the internet, your location will
be detected automatically. Check if it’s correct and click on “Continue”.
9.Enter Your Login Information: Enter your name, your computer’s name, pick a
username, enter a password, and choose whether you want to log in
automatically or require a password. Click on “Continue”.
10.Installation: The installation process will now start. It can take a while, so
you might want to grab a cup of coffee.
10.Restart Your Computer: Once the installation is complete, you’ll be
prompted to restart your computer. Make sure to remove the USB drive, then
click on “Restart Now”.
10. GRUB Boot loader: Now, after each restart you’ll see a new bootloader
(GNU GRUB - version 2.0). Here, you can select the operating system that you
want to boot on each boot.
Lab Assignment 8
Aim:As supervisor create and maintain user accounts, learn
ackages installations, taking backups, creation of scripts for file and
p
user management, creation of startup and shutdown using at, crontab
etc.
Managing users:
o create and maintain user accounts in Linux, you can use the
T
command line called ”useradd”.
command:
o view the existing list of user on your Linux system, you can run the
T
following command:
Managing Groups:
here are several group management tools available in Linux. Here are
T
a few examples with their respective outputs.
Tar command:
o view the current user’s crontab file, you can use the following
T
command “crontab-1”.