Kali Linux
Kali Linux
Class : II B.Sc. CS
Semester : IV
• Create files: A text editor can be used to create, edit, and save files.
• Open files: A text editor can be used to open, modify and save an
existing file. It is also used to open multiple documents at a time.
• Copy text: text editors facilitate document creation because they enable
to copy and paste text.
• Search for text: A text editor can be used to search a particular
expression or a word. The search and replace feature enables to
change multiple instances of a particular word or a string.
Editors available with linux
• The vi Editor
• The visual editor, popularly known as the vi editor, is one of the
most widely used UNIX based text editors. It offers a compact interface
and enables to control the system by using the keyboard.
The vim Editor
• Another widely used text editor is the edit macros or emacs editor.
The emacs editor provides a much larger set of commands than the vi
editor
The ed Editor
• Another popular editor available is the Joe’s own editor or joe. The
joe editor is a full – screen editor that lets to edit both programs and
text.
The pico Editor
• The pico editor is based on the Pine messaging system. The pine
messaging system is a character-based interface in Linux. It is used to
send and receive e-mail messages. The pico editor offers various
features, including paragraph justification and search features
Unit - III
THE vi
EDITOR
THE vi EDITOR
The vi editor is a visual editor used to create and edit text files,
documents, and programs. It displays the contents of files on the
screen.
The vi editor is one of the oldest editors available for the UNIX platform.
The vi editor is available for all of the variants of UNIX and Linux.
Getting started with the vi Editor
• Give the following command at the Linux prompt to invoke the vi editor:
• vi filename <Enter>
The following table lists out the basic
commands to use the vi editor −
• Following is an example to create a new file testfile if it already does
not exist in the current working directory −
• $vi testfile
• The above command will generate the following output −
• |
• ~
• ~
• ~
• ~
• ~
• ~
• ~
• ~
• ~
• ~
• ~
• ~
•
• The –exec option is used to specify the operations that need to be
performed on the files that have been located by the find command.
• $ find . –name temp –type f –exec rm {} \;
The –ok Option
Standard Files
Standard Files
• A computer system consists of mainly three parts, input, processing, and output devices. The
input device accepts data from a user, and the output device displays or prints information or
any error messages that are generated.
• The keyboard and mouse are examples of input devices, and the
screen and the printer are the examples of output devices. The CPU is
the processing device.
• In the Linux operating system, all input and output devices are
considered special files.
• Standard Input File
• If we specify the cat command with a file name, all the lines in the file
are displayed. However, without a file name, the cat command takes
input from the standard input file or the keyboard as given below:
• $ cat <Enter>
• The cat command waits for input from the keyboard. The screen will
display the following output:
• $ cat <Enter>
Standard Error File
.
and served as chief scientist until 2003
The vi editor is:
» - A very powerful
» - It is hard to learn, specially for
windows
users
» - Move from point to point in the file, and
make changes.
» - Available on all UNIX systems
There are three modes in vi
» - Command mode
⋄ - Accessed by typing Esc
⋄ - In this mode all the keys pressed by the user are interpret to the editor command.
» - Input mode
⋄ - Accessed by typing “i”
⋄ - This mode permits insertion of new text, editing of existing text or replacement of existing text.
» Ex mode( Last Line Mode)
⋄ -The bottom line of the vi screen is called ex mode.
⋄ - When you start vi by default it is in command mode
» -You exit the input mode by pressing the Esc key to get back to the command mode.
I/P & O/P
REDIRECTION
Your keyboard is your standard
input (stdin) device, and the
screen or a particular
terminal
• Most Linux commands read input, such as a file or another attribute for
the command, and write output. By default, input is being given with the
keyboard, and output is displayed on your screen.
window is the standard output (stdout) device.
However, since Linux is a flexible system, these default settings
don't necessarily have to be applied. The standard output, for
example, on a heavily monitored
server in a large environment may be a printer.
Output redirection with > and Input
redirection with <
The> operator tells unix, “Don’t display this output on screen instead , put it
somewhere else”. Likewise the < operator says “ the input for this command is
not coming from the keyboard this time look for somewhere else”.
The somewhere else can be a file or a printer for output redirection and a
file or a keyboard for input redirection.
Example
$cat file1 > file2
$cat test1
some words
$ cat test2
some other words
$ cat test1 test2 > test3
$cat test3
some words some other
words
Example
$cat file1 < file2
Example:$ls |more
Linux treats the keyboard as the standard input (value 0) and terminal screen
standard output (value 1) as well as standard error(value2).
Redirection inputs:
The < symbol is used to redirect inputs. Example
$cat < file.txt
Example :
$cat list1.doc
There are some linux commands that accept input from standard input
or files,perform some manipulation on it and produce some
output to the standard output.