Uploaded by 1238 Vaishnavi Hande

Operating System

advertisement
MAHARASHTRA STATE BOARD OF
TECHNICAL EDUCATION
NAVJEEVAN EDUCATION SOCIETY
POLYTECHNIC
MICRO PROJECT
Academic year: 2023-24
TITLE OF MICRO PROJECT
Prepare Help Guide Using Shell Script For
All The Major Linux Commands
Program:
Program code:
Course:
Course code:
Computer Engineering.
CO5I
Operating System.
22516
Operating System(22516)
Prepare Help Guide Using Shell Script For All The Major
Linux Commands
NAVJEEVAN POLYTECHNIC BHANDUP[W]
GROUP DETAILS:Sr.no Name of Team
Members
1.
Jyoti Das
2.
Dhruv Kasar
3.
Sanjog Salunke
Roll no Enrollment No
1328
1312
1239
2101440174
2101440158
2101440188
HELPED AND GUIDED BY
Miss. Reema Kadam.
Seat No
120770
120754
120781
Brief introduction:
The Shell is the command interpreter on Linux systems. This
document intoduces some of the basic features of the Shell and lists
many of the commands or programs available on the Linux computers
in Cardiff School of Computer Science & Informatics. The Shell is
the command interpreter on Linux systems. This document intoduces
some of the basic features of the Shell and lists many of the
commands or programs available on the Linux computers in Cardiff
School of Computer Science & Informatics.
Aims of micro-project:
1. To Understand concept of shell scripting.
2. To study about linux commands.
Resources Required:
S.NO
Name Of
Resources/material
Specifications
Qty
1
Computer
System
Operating System:
Windows 7 or higher.
Memory: 8 GB
RAM.Processor: Core
i3. HDD: 500GB or
Larger.
1
2
Software
Unix/Ubuntu/Linux
1
Weekly Progress Report (Action Plan) Micro-Project:Topic: Prepare Help Guide Using Shell Script For All The MajorLinux
Commands.
Academic Year: 2023-24
Name of Faculty: Miss. Reema kadam
Program Code: Computer Engg (CO5I).
Course & Course Code: Operating System (22516).
Roll No: 1328,1312,1339
Enrollment No: 2101440174,2101440188,2101440158
Semester: V
Name of Candidate Jyoti Das,Sanjog Salunke,Dhruv kasar
Sr.no
1.
2.
3.
4.
5.
6.
7.
Week
Activity of Performed
Planned
Planned Name of
start Date Finish Date Responsible
Team member
Jyoti,
Discussion and finalization
Dhruv,
of topic
1st
Sanjog.
Jyoti,
2nd Preparation and submission
Dhruv,
of
Sanjog.
Abstract
Jyoti,
3th
Collection of Data
Dhruv,
Sanjog.
Jyoti,
4th
Implementation
Dhruv,
Sanjog.
Jyoti,
5th
Check, Validation and
Dhruv,
Execution of code
Sanjog.
Jyoti,
Compilation of Report And
Dhruv,
6th Presentation
Sanjog.
Jyoti,
7th Actual Presentation & Final
Dhruv,
submission of Micro Project
Sanjog.
Sign of students:-
1) Jyoti Das(1328)
2) Dhruv kasar (1312)
3) Sanjog salunke (1339)
Sign of Faculty
(Miss reema kadam)
-: INDEX :Academic Year: 2023-2024
Name of Faculty: Miss. Reema kadam
Program Code: Computer engg (CO5I).
Course & Course Code: Operating System (22516).
Roll No: 1328,1312,1339
Enrollment No: 2101440174,2101440158,2101440188
Semester: V
SR.NO
Name of Candidate: Jyoti,Dhruv,Sanjog
CONTENT
PAGE NO
1.
Brief Description
1
2.
Aim of the Micro-Project
1
3.
Course Outcomes Integrated
1
4.
Actual Procedure Followed
2
5.
Actual Resources Used
2
6.
Skill Developed/learning out of this
Micro Project
8
7.
Implementation and Result
8
8.
Conclusion
8
9.
Teacher Evaluation Sheet
9 to 11
10.
Annexure II
12
Prepare Help Guide Using Shell Script For All The Major
Linux Commands
Brief Description:
The Shell is the command interpreter on Linux systems. This
document introduces some of the basic features of the Shell and lists
many of the commands or programs available on the Linux computers
in Cardiff School of Computer Science & Informatics.
The Linux command interpreter or shell is the program users interact
with in a terminal emulation window. The terminal emulation window
can be one in the workstation's Graphical User Interface mateterminal on Linux. Alternatively, it can be an application such as SSH
secure shell client or PuTTY on a Windows PC that's logged into
Linux over the network. A shell script is a list of commands in a
computer program that is run by the Unix shell which is a command
line interpreter. A shell script usually has comments that describe the
steps. The different operations performed by shell scripts are program
execution, file manipulation and text printing. A wrapper is also a
kind of shell script that creates the program environment, runs the
program etc.
Types of Shells:
There are two major types of shells in Unix:
1. Bourne Shell
2. C Shell
Aims of micro-project:
1. To Understand concept of shell scripting.
2. To study about linux commands.
Course outcomes integrated:
1. Install linux operating system and configure it.
2. Use operating system tools to perform various functions.
3. Execute commands for performing operation.
Resources Required:
S.NO
Name Of
Resources/material
1
Computer
System
2
Software
Specifications
Operating System: Windows
7 or higher.
Memory: 8 GB
RAM.Processor: Core i3.
HDD: 500GB or Larger.
Unix/Ubuntu/Linux
Qty
1
1
Implementation and Result:
What is Linux?
Linux is an operating system based on UNIX and was first introduced
by Linus Torvalds. It is based on the Linux Kernel and can run on
different hardware platforms manufactured by Intel, MIPS, HP, IBM,
SPARC, and Motorola. Another popular element in Linux is its
mascot, a penguin figure named Tux.
Linux Operating System
CLI (Command Line Interface) and GUI (Graphic User Interface)
Linux actually means the kernel of the system, which is the sole
controller of whatever happens on the computer system. When we
talk or say that x “runs Linux” we usually refer to the system kernel
and set of the tools that are used with it. Each of the present
components will be checked so that we understand exactly what
functions each does.
The Linux based kernel can run a wide variety of software across
many different hardware-based platforms. A computer can act as a
server, which means it primarily handles data on other’s behalf or can
act like a desktop, which means a user will be interacting with it
directly. The system can run software or it can be used as a
development PC in the process of creating any software. Linux can
perform multiple roles as there is no special allocation to Linux about
the role of the system; it’s only a matter of configuring the present
applications and how do they execute.
Command Line Interface (CLI):
The Command Line Interface (CLI), is a non-graphical, text-based
interface to the computer system, where the user types in a command
and the computer then successfully executes it. The Terminal is the
platform or the IDE that provides the command line interface (CLI)
environment to the user.
What is the difference between UNIX and LINUX?
“Linux” originates from the Linux kernel. It is open-source and free
to use the operating system. It is used for computer hardware and
software, game development, mainframes, etc. It can run various
client programs. Unix is a portable, multi-tasking, a multi-user
operating system developed by AT&T. It started as a one-man venture
under the initiative of Ken Thompson of Bell Labs. It proceeded to
turn out to become the most widely used operating systems. It is used
in web servers, workstations, and PCs. Many business applications
are accessible in it.
What Is The Shell?
When we speak of the command line, we are really referring to the
shell. The shell is a program that takes keyboard commands and
passes them to the operating system to carry out. Almost all Linux
distributions supply a shell program from the GNU Project called
bash. The name “bash” is an acronym for “Bourne Again SHell”, a
reference to the fact bash is an enhanced replacement for sh, the
original Unix shell program written by Steve Bourne.
An Operating is made of many components, but its two prime
components are –
• Kernel
• Shell
A Kernel is at the nucleus of a computer. It makes the communication
between the hardware and software possible. While the Kernel is the
innermost part of an operating system, a shell is the outermost one. A
shell in a Linux operating system takes input from you in the form of
commands, processes it, and then gives an output. It is the interface
through which a user works on the programs, commands, and scripts.
A shell is accessed by a terminal which runs it. When you run the
terminal, the Shell issues a command prompt (usually $), where you
can type your input, which is then executed when you hit the Enter
key. The output or the result is thereafter displayed on the terminal.
The Shell wraps around the delicate interior of an Operating system
protecting it from accidental damage. Hence the name Shell.
Types of Shell
There are two main shells in Linux:
1. The Bourne Shell: The prompt for this shell is $ and its derivatives
are listed below:
• POSIX shell also is known as sh
• Korn Shell also knew as sh
• Bourne Again SHell also knew as bash (most popular)
2. The C shell: The prompt for this shell is %, and its subcategories
are:
• C shell also is known as csh
• Tops C shell also is known as tcsh
What is Shell Scripting?
Shell scripting is writing a series of command for the shell to execute.
It can combine lengthy and repetitive sequences of commands into a
single and simple script, which can be stored and executed anytime.
This reduces the effort required by the end user. Let us understand the
steps in creating a Shell Script.
1. Create a file using a vi editor(or any other editor).Name script file
with extension .sh
2. Start the script with #! /bin/sh
3. Write some code.
4. Save the script file as filename.sh
5. For executing the script type bash filename.sh
Usually shells are interactive that mean, they accept command as
input from users and execute them. However some time we want to
execute a bunch of commands routinely, so we have type in all
commands each time in terminal. As shell can also take commands as
input from file we can write these commands in a file and can execute
them in shell to avoid this repetitive work. These files are called Shell
Scripts or Shell Programs.
Shell scripts are similar to the batch file in MS-DOS. Each shell script
is saved with .sh file extension eg. Myscript.sh A shell script have
syntax just like any other programming language. If you have any
prior experience with any programming language like Python, C/C++
etc it would be very easy to get started with it.
A shell script comprises following elements –
• Shell Keywords – if, else, break etc.
• Shell commands – cd, ls, echo, pwd, touch etc.
• Functions
• Control flow – if..then..else, case and shell loops etc.
Terminal Emulators:
When using a graphical user interface, we need another program
called a terminal emulator to interact with the shell. If we look
through our desktop menus, we will probably find one. KDE uses
console and GNOME uses gnome-terminal, though it’s likely called
simply “terminal” on our menu. There are a number of other terminal
emulators available for Linux, but they all basically do the same
thing; give us access to the shell. You will probably develop a
preference for one or another based on the number of bells and
whistles it has.
Your First Keystrokes:
So let’s get started. Launch the terminal emulator! Once it comes up,
we should see something like this:[me@linuxbox ~]$ This is called a
shell prompt and it will appear whenever the shell is ready to accept
input. While it may vary in appearance somewhat depending on the
distribution, it will usually include your username@machinename,
followed by the current working directory (more about that in a little
bit) and a dollar sign. If the last character of the prompt is a pound
sign (“#”) rather than a dollar sign, the terminal session has superuser
privileges. This means either we are logged in as the root user or we
selected a terminal emulator that provides superuser (administrative)
privileges.
Cursor Movement:
Recall t he previous command with the up-arrow key again. Now try
the left and right-arrow keys. See how we can position the cursor
anywhere on the command line? This makes editing commands easy.
What are Shell Variables?
As discussed earlier, Variables store data in the form of characters
and numbers. Similarly, Shell variables are used to store information
and they can by the shell only. For example, the following creates a
shell variable and then prints it: variable ="Hello" echo $variable
Below is a small script which will use a variable.
#!/bin/sh echo "what is your name?"
read name echo
"How do you do, $name?" read remark
echo "I am $remark too!"
Why do we need shell scripts:
There are many reasons to write shell scripts –
• To avoid repetitive work and automation
• System admins use shell scripting for routine backups
• System monitoring
• Adding new functionality to the shell etc.
Advantages of shell scripts:
• The command and syntax are exactly the same as those directly
entered in command line, so programmer do not need to switch to
entirely different syntax
• Writing shell scripts are much quicker
• Quick start
• Interactive debugging etc.
Disadvantages of shell scripts:
• Prone to costly errors, a single mistake can change the command
which might be harmful
• Slow execution speed
• Design flaws within the language syntax or implementation
• Not well suited for large and complex task
• Provide minimal data structure unlike other scripting languages.
Navigation:
The first thing we need to learn (besides just typing) is how to
navigate the file system on our Linux system. In this chapter we will
introduce the following commands:
1. pwd - Print name of current working directory
2. cd - Change directory
3. ls - List directory contents
Listing The Contents Of A Directory:
To list the files and directories in the current working directory, we
use the ls command.
Changing The Current Working Directory
To change your working directory (where we are standing in our treeshaped maze) we use the cd command. To do this, type cd followed
by the pathname of the desired working directory. A pathname is the
route we take along the branches of the tree to get to the directory we
want. Pathnames can be specified in one of two different ways; as
absolute pathnames or as relative pathnames. Let's deal with absolute
pathnames first. Some Helpful Shortcuts: we see some useful ways
the current working directory can be quickly changed.
Shortcut:
▪ cd Changes the working directory to your home directory.
▪ cd - Changes the working directory to the previous working
directory.
Important Facts About Filenames:
1. Filenames that begin with a period character are hidden. This only
means that ls will not list them unless you say ls -a. When your
account was created, several hidden files were placed in your home
directory to configure things for your account. Later on we will take
a closer look at some of these files to see how you can customize
your environment. In addition, some applications place their
configuration and settings files in your home directory as hidden
files.
2. Filenames and commands in Linux, like Unix, are case sensitive.
The filename“File1” and “file1” refer to different files.
Exploring The System:
Before we start however, we’re going to learn some more commands
that will be useful along the way:
1. ls – List directory contents
2. file – Determine file type
3. less – View file contents
Manipulating Files And Directories:
1. cp – Copy files and directories
2. mv – Move/rename files and directories
3. mkdir – Create directories
4. rm – Remove files and directories
File manipulation refers to a wide variety of operations which are
available and allow us to delete, copy, move, both individual files and
multiple files.
These four commands are among the most frequently used Linux
commands. They are used for manipulating both files and directories.
For example, how could we copy all the HTML files from one
directory to another, but only copy files that do not exist in the
destination directory or are newer than the versions in the destination
directory?
Permissions:
Essential part of system security and introduce the following
commands:
1. id – Display user identity
2. chmod – Change a file's mode
3. umask – Set the default file permissions
4. su – Run a shell as another user
5. sudo – Execute a command as another user
6. chown – Change a file's owner
7. chgrp – Change a file's group ownership
8. password – Change a user's password
chmod – Change File Mode
To change the mode (permissions) of a file or directory, the chmod
command is used. Be aware that only the file’s owner or the superuser
can change the mode of a file or directory. chmod supports two
distinct ways of specifying mode changes: octal number
representation, or symbolic representation. We will cover octal
number representation first.
chmod also supports a symbolic notation for specifying file modes.
Symbolic notation is divided into three parts: who the change will
affect, which operation will be performed, and what permission will
be set. To specify who is affected, a combination of the characters
“u”, “g”, “o”, and “a” is used as follows:
If no character is specified, “all” will be assumed. The operation may
be a “+” indicating that a permission is to be added, a “-” indicating
that a permission is to be taken away, or a “=” indicating that only the
specified permissions are to be applied and that all others are to be
removed. Permissions are specified with the “r”, “w”, and “x”
characters. Here are some examples of symbolic notation.
sudo –
Execute A Command As Another User The sudo command is like su
in many ways, but has some important additional capabilities. The
administrator can configure sudo to allow an ordinary user to execute
commands as a different user (usually the superuser) in a very
controlled way. In particular, a user may be restricted to one or more
specific commands and no others. Another important difference is
that the use of sudo does not require access to the superuser's
password. To authenticate using sudo, the user uses his/her own
password.
Let's say, for example,
that sudo has been configured to allow us to run a fictitious backup
program called “backup_script”, which requires superuser privileges.
chown –
Change File Owner And Group The chown command is used to
change the owner and group owner of a file or directory. Superuser
privileges are required to use this command. The syntax of chown
looks like this: chown [owner][:[group]] file... chown can change the
file owner and/or the file group owner depending on the first
argument of the command.
Changing Your Password:
The last topic we'll cover in this chapter is setting passwords for
yourself (and for other users if you have access to superuser
privileges.) To set or change a password, the passwd command is
used. The command syntax looks like this: passwd [user]
Common Shell Features:
Syntactic
;
Separates commands that should be executed sequentially.
|
Separates commands that are part of a pipeline.
&&
Runs the next command if the current command succeeds.
||
Runs the next command if the current command fails.
( \)
Groups commands to run as a separate process in a subshell.
&
Runs commands in the background.
Filename
/
Separates the parts of a file's pathname.
?
Matches any single character except a leading dot (.).
*
Matches any sequence of characters except a leading dot (.).
[]
Matches any of the enclosed characters.
\~
Specifies a home directory when used at the beginning of filenames.
Quotation
'...'
Specifies that any of the enclosed characters should be interpreted
literally; that is, without their special meaning to
the shell.
"..."
Provides a special form of quoting. Specifies that the $
(dollar sign), (grave accent), and \ (backslash) characters
keep their special meaning, while all other enclosed
characters are interpreted literally; that is, without their
special meaning to the shell. Double quotes are useful in
making variable assignments.
Input/Output
<
Redirects input.
>
Redirects output to a specified file.
<<
Redirects input and specifies that the shell should read input up to a
specified line.
>>
Redirects output and specifies that the shell should add output to the
end of a file.
>&
Redirects both diagnostic and standard output and appends them to a
file.
>>&
Redirects both diagnostic and standard output to the end of an existing
file.
>!
Redirects ouput and specifies that if the noclobber variable is set
(prevents overwriting of files); it should be ignored so that the file can
be overwritten.
Substitution
$
Specifies variable substitution.
!
Specifies history substitution.
:
Precedes substitution modifiers.
^
Used in special kinds of history substitution.
`
Specifies command substitution.
Shell scripting on other operating systems:
Interoperability software such as Cygwin, the MKS Toolkit, Interix
(which is available in the Microsoft Windows Services for UNIX),
Hamilton C shell, UWIN (AT&T Unix for Windows) and others
allow Unix shell programs to be run on machines running Windows
NT and its successors, with some loss of functionality on the MSDOS-Windows 95 branch, as well as earlier MKS Toolkit versions for
OS/2. At least three DCL implementations for Windows type
operating systems—in addition to XLNT, a multiple-use scripting
language package which is used with the command shell, Windows
Script Host and CGI programming—are available for these systems as
well. Mac OS X and subsequent are Unix- like as well. In addition to
the aforementioned tools, some POSIX and OS/2 functionality can be
used with the corresponding environmental subsystems of the
Windows NT operating system series up to Windows 2000 as well. A
third, 16-bit subsystem often called the MS-DOS subsystem uses the
Command.com provided with these operating systems to run the a
fore mentioned MS-DOS batch files.
Micro Project Evaluation Sheet
Name of Student: Jyoti Das
Enrollment No: 2101440174
Name of Programme: Computer Engineering
Semester: V.
Course Title: Operating System
Code: 22516.
Title of Micro Project: Prepare help guid using shell script for all the major linux
commands.
Course Outcomes Achieved:
1. Install Operating System and Configure it.
2. Use operating system tools for various functions.
3. Execute process commands for performing process management operations
Sr.no
Charateristic
to
be Poor(Mar Average(Ma Good(Mar Excellent(Ma Sub
assessed
ks 1-3)
rks 4 - 5)
ks 6-8 )
rks 9-10)
Total
(A)Process and Product Assessment (Convert above total marks out of 6 marks.)
1.
Relevance to the Course
2.
Literature Review
/information collection
Completion of the target
as per project proposal
Analysis of data and
representation
Quality
of
Prototype/Model
Report Preparation.
3.
4.
5.
6.
(B) Individual Presentation/Viva (Convert above marks Total Marks out of 4)
7.
Presentation
8.
Viva
(A)Process
andProduct
Assessment
(6 marks)
(B)
Individual
Presentation/Viva(4
marks)
Total Marks 10
Comments/Suggestions about team work. Leadership /inter-personal communication
…………………………………………………………………………………………
……………………………………………………………………………………….
Name and designation of the Teacher: Mrs.Rema kadam
Dated Signature ……………………………………………..
Micro Project Evaluation Sheet
Name of Student: Dhruv Kasar
Enrollment No: 2101440158
Name of Programme: Computer Engineering
Semester: V.
Course Title: Operating System
Code: 22516.
Title of Micro Project: Prepare help guid using shell script for all the major linux
commands.
Course Outcomes Achieved:
1. Install Operating System and Configure it.
2. Use operating system tools for various functions.
3. Execute process commands for performing process management operations
Sr.no
Charateristic
to
be Poor(Mar Average(Ma Good(Mar Excellent(Ma Sub
assessed
ks 1-3)
rks 4 - 5)
ks 6-8 )
rks 9-10)
Total
(A)Process and Product Assessment (Convert above total marks out of 6 marks.)
1.
Relevance to the Course
2.
Literature Review
/information collection
Completion of the target
as per project proposal
Analysis of data and
representation
Quality
of
Prototype/Model
Report Preparation.
3.
4.
5.
6.
(B) Individual Presentation/Viva (Convert above marks Total Marks out of 4)
7.
Presentation
8.
Viva
(A)Process
andProduct
Assessment
(6 marks)
(B)
Individual
Presentation/Viva(4
marks)
Total Marks 10
Comments/Suggestions about team work. Leadership /inter-personal communication
…………………………………………………………………………………………
……………………………………………………………………………………….
Name and designation of the Teacher: Mrs.Rema kadam
Signature ……………………………………………..
Micro Project Evaluation Sheet
Name of Student: Sanjog Salunke
Enrollment No: 2101440188
Name of Programme: Computer Engineering
Semester: V.
Course Title: Operating System
Code: 22516.
Title of Micro Project: Prepare help guid using shell script for all the major linux
commands.
Course Outcomes Achieved:
1. Install Operating System and Configure it.
2. Use operating system tools for various functions.
3. Execute process commands for performing process management operations
Sr.no
Charateristic
to
be Poor(Mar Average(Ma Good(Mar Excellent(Ma Sub
assessed
ks 1-3)
rks 4 - 5)
ks 6-8 )
rks 9-10)
Total
(A)Process and Product Assessment (Convert above total marks out of 6 marks.)
1.
Relevance to the Course
2.
Literature Review
/information collection
Completion of the target
as per project proposal
Analysis of data and
representation
Quality
of
Prototype/Model
Report Preparation.
3.
4.
5.
6.
(B) Individual Presentation/Viva (Convert above marks Total Marks out of 4)
7.
Presentation
8.
Viva
(A)Process
andProduct
Assessment
(6 marks)
(B)
Individual
Presentation/Viva(4
marks)
Total Marks 10
Comments/Suggestions about team work. Leadership /inter-personal communication
…………………………………………………………………………………………
……………………………………………………………………………………….
Name and designation of the Teacher: Mrs.Rema kadam
Dated Signature ……………………………………………..
Download