0% found this document useful (0 votes)
4 views6 pages

Module 6 Important

A shell is a software interface for users to interact with an operating system, often as a command-line interpreter. Shell scripts are programs run by a Unix shell for tasks like file manipulation, while shell variables can be user-defined or system variables affecting processes. The vi editor is a powerful, modal text editor for Unix systems, offering features like syntax highlighting and macro recording, while Vim is an enhanced version of vi with additional functionalities.

Uploaded by

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

Module 6 Important

A shell is a software interface for users to interact with an operating system, often as a command-line interpreter. Shell scripts are programs run by a Unix shell for tasks like file manipulation, while shell variables can be user-defined or system variables affecting processes. The vi editor is a powerful, modal text editor for Unix systems, offering features like syntax highlighting and macro recording, while Vim is an enhanced version of vi with additional functionalities.

Uploaded by

Shinchan Nohara
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

What is a shell ?

A shell is a software interface that allows users to interact with an operating


system (OS) kernel. It acts as a command-line interpreter, enabling users to issue
commands and control the OS. Shells can be either command-line interfaces
(CLIs) or graphical user interfaces (GUIs), but the term "shell" often refers to the
CLI, especially on Unix-like systems.

What is shell script ?

A shell script is a computer program designed to be run by a Unix shell, a


command-line interpreter. The various dialects of shell scripts are considered to
be command languages. Typical operations performed by shell scripts include file
manipulation, program execution, and printing text.

What are shell variables?

In shell scripting, there are two main types of variables: user-defined and system
(environment) variables. User-defined variables are created and used within a
specific script or shell session, while system variables are pre-defined by the
operating system and affect the behavior of all processes and scripts.

User-defined variables:

 These are variables that are defined and used within a shell script or
during a shell session.

 They are typically used to store temporary values, data for calculations, or
to pass information between different parts of a script.

 User-defined variables are not automatically inherited by child processes


unless they are explicitly exported.

 They are generally defined with lowercase letters or mixed case.

System (environment) variables:

 These variables are pre-defined by the operating system and are accessible
to all processes and scripts.

 They control the environment in which programs run, providing


information like the user's home directory, the path to executable files, and
other important settings.

 System variables are often used in uppercase letters, although this is not a
strict requirement.

 By default, system variables are inherited by child processes.


What are system calls

System calls are a fundamental mechanism in operating systems, acting as an


interface between user programs and the kernel. They allow programs to
request services from the kernel, such as accessing hardware, managing
processes, or performing file operations. System calls are essentially a way for
a program to ask the OS to do something on its behalf, rather than directly
accessing system resources.

VI Editor

What Is vi Editor?

The vi editor is a text editor that is available on almost all Unix systems. It is a very
powerful editor with many features that make it ideal for editing text files. One of the
most important features of the vi editor is that it is modal, which means that it has
different modes for editing and for viewing files. This is a major advantage over other
editors, which are not modal and thus confusing.

The vi editor has three main modes:

 Command Mode: When you first open a file with the vi editor, you are in
command mode. In this mode, you can move the cursor around the file and issue
commands to the editor. The most important commands in this mode are the
movement commands, which allow you to move the cursor around the file. These
commands are very important because they allow you to edit the file in a very
precise way.

 Insert Mode: Itis the mode you are in when you want to insert or change the text
in the file. In this mode, the cursor is positioned at the point where you want to
make the change, and you can type in the new text. After making the change, you
can press the Esc key to return to command mode.

 View Mode: When you want to view the file but not make any changes to it, that’s
the view mode of the vi editor. This mode is useful for viewing files you do not
want to modify, such as configuration files. In view mode, you can move the
cursor around the file and view the contents of the file. However, you cannot
change the file in this mode. You can press the Esc key to exit view mode and
return to command mode.

Operations on vi Editor

1. vi Command Mode:
The “vi” command mode is the default mode for the vi editor. In this mode, characters
typed on the keyboard are interpreted as commands. The commands available in this
mode allow you to move the cursor around the screen, search for text, delete text,
change text, and so on.

There are two ways to enter the “vi” command mode:

 Use the Esc key

 Type the “:” (colon) character

2. vi Editor Insert mode:

You must first be in insert mode to insert text while in the vi editor. To enter insert
mode, press the “i” key. You can also enter insert mode by pressing the “a” key, which
will insert text after your cursor’s character. You can also enter insert mode by pressing
the “I” key, which will insert text at the beginning of the current line. Finally, you can
enter insert mode by pressing the “A” key, which will insert text at the end of the
current line.

Once you are in insert mode, you can start typing to insert text. To exit insert mode and
return to command mode, press the “Esc” key.

3. How to Use vi Editor:

 For command mode: Press the Esc key

 For insert mode: Press the “i” key

 For last-line mode: Press the “:” key

In command mode, you can issue commands to the vi editor. For example, you can use
the h, j, k, and l keys to move the cursor around the file. You can use the w, b, and e keys
to move the cursor forward or backward by word or by sentence. You can use the 0
(zero) key to move the cursor to the beginning of the current line and the $ key to move
the cursor to the end of the current line. Press “i” to enter the insert mode. In this mode,
you can insert text into the file. The text is inserted at the location of the cursor.

In last-line mode, you can enter commands that affect how the vi editor behaves. For
example, you can use the: set command to turn on or off certain features of the vi editor.
To enter last-line mode, press the: key. To exit the last-line mode, press the Esc key.

4. vi Editing Commands:

There are a variety of commands for editing text in vi Editor. These commands can be
used to move the cursor around, delete text, insert text, and so on. Each command is
typically a single letter. For example, the “i” command inserts text at the current cursor.

5. Moving Within a File:


Moving within a file means moving the cursor to a new location in the same file. The
cursor is moved using the arrow keys or other keys. The other keys include the
following:

 h – move left

 j – move down

 k – move up

 l – move right

The moving can also be done using keyboard shortcuts. For example, the Ctrl + F key
combination moves the cursor forward one full screen, and the Ctrl + B key combination
moves the cursor backward one full screen.

6. Saving and Closing the File:

In the vi editor, to save the file without exiting the editor, we can use “:wq.” This saves
and exits the file. Otherwise, to save the file, we use:w. To exit the file without saving, we
use “:q.”

Advantages of vi Editor

There are various advantages of using the vi editor, which include:

1. vi Editor is Powerful

vi is a very versatile text editor that can be used to edit various files. It is used to edit
files in many different programming languages, including C, C++, Java, and Python. “vi”
can also be used to edit HTML, XML, and CSS files. It is a very user-friendly text editor
with a wide variety of features that make it a great choice for editing text files. “vi” is a
very popular text editor used by many people, including programmers, web developers,
and system administrators.

2. Provides a Wide Range of Features

“vi” editor is a powerful text editor that comes with a wide range of features that can be
used to edit text files. Some of the most notable features include:

 Support for a Wide Range of File Formats: vi editors can be used to edit files in
various formats, including plain text, HTML, XML, and more.

 Syntax Highlighting: vi editors can highlight the syntax of various programming


languages, making it easier to read and edit code.

 Code Completion: vi editors can automatically complete code for you based on
your editing context. This can save a lot of time, especially when working with
large codebases.
 Macro Recording: vi editors can record your keystrokes and play them back,
which can be very useful for repetitive tasks.

 Plug-in Support: vi editors can be extended with plug-ins, adding new features or
customizing the editor to suit your needs.

3. vi Editor Is Easy to Use and Provides a User-Friendly Interface

Advantages of the vi editor include ease of use and user-friendly UI. It is a text editor
that programmers and system administrators widely use.

The vi editor is easy to learn and use and provides various features that make it a
powerful tool for editing text files. It is available on most Unix-like operating systems
and is the default editor on many Linux distributions.

What is Vim?

Vim is a highly configurable text editor available on all Unix systems, but it is also
available on MS-Windows (7, 8, 10, 11), macOS, Haïku and VMS.

It is an enhanced version of UNIX/VI developed in 1991 by Bram Moolenaar. In fact,


the term Vim comes from Vi IMproved. And even today, it continues to improve thanks
to the addition of new, ever more powerful features.

The aim of all these features is to make it easier to create and modify any type of text.
Although Vim is often referred to as “the developer’s editor”, it is not just used for
programming software and applications. In fact, this tool can be used for all types of text
editing (such as writing e-mails or editing configuration files).

Vim can also be used by data experts. It enables them to sort and correct databases
containing thousands of heterogeneous lines.

What are the advantages of Vim?

At first glance, the Vim text editor may seem a little austere. And yet it is one of the
preferred tools of developers. There are several reasons for this:

 Its power: Vim users benefit from powerful search and replace functions

 Its features: for example, automatic completion, file comparison, advanced


searches, command line history, online help, spell checking, block operations,
scripting language, etc.

 Customisation: to make it easier to create and modify software and


applications, Vim offers users a wide variety of extensions.

 Adaptability: Vim supports hundreds of programming languages and file


formats. It also integrates with a wide range of tools.
 Continuous improvement: Vim is continually developed to offer users even
more features to meet their needs.

You might also like