0% found this document useful (0 votes)
27 views36 pages

Linux Mayank Jaiswal 2

Uploaded by

gotunamdevj11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views36 pages

Linux Mayank Jaiswal 2

Uploaded by

gotunamdevj11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

Swami Vivekanand College of Engineering

Indore
Department of Information Technology

Session: Jan-June 2023


LAB MANUAL
Session: IV
Open Source Software Lab (Linux and R)
IT – 407

Submitted To Submitted By
Ms. Anjali Kayat Mayank Jaiswal
Assistant Professor 0822IT211028
Department’s Vision and Mission

Vision: To achieve global standard in quality of education, research & development in


Information Technology by adapting to the rapid technological advancement to
empowering the IT-industry with the wings of knowledge and power of innovation though
knowledge creation, acquisition and dissemination for the benefit of Society and
Humanity.

Mission:
M1: To provide students with Innovative and research skills, which is need of the hour for
technical students.
M2: To impart knowledge to the students of Information Technology with relevant core
and practical knowledge inculcating real time experience in the promising field of
computing.
M3: To prepare the graduates to meet information technology challenges with a blend of
social, human, ethical and value based education.
M4: To engage in emerging research areas and establishing leadership.
M5: To contribute to the community services at large as well as catering to socio-
economic goals in local and national levels.
PROGRAM OUTCOMES (POs)
PO1. Engineering knowledge: Apply the knowledge of mathematics, science, engineering fundamentals,
and an engineering specialization to the solution of complex engineering problems.
PO2. Problem analysis: Identify, formulate, research literature, and analyze complex engineering
problems reaching substantiated conclusions using first principles of mathematics, natural sciences, and
engineering sciences.
PO3.Design/development of solutions: Design solutions for complex engineering problems and design
system components or processes that meet the specified needs with appropriate consideration for the
public health and safety, and the cultural, societal, and environmental considerations.
PO4. Conduct investigations of complex problems: Use research-based knowledge and research methods
including design of experiments, analysis and interpretation of data, and synthesis of the information to
provide valid conclusions.
PO5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools including prediction and modeling to complex engineering activities with an
understanding of the limitations.
PO6. The engineer and society: Apply reasoning informed by the contextual knowledge to assess societal,
health, safety, legal and cultural issues and the consequent responsibilities relevant to the professional
engineering practice.
PO7. Environment and sustainability: Understand the impact of the professional engineering
solutions in societal and environmental contexts, and demonstrate the knowledge of, and need for
sustainable development.
PO8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of
the engineering practice.
PO9. Individual and team work: Function effectively as an individual, and as a member or leader in
diverse teams, and in multidisciplinary settings.
PO10. Communication: Communicate effectively on complex engineering activities with the
engineering community and with society at large, such as, being able to comprehend and write effective
reports and design documentation, make effective presentations, and give and receive clear instructions.
PO11. Project management and finance: Demonstrate knowledge and understanding of the engineering
and management principles and apply these to one’s own work, as a member and leader in a team, to
manage projects and in multidisciplinary environments.
PO12. Life-long learning: Recognize the need for, and have the preparation and ability to engage in
independent and life-long learning in the broadest context of technological change .
PROGRAM EDUCATION OBJECTIVES (PEOs)

PEO-I: Meet Market Demands: To prepare students to become a successful engineer to


meet the demand driven needs of industries/technical profession.

PEO-II: Core Competence: Graduates will demonstrate core competence in


mathematical, scientific and basic engineering fundamentals necessary to formulate,
analyze and solve engineering problems and also to pursue advanced study or research.

PEO-III: Design and Analysis : Graduates will demonstrate good breadth of knowledge
in core areas of Information Technology and related engineering so as to comprehend
engineering trade-offs, analyze, design, and synthesize data and technical concepts to
create novel designs in solving the real life problems.

PEO-IV: Professional Responsibility : Graduates will demonstrate professional


responsibility by offering a wide spectrum of consultancy and testing services by
addressing social, cultural, economic, sustainability, and environmental considerations in
the solution of real world engineering problems.

PEO-V: Life-long learning: Graduates will engage themselves in life-long learning


through independent study and by participating in professional activities or continuing
education .
Course Outcomes (CO)

After the completion of this course, the students will be able to:

CO 1. Understand the basic commands used in Linux operating system

CO 2. Learn the important Linux/UNIX library functions and system calls

CO 3. Write, compile and debug shell script in Linux environment

CO 4. Learn how to program in R and write R functions

CO 5. Read data into R, access R packages


INDEX

S. Date of Date of
Name of Experiment Experiment Submission
Signature Remark
NO
Installation of Linux OS using
1. CD,DVD,USB drive.

Execution of various file and


2 directory handling command.

Study & use of command for


performing arithmetic operation
3 with Linux.

Create a file called wlcc.txt with


some lines and display how many
4 lines, words and characters are
present in that file.

Give two files each of which


contains name of students. Create a
5 program to display only those names
that are found on both the files.

Study & use of the command for


6 changing the permission.

Execute shell command through vi


7 editor.

Write a shell script that accepts any


no. of arguments and prints them in
8
reverse.

Write a shell script to find the


smallest of three no. that are read
9 from the keyboard.

Write a shell script that report the


logging in of a specified user
within one minute after he/she logs
in. The script automatically
10
terminates if the specified user does
not login during a specified period
of time.
Experiment No. 01

Aim: - Installation of Linux OS is using CD, DVD, and USB drive.


Tools Required: - Linux operating system (any flavor) CD/DVD/USB.
Objective: - To learn installation of Linux operating system.
Theory:
1. Boot your system with Opens USE 12.3 installation media i.e. CD/DVD or ISO image.

2. Choose installation options to install opens USE 12.3 on you system. Please select openSUSE 12.3
GNOME Live options to test it, before installation.

3. Loading Linux kernel.


4. Welcome screen, from where we can select Language and keyboard layout. Read license agreement
and proceed further installation once agreed.

5. Clock and time zone settings.


6. Please click on change if you want custom setting of date and time. You can change it manually or
Sync with NTP Server as show below. Click Accept once done.

7. File system partitioning. We opted default file system partition. You may choose manual file system
partitioning as options provided.

8. Create new user and its password. Uncheck all three options. Click on change to select authentication
method.
9. Please select authentication method and click on Accept.

10. Set root user password and click on Next.


11. Verify settings, you may change settings after clicking on headlines or click on Change button. Once
click on Install.

12. Installation confirmation. Click on Install to proceed.


13. Performing installation. Creating volume and formatting file system for installation. Sit back and
relax… This may take several times.

14. Installation completed, remove installation media and click on Reboot Now.
15. Post installation.

16. Login screen. Supply password for user created during installation.
17. OpenSUSE 12.3 Desktop. OpenSuse

Conclusion: - Hence we have implemented installation of Linux operating system.


Experiment: -2

Question: 2) Execution of various file/directory handling commands.

TOOLS: UNIX operating system/any flavor of Linux.

STANDARD PROCEDURE:

Analyzing the Problem:

 Start the Linux and enter the user name and password.
 Now write startx and after that open the terminal.
 At the terminal try the different commands and see the output.

Designing the Solution:


 At the terminal first perform the command without and with the different
Options available for it.

The exercises in this lab cover the usage of some of the most basic system
utilities that users and administrators alike need to be familiar with. Most of the
commands are used in navigating and manipulating the file system.The file
system is made up of files and directories.

THEORY:

1) pwd COMMAND:
pwd - Print Working Directory. pwd command prints the full filename of
the current working directory.

SYNTAX:
The Syntax is
pwd [options]

2) cd COMMAND:
cd command is used to change the directory.

SYNTAX:
The Syntax is
cd [directory | ~ | ./ | ../ | - ]
ls COMMAND:
ls command lists the files and directories under current working directory.

SYNTAX:
The Syntax is
ls [OPTIONS]... [FILE]

OPTIONS:

-l Lists all the files, directories and their mode, Number of links,
owner of the file, file size, Modified date and time and filename.
-t Lists in order of last modification time.
-a Lists all entries including hidden files.
-d Lists directory files instead of contents.
-p Puts slash at the end of each directories.
-u List in order of last access time.
-i Display inode information.

3) rm COMMAND:
rm linux command is used to remove/delete the file from the directory.

SYNTAX:
The Syntax is
rm [options..] [file | directory]
OPTIONS:

-f Remove all files in a directory without prompting the user.

-i Interactive. With this option, rm prompts for confirmation before


removing any files.

4) mv COMMAND:
mv command which is short for move. It is used to move/rename file
from one directory to another. mv command is different from cp command as
it completely removes the file from the source and moves to the directory
specified, where cp command just copies the content from one file to another.
SYNTAX:
The Syntax is
mv [-f] [-i] oldname newname

OPTIONS:

-f This will not prompt before overwriting (equivalent to --


reply=yes). mv -f will move the file(s) without prompting evenif
it is writing over an existing target.
-i Prompts before overwriting another file.

5) cat COMMAND:
cat linux command concatenates files and print it on the standard output.

SYNTAX:
The Syntax is
cat [OPTIONS] [FILE]...

OPTIONS:

-A Show all.
-b Omits line numbers for blank space in the output.
-E Displays a $ (dollar sign) at the end of each line.
-n Line numbers for all the output lines.

6) cmp COMMAND:
cmp linux command compares two files and tells you which line numbers are
different.

SYNTAX:
The Syntax is
cmp [options..] file1 file2

OPTIONS:

-c Output differing bytes as characters.

-l Print the byte number (decimal) and the differing byte values
(octal) for each difference.
-s Prints nothing for differing files, return exit status only.
7) cp COMMAND:
cp command copy files from one location to another. If the destination
is an existing file, then the file is overwritten; if the destination isan existing
directory, the file is copied into the directory (the directory is notoverwritten).

SYNTAX:
The Syntax is

cp [OPTIONS]... SOURCE DEST

10) echo COMMAND:


echo command prints the given input string to standard output.

SYNTAX:
The Syntax is
echo [options..] [string]

11)mkdir COMMAND:
mkdir command is used to create one or more directories.

SYNTAX:
The Syntax is
mkdir [options] directories

OPTIONS:

-m Set the access mode for the new directories.


-p Create intervening parent directories if they don't exist.
-v Print help message for each directory created.

12) paste COMMAND:


paste command is used to paste the content from one file to another file. It isalso
used to set column format for each line.

SYNTAX:
The Syntax is
paste [options]

OPTIONS:

-s Paste one file at a time instead of in parallel.


13) rmdir COMMAND:
rmdir command is used to delete/remove a directory and its subdirectories.

SYNTAX:
The Syntax is
rmdir [options..] Directory

OPTIONS:

-P Allow users to remove the directory dir name and its parent
directories which become empty.
Experiment : -3

Question :3 ) Study and use of command for performing arithmetic operation with linux.

THEORY:

There are various operators supported by each shell. Our tutorial is based on default
shell (Bourne) so we are going to cover all the important Bourne Shelloperators in
the tutorial.
There are following operators which we are going to discuss:
Arithmetic Operators.
Logical Operators.
String operators.
File operators
Relational operators.
But in this section we are only concentrating on only arithmetic operators

Arithmetic Operators:

There are following arithmetic operators supported by Bourne Shell.

Assume variable a holds 10 and variable b holds 20 then:

Operator Description Example


+ Addition - Adds values on either side `expr $a + $b` will give 30
of the operator
Operator Description Example
- Subtraction - Subtracts right hand `expr $a - $b` will give -10
operand from left hand operand
* Multiplication - Multiplies values on `expr $a * $b` will give 200
either side of the operator
/ Division - Divides left hand operand `expr $b / $a` will give 2
by right hand operand
% Modulus - Divides left hand operand `expr $b % $a` will give 0
by right hand operand and returns
remainder

= Assignment - Assign right operand in a=$b would assign value of b


left operand into a
== Equality - Compares two numbers, if [ $a == $b ] would return
both are same then returns true. false.
!= Not Equality - Compares two numbers, [ $a != $b ] would return true.
if both are different then returns true.

Here's an example of performing arithmetic operations in R language on Linux:

1. Open a text editor and create a new file. Let's name it `arithmetic_operations.R`.

2. In the file, you can write your arithmetic operations using R syntax. Here are a few examples:

3. Save the file (`arithmetic_operations.R`).

4. Open the terminal and navigate to the directory where the `arithmetic_operations.R` file is
located.
5. Execute the R script using the command `Rscript arithmetic_operations.R`. This will run the
script in the R interpreter and display the results in the terminal.

The script will perform the arithmetic operations you specified and print the results in the
terminal. You can modify the arithmetic expressions or add more operations as per your
requirements.
Experiment : -4

Question :4) To create a file called "cc.txt" with some lines and display the number of lines,
words, and characters present in that file, you can follow these steps:

1. Open a text editor or a terminal window.

2. Create a new file named "cc.txt" and add some lines of text. For example, you can use the
following lines:

This is line 1.
This is line 2.
This is line 3.

3. Save the file as "cc.txt" in a directory of your choice. Make sure to note down the file's
location.

4. Open a terminal window and navigate to the directory where the "cc.txt" file is located using
the `cd` command. For example, if the file is in the "Documents" directory, you can use the
following command:

5. Once you are in the correct directory, you can use the following command to display the
number of lines, words, and characters in the file:
The `wc` command is used to count lines, words, and characters in a file. By providing the
filename (`cc.txt` in this case) as an argument to the `wc` command, it will display the line
count, word count, and character count for that file.

6. After running the `wc` command, you will see the output that includes the number of lines,
words, and characters in the "cc.txt" file:

The output is separated by spaces, where the first number represents the number of lines, the
second number represents the number of words, the third number represents the number of
characters, and the last part is the filename.

That's it! You have created the "cc.txt" file, and you have displayed the number of lines, words,
and characters present in the file using the `wc` command.
Experiment : -5

Question :5) Give two files each of which contain name of student . create a program to only
those names that are found on both the files .

1. Create two text files, let's name them `file1.txt` and `file2.txt`, and populate them with names.
Each name should be on a separate line.

`file1.txt`:

`file2.txt`:

2. Open a text editor and create a new file. Let's name it `find_common_names.R`.

3. In the file, write the R code to read the contents of the two files, compare the names, and find
the common names.
4. Save the file (`find_common_names.R`).

5. Open the terminal and navigate to the directory where the `find_common_names.R` file and
the two text files (`file1.txt` and `file2.txt`) are located.

6. Execute the R script using the command `Rscript find_common_names.R`. This will run the
script in the R interpreter and display the common names in the terminal.

The program reads the contents of both files, compares them, and prints the common names
found in both files. In this example, the names "Alice" and "David" are present in both `file1.txt`
and `file2.txt`. You can modify the file names and their contents as needed for your specific use
case.
Experiment: -6

Question: 6) Study and use of command for changing the permission in Linux .

In Linux, the "chmod" command is used to change the permissions of files and directories. The
"chmod" command allows you to modify the read (r), write (w), and execute (x) permissions for
the owner, group, and others.

The basic syntax of the "chmod" command is as follows:

Here are some commonly used options and examples for changing permissions:

1. Change permissions using numeric mode:


- Numeric mode allows you to specify permissions using numbers.
- Each permission has a numeric value: read (4), write (2), and execute (1).
- The sum of these values represents the desired permission setting.
- Example: To set read and write permissions for the owner, read-only permissions for the
group, and no permissions for others, you can use the command:

This sets the permissions to 640 (-rw-r ---- ).

2. Change permissions using symbolic mode:


3. - Symbolic mode allows you to use symbols (+, -, =) to modify permissions.
- Use letters to represent the permission type: owner (u), group (g), others (o), all (a).
- Use symbols (+, -, =) to add, remove, or set permissions respectively.
- Example: To add execute permission for the owner and group, and remove write permission
for others, you can use the command:

This adds execute permission for the owner and group (+x) and removes write permission
for others (-w).

4. Recursive mode:
- The "-R" option allows you to change permissions recursively on directories and their
contents.
- Example: To change the permissions of a directory and all its files and subdirectories, you
can use the command:

This sets the permissions to 755 (rwxr-xr-x) for the directory and all its contents.

It's important to note that changing permissions can affect the security and functionality of files
and directories. It's recommended to understand the implications and use caution when
modifying permissions.
Experiment No.07
Aim:- Execute shell command through vi editor.
The vi editor is also known as visual editor. It is user-friendly and works same on different
platforms. The vi editor
tool is an interactive tool as it displays changes made in the file on the screen while you edit the
file.In vi editor
you can insert, edit or remove a word as cursor moves throughout the file.

Note : The vi editor is case-sensitive


The vi editor has two modes:
• Command Mode: In command mode, actions are taken on the file. The vi editor starts in
command mode. Here, the
typed words will act as commands in vi editor. To pass a command, you need to be in command
mode.
• Insert Mode: In insert mode, entered text will be inserted into the file. The Esc key will take you
to the
command mode from insert mode.
By default, the vi editor starts in command mode. To enter text, you have to be in insert mode, just
type 'i' and
you'll be in insert mode. Now you can type anything. To exit from insert mode press Esc key, you'll
be directed to
Command mode.
Syntax :- vi filename

In the terminal when you'll type vi command with a file name, the content of the file will be
displayed. If there is
no such file, then a new file will be created .
Example
we are creating a new file f.txt as this file doesn't exist and have entered the full path for the
directory Documents.
vi /home/cloudera/Documents/f.txt
Command mode : by default vi editor is in command mode.S
Insert mode: To be in insert mode we need to press “ i ”
Commands Action

:wq Save and quite

:w Save

:q Quite

:w fname Save as fname

ZZ Save and quit

:q! Quit discarding change made

:w! Save (and write to non-writable file)

press escape (esc ) and then :wq will save and quit the vi editor. When you'll type it in command mode,
it will automatically come at bottom left corner. If you want to quit without saving the file, use :q

File is modified and hence on typing :q file can be saved with the command.
“!q” It discards the changes made in the file and save it.
Example : let create a program file named as “abc.sh”.then write a program in it and then save it by
pressing “esc :wq!”.then run the program by passing “sh abc.sh” command to terminal.
Experiment: -8

Question: 8) Write a shell script that accepts any number of argument and print them in the
reverse.

Save the script with a desired name, such as "reverse.sh". Make sure to give it execute
permissions using the following command:

You can then run the script by providing any number of arguments. For example:
The script will print the arguments in reverse order:

The script uses a loop to iterate through the arguments array in reverse order, starting from the
last element. It then echoes each argument, printing them in reverse order.
Experiment: -9

Aim :-Write a shell script to find the smallest of three no. that are read from the keyboard.

Program 1
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
Program 2
echo "enter a: "
read a
echo "enter b: "
read b
echo "enter c: "
read c
if [ $a -le $b -a $a -le $c ]
then
echo "a is Smallest"
elif [ $b -le $c -a $b -le $a ]
then
echo "b is Smallest"
else
echo "c is Smallest"
fi

Output
Experiment No.10

Aim: - Write a shell script that report 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.

echo "Enter user name "


read name
echo "Enter min"
read min
period=0
until who | grep -w "$name" > /dev/null
do

echo " user not loged in yet"

done
echo "he is there"

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy