Professional Documents
Culture Documents
Lab Manual
Student Name……………………………..
Enrollment No…………………………….
Faculty Incharge
Kamaljeet Singh kalsi
CSE, GGCT
Session: 2021-22
INDEX
S.NO NAME OF PRACTICAL DATE PAGE NO. REMARKS
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
Practical No-1
$man cd
Command: history
History command shows all the commands that you have used in the past for the
current terminal session. This can help you refer to the old commands you have
entered and re-used them in your operations again.
$history
Command: clear
to clear the screen.
$clear
Command: date
to see the system’s date.
$date
Command: time
to see the system’s time.
$time
Command: cal
It is used to see the calendar of any specific month, or a complete year.
$cal 11 2018
will show the calendar of Nov 2018.
Command: who
It is used to see the details of various users who are currently log in.
$who
Command: ps
It is used to see various process running at a terminal.
$ps
Command: pwd
It is used to see the present working directory.
$pwd
Practical No-2
AIM- Study & use of commands for performing arithmetic operations with Unix/Linux.
Theory- The Bourne shell didn't originally have any mechanism to perform simple arithmetic but it uses
external programs, either awk or the must simpler program expr.
Here is simple example to add two numbers −
#!/bin/sh
val=`expr 2 + 2`
echo "Total value : $val"
This would produce following result −
Total value : 4
There are following points to note down −
There must be spaces between operators and expressions for example 2+2 is not correct, where as it
should be written as 2 + 2.
Complete expression should be enclosed between ``, called inverted commas.
There are following arithmetic operators which we are going to discuss –
There are following arithmetic operators supported by Bourne Shell.
Assume variable a holds 10 and variable b holds 20 then −
Show Examples
Operator Description Example
+ Addition - Adds values on either side of the `expr $a + $b` will give 30
operator
- Subtraction - Subtracts right hand operand from `expr $a - $b` will give -10
left hand operand
* Multiplication - Multiplies values on either side `expr $a \* $b` will give 200
of the operator
/ Division - Divides left hand operand by right `expr $b / $a` will give 2
hand operand
% Modulus - Divides left hand operand by right `expr $b % $a` will give 0
hand operand and returns remainder
= Assignment - Assign right operand in left a=$b would assign value of b into a
operand
AIM- Create a file called wlcc.txt with some lines and display how many lines, words and characters are
present in that file.
STEP : 2). Go to the shell prompt and type command wc to view the number of
Lines, Words and Characters.
Practical No-4
AIM- Append ten more simple lines to the wlcc.txt file created above and split the appended file into 3
parts. What will be the names of these split files? Display the contents of each of these files. How many
lines will be there on the last file?
AIM- Given two files each of which contains names of students. Create a program to display only those names that are
found on both the files.
Theory-
Where-
-1 : suppress lines unique to FILE1
-2 : suppress lines unique to FILE2
-3 : suppress lines that appear in both files
Practical No-6
AIM- Create a program to find out the inode number of any desired file.
Theory- Use the ls command with -i option to view the file inode number. The inode number of the file
will be shown in the first field of the output.
The inode stands for index node or index number is a data structure in a Linux file system that stores
information about a file and directory.
File systems in general have two parts, those are metadata and actual data.
Each file has an inode containing metadata about the file. Each file in a filesystem has a unique inode
number. Inode numbers are guaranteed to be unique only within a filesystem.
You may get the following error when inode is full on the file system. No space left on device or running
out of Inodes.
Inode stores the following information about a file.
Size of the file.
Device ID
User ID (UID)
Group ID (GID)
Practical No-7
AIM- Study & use of the Command for changing file permissions.
Procedure :
In the diagram below, we see how the first portion of the listing is interpreted. It consists of a
character indicating the file type, followed by three sets of three characters that convey the
reading, writing and execution permission for the owner, group, and everybody else.
chmod
The chmod command is used to change the permissions of a file or directory. To use it, you
specify the desired permission settings and the file or files that you wish to modify. There are
two ways to specify the permissions. In this lesson we will focus on one of these, called the octal
notation method.
It is easy to think of the permission settings as a series of bits (which is how the computer thinks
about them). Here's how it works:
and so on...
Value Meaning
(rwxrwxrwx) No restrictions on permissions. Anybody may do anything. Generally not a desirable setting.
777
(rwxr-xr-x) The file's owner may read, write, and execute the file. All others may
755 read and execute the file. This setting is common for programs that are used by all
users.
(rwx------) The file's owner may read, write, and execute the file. Nobody else has
700 any rights. This setting is useful for programs that only the owner may use and
must be kept private from others.
666 (rw-rw-rw-) All users may read and write the file.
(rw-r--r--) The owner may read and write a file, while all others may only read
644 the file. A common setting for data files that everybody may read, but only the
owner may change.
(rw------) The owner may read and write a file. All others have no rights. A
600
common setting for data files that the owner wants to keep private.
Directory Permissions
The chmod command can also be used to control the access permissions for
directories. Again, we can use the octal notation to set permissions, but the
meaning of the r, w, and x attributes is different:
AIM- Write a pipeline of commands, which displays on the monitor as well as saves the information about the
number of users using the system at present on a file called usere.ux.
Theory- The novel idea of Pipes was introduced by M.D Mcllory in June 1972– version 2, 10 UNIX installations.
Piping is used to give the output of one command (written on LHS) as input to another command
(written on RHS). Commands are piped together using vertical bar “ | ” symbol.
Theory- vi editor
vi is the most useful standard text editor on your system. (vi is
short for visual editor and is pronounced "vee-eye."). UNIX has a number of editors that can process the
contents of text files, whether those files contain data, source code, or sentences. Editor (VI – editor) is
screen editors which display a part of the file on your terminal screen.
vi. This editor enable you to edit lines in context with other lines in the file.
Now a day you would find an improved version of vi editor which is called vi. Here VIM stands for vi
improved.
You can use vi editor to edit an existing file or to create a new file from scratch. You can also use this
editor to just read a text file.
Command Description
file.
Following is the example to create a new file testfile if it already does not exist in the current
working directory −
$vi testfile
As a result you would see a screen something like as follows −
~
~
~
You will notice a tilde on each line following the cursor. A tilde represents an unused line. If a line
does not begin with a tilde and appears to be blank, there is a space, tab, newline, or some other
nonviewable character present.
So now you have opened one file to start with. Before proceeding further let us understanding few minor
but important concepts explained below.
Operation Modes
While working with vi editor you would come across following two modes −
Command mode − This mode enables you to perform administrative tasks such as saving files,
executing commands, moving the cursor, cutting yanking and pasting lines or words, and finding and
replacing. In this mode, whatever you type is interpreted as a command.
Insert mode − This mode enables you to insert text into the file. Everything that's typed in this
mode is interpreted as input and finally it is put in the file .
The vi always starts in command mode. To enter text, you must be in insert mode. To come in insert mode
you simply type i. To get out of insert mode, press the Esc key, which will put you back into command mode.
Hint − If you are not sure which mode you are in, press the Esc key twice, and then you'll be in command
mode. You open a file using vi editor and start type some characters and then come in command mode to
understand the difference.
Getting Out of vi
The command to quit out of vi is :q. Once in command mode, type colon, and 'q', followed by return. If
your file has been modified in any way, the editor will warn you of this, and not let you quit. To ignore this
message, the command to quit out of vi without saving is :q!. This lets you exit vi without saving any of
the changes.
The command to save the contents of the editor is :w. You can combine the above command with the quit
command, or :wq and return.
The easiest way to save your changes and exit out of vi is the ZZ command. When you are in
command mode, type ZZ and it will do the equivalent of :wq.
You can specify a different file name to save to by specifying the name after the :w. For example, if you
wanted to save the file you were working as another filename called filename2, you would type
:w filename2 and return. Try it once.
Command Description
K Moves the cursor up one line.
position.
The vi is case-sensitive, so you need to pay special attention to capitalization when using commands.
Most commands in vi can be prefaced by the number of times you want the action to occur. For
example, 2j moves cursor two lines down the cursor location.
There are many other ways to move within a file in vi. Remember that you must be in command mode
pressEsctwice. Here are some more commands you can use to move around the file −
Command Description
Fc Move forward to c
Fc Move back to c
represented by x
Editing Files
To edit the file, you need to be in the insert mode. There are many ways to enter insert mode from the
command mode –
Command Description
location.
Deleting Characters
Here is the list of important commands which can be used to delete characters and
lines in an opened file.
Command Description
line.
Command Description
Yw Copies the current word from the character the lowercase w cursor is
Theory-
1. Download the Linux distribution of your choice. If you're new to Linux, consider trying a lightweight and
easy to use distribution, such as Ubuntu or Linux Mint. Linux distributions (known as "distros") are typically
available for free to download in ISO format. You can find the ISO for the distribution of your choice at the
distribution’s website. This format needs to be burned to a CD or USB stick before you can use it to install
Linux. This will create a Live CD or Live USB.
A Live CD or Live USB is a disk that you can boot into, and often contains a preview version
of the operating system that can be run directly from the CD or USB stick.
Install an image burning program, or use your system’s built-in burning tool if you are using
Windows 7, 8, or Mac OS X. Pen Drive Linux and UNetBootin are two popular tools for
burning ISO files to USB sticks.
2. Boot into the Live CD or Live USB. Most computers are set to boot into the hard drive first, which means you
will need to change some settings to boot from your newly-burned CD or USB. Start by rebooting the computer.
Once the computer reboots, press the key used to enter the boot menu. The key for your system
will be displayed on the same screen as the manufacturer’s logo. Typical keys include F12, F2,
or Del.
For Windows 8 users, hold the Shift key and click restart. This will load the Advanced Startup
Options, where you can boot from CD.
For Windows 10 users, go to advanced boot in settings and click "Restart Now."
If your computer doesn't give you direct access to the boot menu from the manufacturer's
splash screen, it's most likely hidden in the BIOS menu. You can access the BIOS menu in the
same way that you would get to the boot menu. At the manufacturer splash screen, the key
should be listed in one of the bottom corners.
Once you're in the boot menu, select your live CD or USB. Once you’ve changed the settings,
save and exit the BIOS setup or boot menu. Your computer will continue with the boot process.
Practical No-11
AIM- Write a shell script that accepts any number of arguments and prints them in the reverse order.
Shell Script-
a=$#
x=$*
c=$a
res=''
while [ 1 -le $c ]
do
c=`expr $c - 1`
shift $c
res=$res' '$1
set $x
done
AIM- Write a shell script to find the smallest of three numbers that are read from the keyboard.
Shell Script-
echo "enter a: "
read a
echo "enter b : "
read b
echo "enter c : "
read c
s=$a
if [ $b -lt $s ]
then
s=$b
fi
if [ $c -lt $s ]
then
s=$c
fi
echo Smallest of $a $b $c is $s
OUTPUT-
Practical No-13
AIM- Write a shell script that reports the logging in of a specified user within one minute after he/she
logs in. The script automatically terminates if the specified user does not login during a specified period
of time.
Shell Script-
a=`date +%M`
b=`expr $a + 1`
while [ $b -gt `date +%M` ]
do
who | grep $1
if [ $? -eq 0 ]
then
echo "$1 has logged in 1 minute"
exit
fi
done
echo "$1 has not looged in within 1 minute"
Practical No-14
You can install Apache anywhere, such as a portable USB drive (useful for client demonstrations).
1. In the left-hand Download menu, click the latest available Tomcat version.
2. Locate the Binary Distributions area and in the Core list click on the ZIP file corresponding to the required Windows version.
3. Save the ZIP file in a temporary directory.
4. Unpack the downloaded ZIP file into the target folder on the computer.
Practical No-15
Theory-
Implementation of DNS: DNS is a host name to IP address translation service. DNS is a distributed database implemented
in a hierarchy of name servers. It is an application layer protocol for message exchange between clients and servers.
Requirement
Every host is identified by the IP address but remembering numbers is very difficult for the people and also the IP addresses are not static
therefore a mapping is required to change the domain name to IP address. So DNS is used to convert the domain name of the websites to their
numerical IP address.
Domain :
There are various kinds of DOMAIN :
1. Generic domain : .com(commercial) .edu(educational) .mil(military) .org(non profit organization) .net(similar to commercial) all these are
generic domain.
2. Country domain .in (india) .us .uk
3. Inverse domain if we want to know what is the domain name of the website. Ip to domain name mapping.So DNS can provide both the
mapping for example to find the ip addresses of geeksforgeeks.org then we have to type nslookup
It is Very difficult to find out the ip address associated to a website because there are millions of websites and with all those websites we
should be able to generate the ip address immediately.
LDAP Services:
Linux provides both server-side and client-side support for the Lightweight Directory Access Protocol (LDAP) facility. This is a standards-based
facility, so it is compatible with other LDAP implementations, including Microsoft’s Active Directory. Data suitable for a directory service has
low volatility as LDAP is optimized for read-mostly access; database systems are tailored for more volatile data. A classic example of data
suitable for directory services is the ordinary telephone directory.
LDAP content is organized according to a data definition language, or schema. Standard schema are available but customized schema are also
possible. Much of the value of using LDAP is to consolidate corporate information about resources, such as login passwords, to centralize
administration efforts.
The Linux LDAP implementation has two main components: slapd, a stand-alone LDAP daemon, and slurpd, a stand-
alone LDAP replication daemon. The two daemons work cooperatively, slapd maintaining the local LDAP information and slurpd
replicating these changes to additional LDAP directories.
Practical No-16
Theory-
Installation of Firewall:-
Setting Up a Firewall:
1. Set up system and security settings. From the Start menu, click Control Panel, then click System and Security. ...
2. Select program features. Click Turn Windows Firewall on or off from the left side menu. ...
3. Choose firewall settings for different network location types.
1. Open Settings.
2. Click Network & Internet. ...
3. Click Proxy. ...
4. In the Manual Proxy Setup section, set the Use a Proxy Server switch to On.
5. In the Address field, type the IP address.
6. In the Port field, type the port.
7. Click Save; then close the Settings window.