FOSS 3rd Module
FOSS 3rd Module
Module III
Linux Commands: date, time, who, echo, man, info, cal, pwd, more, less, head, tail, mkdir, cd, cp, mv,
rm, touch, sort, wc, cut, cat with options, ls with options ,grep with options, chmod, diff, mounting the
file system, command line processing etc. Types of editors in Linux, Introduction to vi editor, modes in
vi editor, common vi editor commands for open a file, save a file, delete a file, quit a file etc
*******************
LINUX COMMANDS
DATE COMMAND
The date command is used to display system date, time, time zone, and more.
Syntax: date [OPTION]... [+FORMAT]
3: –date or -d Option: Displays the given date string in the format of date. But this will not affect the
system’s actual date and time value. Rather it uses the date and time given in the form of string.
Syntax: $date --date=" string "
Command: $date --date="2/02/2010"
$date --date="Feb 2 2010"
Output:
Tue Feb 2 00:00:00 PST 2010
Tue Feb 2 00:00:00 PST 2010
1
FOSS
6: -s or –set Option: To set the system date and time -s or –set option is used.
Syntax: $date --set="date to be set"
2
FOSS
Command: $date
Output: Wed Oct 11 15:23:26 PDT 2017
7: –file or -f Option: This is used to display the date string present at each line of file in the date and
time format. This option is similar to –date option but the only difference is that in –date we can only
give one date string but in a file we can give multiple date strings at each line.
Syntax: $date --file=file.txt
$cat >> datefile
Sep 23 2018
Nov 03 2019
8:-r Option: This is used to display the last modified timestamp of a datefile .
Syntax: $date -r file.txt
$touch datefile
//The timestamp of datefile is changed using touch command.
This was done few seconds after the above date command’s output.
$date -r datefile
Wed Oct 11 15:56:23 PDT 2017
//display last modified time of datefile
3
FOSS
TIME COMMAND
The time command is used to display the time to execute a command.
Syntax: time [option] [COMMAND]
Command: $time
Output:
4
FOSS
WHO COMMAND
The who command is used to get information about currently logged in user on to system. Who
command is used to find out the following information :
1. Time of last system boot
2. Current run level of the system
3. List of logged in users and more.
Syntax : $who [options] [filename] ‘
Options:
1. The who command displays the following information for each user currently logged in to the
system if no option is provided :
a. Login name of the users
b. Terminal line numbers
c. Login time of the users in to system
d. Remote host name of the user
hduser@mahesh-Inspiron-3543:~$ who
hduser tty7 2018-03-18 19:08 (:0)
5
FOSS
ECHO COMMAND
The echo command in Linux is a built-in command that allows users to display lines of text or strings
that are passed as arguments.
Syntax: echo [option] [string]
Example: If we want to display “MACAS”.
echo "MACAS"
OPTIONS
NOTE :- -e here enables the interpretation of backslash escapes
1. \b : it removes all the spaces in between the text
Example:
2. \c : suppress trailing new line with backspace interpreter ‘-e‘ to continue without emitting new line.
Example:
echo -e "Geeks \cfor Geeks"
In the above example, text after \c is not printed and omitted trailing new line.
6
FOSS
5. \r : carriage return with backspace interpreter ‘-e‘ to have specified carriage return in output.
Example:
echo -e "Geeks \rfor Geeks"
7
FOSS
8
FOSS
Man Command
man command in Linux is used to display the user manual of any command that we can run on the
terminal. It provides a detailed view of the command which includes NAME, SYNOPSIS,
DESCRIPTION, OPTIONS, EXIT STATUS, RETURN VALUES, ERRORS, FILES, VERSIONS,
EXAMPLES, AUTHORS and SEE ALSO.
9
FOSS
2. Section-num: Since a manual is divided into multiple sections so this option is used to display only
a specific section of a manual.
Syntax : $ man [SECTION-NUM] [COMMAND NAME]
Example: $ man 2 intro
Output:
3. -f option: One may not be able to remember the sections in which a command is present. So this
option gives the section in which the given command is present.
Syntax:
$ man -f [COMMAND NAME]
10
FOSS
Example:
$ man -f ls
Output:
CAL COMMAND
cal command is a calendar command in Linux which is used to see the calendar of a specific month or a
whole year.
Syntax: cal [ [ month ] year]
Example : cal jun 2023
cal : Shows current month calendar on the terminal with the current date highlighted.
cal -y : Shows the calendar of the complete current year with the current date highlighted.
11
FOSS
cal 2018 | more : But year may not be visible in the same screen use more with cal use spacebar to
scroll down.
12
FOSS
cal -j : Shows the calendar of the current month in the Julian calendar format not in the
default Gregorian calendar format. In Julian calendar format, the date does not reset to 1 after every
month’s end i.e. after 31st Jan, Feb will start as 32nd Feb, not as 1st Feb. But in the Gregorian calendar
format, the date is reset to 1 after every month’s end i.e after 31st Jan, Feb will start as of 1st Feb.
INFO COMMAND:
Info command reads documentation in the info format. It will give detailed information for a command
when compared with the man page.
Syntax:
info [OPTION]... [MENU-ITEM...]
Options:
• -a, –all: It use all matching manuals.
• -k, –apropos=STRING: It look up STRING in all indices of all manuals.
• -d, –directory=DIR: It add DIR to INFOPATH.
• -f, –file=MANUAL: It specify Info manual to visit.
• -h, –help: It display this help and exit.
• -n, –node=NODENAME: It specify nodes in first visited Info file.
• -o, –output=FILE: It output selected nodes to FILE.
13
FOSS
Examples:
• -a : It use all matching manuals and display them for a particular command.
info -a cvs
• -k : It look up STRING in all indices of all manuals and then display the same.
info -k cvs
14
FOSS
• -O : It go to command-line options node for a particular command and display the same.
info -O cvs
15
FOSS
PWD COMMAND
pwd stands for Print Working Directory. It prints the path of the working directory, starting from the
root.
Syntax: pwd [OPTIONS]
Example: pwd -L: Prints the symbolic path.
pwd -P: Prints the actual path.
MORE COMMAND
more command is used to view the text files in the command prompt, displaying one screen at a time in
case the file is large (For example log files).
Syntax: more [-options] [-num] [+/pattern] [+linenum] [file_name]
• [-options]: any option that you want to use in order to change the way the file is displayed. Choose
any one from the followings: (-d, -l, -f, -p, -c, -s, -u)
• [-num]: type the number of lines that you want to display per screen.
• [+/pattern]: replace the pattern with any string that you want to find in the text file.
• [+linenum]: use the line number from where you want to start displaying the text content.
• [file_name]: name of the file containing the text that you want to display on the screen.
Options:
• -d : Use this command in order to help the user to navigate. It displays “[Press space to continue,
‘q’ to quit.]” and displays “[Press ‘h’ for instructions.]” when wrong key is pressed.
16
FOSS
• -f : This option does not wrap the long lines and displays them as such.
Example:
more -f sample.txt
17
FOSS
• -p : This option clears the screen and then displays the text.
Example:
more -p sample.txt
• -c : This command is used to display the pages on the same area by overlapping the previously
displayed text.
Example:
more -c sample.txt
18
FOSS
• -s : This option squeezes multiple blank lines into one single blank line.
Example:
more -s sample.txt
19
FOSS
• +num : This option displays the text after the specified number of lines of the document.
Example:
more +30 sample.txt
Less Command
Less command is a Linux utility that can be used to read the contents of a text file one page (one screen)
at a time. It has faster access because if a file is large, it doesn’t access the complete file, but accesses it
page by page.
Syntax: less [options] filename
Example: less -p "sample.txt"
20
FOSS
21
FOSS
HEAD COMMAND
The head command, as the name implies, print the top N number of data of the given input. By default,
it prints the first 10 lines of the specified files
Syntax: head [OPTION]... [FILE]...
Example: $ cat state.txt
Andhra Pradesh Arunachal Pradesh Assam Bihar Chhattisgarh Goa Gujarat
Haryana Himachal Pradesh Jammu and Kashmir Jharkhand Karnataka
Kerala Madhya Pradesh Maharashtra Manipur Meghalaya Mizoram
Nagaland Odisha Punjab Rajasthan Sikkim Tamil Nadu
Telangana Tripura Uttar Pradesh Uttarakhand West Bengal
Without any option, it displays only the first 10 lines of the file specified.
$head state.txt
Andhra Pradesh
Arunachal Pradesh
Assam
Bihar
Chhattisgarh
Goa
Gujarat
Haryana
Himachal Pradesh
Jammu and Kashmir
Options
1. -n num: Prints the first ‘num’ lines instead of first 10 lines. num is mandatory to be specified in
command otherwise it displays an error.
$ head -n 5 state.txt
Andhra Pradesh Arunachal Pradesh Assam Bihar Chhattisgarh
22
FOSS
2. -c num: Prints the first ‘num’ bytes from the file specified. Newline count as a single character, so
if head prints out a newline, it will count it as a byte. num is mandatory to be specified in command
otherwise displays an error.
$ head -c 6 state.txt
Andhra
3. -q: It is used if more than 1 file is given. Because of this command, data from each file is not
precedes by its file name.
23
FOSS
Hyderabad
Itanagar
Dispur
Patna
Raipur
Panaji
Gandhinagar
Chandigarh
Shimla
Srinagar
4. -v: By using this option, data from the specified file is always preceded by its file name.
$ head -v state.txt
==> state.txt <==
Andhra Pradesh
Arunachal Pradesh
Assam
Bihar
Chhattisgarh
Goa
Gujarat
Haryana
Himachal Pradesh
Jammu and Kashmir
24
FOSS
Kerala
Madhya Pradesh
Maharashtra
Manipur
Meghalaya
Mizoram
Nagaland
Odisha
2) How to use the head with pipeline(|): The head command can be piped with other commands. In
the following example, the output of the ls command is piped to head to show only the three most
recently modified files or folders.
Display all recently modified or recently used files.
$ ls -t
e.txt
d.txt
c.txt
b.txt
a.txt
3) It can also be piped with one or more filters for additional processing. For example, the sort filter
could be used to sort the three most recently used files or folders in the alphabetic order.
$ ls -t | head -n 3 | sort
c.txt
d.txt
e.txt
25
FOSS
TAIL COMMAND
The tail command print the last N number of data of the given input. By default it prints the last 10 lines
of the specified files.
Syntax: tail [OPTION]... [FILE]...
Without any option it display only the last 10 lines of the file specified.
Example:$ tail state.txt
Odisha
Punjab
Rajasthan
Sikkim
Tamil Nadu
Telangana
Tripura
Uttar Pradesh
Uttarakhand
WEST BENGAL
Options:
1. -n num: Prints the last ‘num’ lines instead of last 10 lines. num is mandatory to be specified in
command otherwise it displays an error. This command can also be written as without symbolizing
‘n’ character but ‘-‘ sign is mandatory.
$ tail -n 3 state.txt $ tail -3 state.txt
Uttar Pradesh Uttar Pradesh
Uttarakhand Uttarakhand
West Bengal West Bengal
OR
Tail command also comes with an ‘+’ option which is not present in the head command. With this
option tail command prints the data starting from specified line number of the file instead of end. For
26
FOSS
command: tail +n file_name, data will start printing from line number ‘n’ till the end of the file
specified.
2. -c num: Prints the last ‘num’ bytes from the file specified. Newline count as a single character, so
if tail prints out a newline, it will count it as a byte. In this option it is mandatory to write -c followed
by positive or negative num depends upon the requirement. By +num, it displays all the data after
skipping num bytes from starting of the specified file and by -num, it display the last num bytes from
the file specified.
Note: Without positive or negative sign before num, command will display the last num bytes from
the file specified.
With negative num
$ tail -c -6 state.txt
Bengal
OR
$ tail -c 6 state.txt
Bengal
3. -q: It is used if more than 1 file is given. Because of this command, data from each file is not
precedes by its file name.
27
FOSS
28
FOSS
4. -f: This option is mainly used by system administration to monitor the growth of the log files written
by many Unix program as they are running. This option shows the last ten lines of a file and will
update when new lines are added. As new lines are written to the log, the console will update with the
new lines. The prompt doesn’t return even after work is over so, we have to use the interrupt key to
abort this command. In general, the applications writes error messages to log files. You can use the -
f option to check for the error messages as and when they appear in the log file.
$ tail -f logfile
5. -v: By using this option, data from the specified file is always preceded by its file name.
$ tail -v state.txt
==> state.txt <==
Odisha
Punjab
Rajasthan
Sikkim
Tamil Nadu
Telangana
Tripura
Uttar Pradesh
Uttarakhand
West Bengal
6. –version: This option is used to display the version of tail which is currently running on your
system.
$ tail --version
tail (GNU coreutils) 8.26
Packaged by Cygwin (8.26-1)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later .
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Paul Rubin, David MacKenzie, Ian Lance Taylor,
and Jim Meyering.
29
FOSS
30
FOSS
MKDIR COMMAND
mkdir command in Linux allows the user to create directories (also referred to as folders in some
operating systems). This command can create multiple directories at once as well as set the permissions
for the directories.
Syntax: mkdir [options...] [directories ...]
example: mkdir -p [mydirectory]
31
FOSS
Here we have used `ls` command to display all files and directories.
CD COMMAND
The cd command in Linux stands for change directory. It is used to change the current directory of the
terminal. The terminal, by default, opens the home directory.
SYNTAX: CD [DIRECTORY]
Example : cd /
To go to the root directory, we input / as the argument.
cd
We do not provide any arguments to the cd command to go to the home directory.
32
FOSS
cd . .
To shift one level above the current directory, we input .. as the argument.
cd -
To go to the previous directory, we use - as our argument.
cd /folder/subfolder
CP COMMAND
cp stands for copy. This command is used to copies files or groups of files or directories from a source
to a destination.
Syntax: cp [options] source destination
cp [OPTION] Source Directory
cp [OPTION] Source-1 Source-2 Source-3 Source-n Directory
The first and second syntax is used to copy the Source file to the Destination file or Directory.
The third syntax is used to copy multiple Sources(files) to the Directory.
Example : $ cp a.txt b.txt
Suppose there is a directory named geeksforgeeks having a text file a.txt, b.txt and a directory
name new in which we are going to copy all files.
$ ls
a.txt b.txt new
33
FOSS
For this case the last argument must be a directory name. For the above command to work, Dest
directory must exist because cp command won’t create it.
MV COMMANDS
MV stands for move. This command is used to rename file directories and move files from one location
to another within a file system.
Two Distinct Functions of `mv` Command
1) Renaming a file or directory.
2) Moving a file or directory to another location
34
FOSS
This command moved file “name = `gfg_1 and gfg_2`” to the destination “name =
“/home.jayeshkumar/jkj/”.
This command renames `jkj` to `new_gfg`. If `new_gfg` already exists, in that case it will be
overwritten without prompting for confirmation.
RM COMMAND
rm stands for remove here. rm command is used to remove objects such as files, directories, symbolic
links and so on from the file system
syntax : rm [OPTION]... FILE...
Example: $ ls
a.txt b.txt c.txt d.txt e.txt
Removing one file at a time
$ rm a.txt
35
FOSS
$ ls
b.txt c.txt d.txt e.txt
Removing more than one file at a time
$ rm b.txt c.txt
$ ls
d.txt e.txt
No output is produced by rm, since it typically only generates messages in the case of an error.
Options:
1. -i (Interactive Deletion): Like in cp, the -i option makes the command ask the user for confirmation
before removing each file, you have to press y for confirm deletion, any other key leaves the file un-
deleted.
TOUCH COMMAND
The touch command is a standard command used in the UNIX/Linux operating system which is used
to create, change and modify the timestamps of a file.
there are two different commands to create a file in the Linux system which are as follows:
• cat command: It is used to create the file with content.
• touch command: It is used to create a file without any content. The file created using the touch
command is empty. This command can be used when the user doesn’t have data to store at the time
of file creation.
• You can update the modification and access time of each file with the help of touch command.
Syntax: touch <filename>
Example: touch myfile1
• Touch command can be used to create multiple numbers of files at the same time. These files would
be empty while creation.
Syntax: touch File1_name File2_name File3_name
Options:
i) touch -a Doc1
Here touch -a command changes access time of the file named Doc1.
ii) touch -c-d filename
this is used to update access and modification time.
iii) touch -m fileName
This is used to change the modification time only. It only updates last modification time.
36
FOSS
SORT COMMAND
• SORT command is used to sort a file, arranging the records in a particular order.
• By default, the sort command sorts file assuming the contents are ASCII.
Syntax: sort <fileName>
Example: $ cat > mix.txt
abc
apple
BALL
Abc
bat
Now use the sort command
$ sort mix.txt
Output :
Abc
BALL
abc
apple
bat
OPTIONS:
Sorting In Reverse Order: You can perform a reverse-order sort using the -r flag. the -r flag is an
option of the sort command which sorts the input file in reverse order i.e. descending order by default.
Syntax :
$ sort -r inputfile.txt
Command : $ sort -r file.txt
Output: :
satish
rajan
naveen
harsh
divyam
chitransh
abhishek
37
FOSS
-nr option: To sort a file with numeric data in reverse order we can use the combination of two
options as stated below.
Example: The numeric file is the same as above.
Syntax : $ sort -nr filename.txt
Command : $ sort -nr file1.txt
Output :
200
89
50
39
15
-M Option: To sort by month pass the -M option to sort. This will write a sorted list to standard
output ordered by month name.
Example:
Suppose the following file exists and is saved as months.txt
$ cat > months.txt
February
38
FOSS
January
March
August
September
wc Command
• wc stands for word count.
• It is used to find out number of lines, word count, byte and characters count in the files
specified in the file arguments.
• By default it displays four-columnar output.
• First column shows number of lines present in a file specified, second column shows number of
words present in the file, third column shows number of characters present in file and fourth
column itself is the file name which are given as argument.
Syntax: wc <file name>
Example : $ cat state.txt $ cat capital.txt
Andhra Pradesh Hyderabad
Arunachal Pradesh Itanagar
Assam Dispur
Bihar Patna
Chhattisgarh Raipur
$ wc state.txt
5 7 58 state.txt
39
FOSS
OR
$ wc capital.txt
5 5 39 capital.txt
Options:
1. -l: This option prints the number of lines present in a file.
With one file name
$ wc -l state.txt
5 state.txt
4. -m: Using -m option ‘wc’ command displays count of characters from a file.
With one file name
40
FOSS
$ wc -m state.txt
56 state.txt
CUT COMMAND
Linux cut command is useful for selecting a specific column of a file. It is used to cut a specific sections
by byte position, character, and field and writes them to standard output. It cuts a line and extracts the
text data.
Syntax:
cut OPTION... [FILE]...
eg: $ cat state.txt
Andhra Pradesh
Arunachal Pradesh
Assam
Bihar
Chhattisgarh
OPTIONS:
1. -b(byte): To extract the specific bytes, you need to follow -b option with the list of byte numbers
separated by comma. Range of bytes can also be specified using the hyphen(-). It is necessary to
specify list of byte numbers otherwise it gives error. Tabs and backspaces are treated like as a
character of 1 byte.
List without ranges
$ cut -b 1,2,3 state.txt
And
Aru
Ass
Bih
Chh
41
FOSS
2. -c (column): To cut by character use the -c option. This selects the characters given to the -c option.
This can be a list of numbers separated comma or a range of numbers separated by hyphen(-).
$ cut -c 2,5,7 state.txt
nr
rah
sm
ir
hti
Above cut command prints second, fifth and seventh character from each line of the file.
$ cut -c 1-7 state.txt
Andhra
42
FOSS
Arunach
Assam
Bihar
Chhatti
Above cut command prints first seven characters of each line from the file.
Cut uses a special form for selecting characters from beginning upto the end of the line:
$ cut -c 1- state.txt
Andhra Pradesh
Arunachal Pradesh
Assam
Bihar
Chhattisgarh
Above command prints starting from first character to end. Here in command only starting
position is specified and the ending position is omitted.
$ cut -c -5 state.txt
Andhr
Aruna
Assam
Bihar
Chhat
Above command prints starting position to the fifth character. Here the starting position
is omitted and the ending position is specified.
CAT COMMAND
Cat(concatenate) command is very frequently used in Linux. It reads data from the file and gives its
content as output. It helps us to create, view, and concatenate files.
1) To view a single file
Syntax: cat file_name
Example: If our file_name = jayesh.txt
cat jayesh.txt
43
FOSS
5) Cat command can append the contents of one file to the end of another file.
Syntax: cat file_name1 >> file_name2
Example: cat file1 >> file2
LS COMMAND
• In Linux, the command "ls" is one of the most commonly used. It's used to display a list of files and
sub-directories in the current directory.
• The 'ls' command is used to list files and directories
• The contents of your current working directory, which is just a technical way of stating the directory
that your terminal is presently in, will be listed if you run the "ls" command without any further
options.
Option 1: ls
Display the hidden files and directories
Option 2: ls -a
Use the -a option of the ls command to show hidden files and directories in the current directory.The
files that start with the dot are hidden (.). The current directory (.) as well as the parent directory (..) are
displayed by "ls -a".
Option 3: ls –l Display complete information about the files
The "ls -l" option displays the contents of the current directory in a long listing format, one per line. The
line begin with the file or directory permission, owner and group name, file size, created/modified date
and time, file/folder name as some of the attributes.
Option 4: ls –i Display File Index Number
For internal purposes, you may need to know the index number of a file. To display the index number,
use the "ls -i" option. You can remove files with special characters in their names by using the index
number.
44
FOSS
grep command
The grep filter searches a file for a particular pattern of characters, and displays all lines that contain that
pattern. The pattern that is searched in the file is referred to as the regular expression (grep stands for
global search for regular expression and print out).
Option 2. Displaying the count of number of matches : We can find the number of lines that matches
the given string/pattern
$grep -c "unix" geekfile.txt
Output: 2
Option 3. Display the file names that matches the pattern : We can just display the files that contains
the given string/pattern.
$grep -l "unix" *
or
$grep -l "unix" f1.txt f2.txt f3.xt f4.txt
Output: geekfile.txt
Option 4. Checking for the whole words in a file : By default, grep matches the given string/pattern even
if it is found as a substring in a file. The -w option to grep makes it match only the whole words.
$ grep -w "unix" geekfile.txt
Output:
unix is great os. unix was developed in Bell labs.
uNix is easy to learn.unix is a multiuser os.Learn unix .unix is a powerful.
45
FOSS
Option 5. Displaying only the matched pattern : By default, grep displays the entire line which has the
matched string. We can make the grep to display only the matched string by using the -o option.
$ grep -o "unix" geekfile.txt
Output:
unix
unix
unix
unix
unix
unix
CHMOD COMMAND
• In Unix operating systems, the chmod command is used to change the access mode of a file. The
name is an abbreviation of change mode.
• Which states that every file and directory has a set of permissions that control the permissions like
who can read, write or execute the file. In this the permissions have three categories: read, write,
and execute simultaneously represented by `r`, `w` and `x`.
These letters combine together to form a specific permission for a group of users.
• The `chmod` command is used to modify this permission so that it can grant or restrict access to
directories and files. Let’s have a look at the syntax and options for the `chmod` command in Linux
Operating System.
Operators Definition
46
FOSS
Letters Definition
Reference Class
u Owner
g Group
o Others
a All (owner,groups,others)
DIFF COMMAND
diff stands for difference. This command is used to display the differences in the files by comparing the
files line by line. Unlike its fellow members, cmp and comm, it tells us which lines in one file have is to
be changed to make the two files identical.
• Syntax : diff [options] File1 File2
47
FOSS
$ ls
a.txt b.txt
$ cat a.txt
Gujarat
Uttar Pradesh
Kolkata
Bihar
Jammu and Kashmir
$ cat b.txt
Tamil Nadu
Gujarat
Andhra Pradesh
Bihar
Uttar pradesh
Now, applying diff command without any option we get the following output:
$ diff a.txt b.txt
0a1
> Tamil Nadu
2,3c3
< Uttar Pradesh
Andhra Pradesh
5c5
Uttar pradesh
0a1 which means after lines 0(at the very beginning of file) you have to add Tamil Nadu to match
the second file line number 1. It then tells us what those lines are in each file preceded by the symbol:
• Lines preceded by a < are lines from the first file.
• Lines preceded by > are lines from the second file.
• Next line contains 2,3c3 which means from line 2 to line 3 in the first file needs to be changed to
match line number 3 in the second file. It then tells us those lines with the above symbols.
• The three dashes (“—“) merely separate the lines of file 1 and file 2.
48
FOSS
49
FOSS
50
FOSS
2. NANO EDITOR
Nano is a straight forward editor. It is designed for both beginners and advanced users. It has many
customization features.
Some advanced features of a nano text editor are as following:
o It has highly customizable key bindings
o It supports syntax highlighting
o It has undo and redo options
o It provides full line display on the standard output
o It has pager support to read from standard input
3. GEDIT EDITOR
Gedit editor is the default editor for the GNOME desktop environment. When we open a file, it will open
with the Gedit editor. It provides straightforward functionalities like any basic text editor. It is a
lightweight editor with a straight forward user interface. It was publicly released in the year 2000 with a
GNOME desktop environment. It is developed using the C programming language and supports all font
family.
Some key features of the gedit text editor are as following:
51
FOSS
4. SUBLIME TEXT
The sublime text editor is also one of the most popular IDE-based text editors. It is used as a development
environment tool more than a text editor. It has several features to support many programming and mark-
up languages.
Some key features of a sublime text editor are as following:
o It has an excellent Command Palette.
o It is a python-based plugin API.
o It supports parallel editing of code.
o It provides project-specific preferences.
5. VSCODE EDITOR
VSCode editor is a modern and widely used text editor. It is built by Microsoft and has support for Linux,
Mac and Windows OS. It facilitates with many powerful features to support many programming
languages and markup language.
Some key features of VSCode editor are as following:
o It has full support for debugging with an interactive console, breakpoints, call stacks and more.
o It has built-in support for Git and Git commands.
o It facilitates with IntelliSense.
o It provides many customization options.
o It has massive support for languages.
o It supports togglable layouts.
o It provides a built-in terminal.
INTRODUCTION TO VI EDITOR
The default editor that comes with the UNIX operating system is called vi (visual editor). Using vi editor,
we can edit an existing file or create a new file from scratch. we can also use this editor to just read a
text file. The advanced version of the vi editor is the vim editor.
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.
52
FOSS
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. Although, after typing i nothing will appear on the screen but 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. Modes of Vi Editors.
1.COMMAND MODE
This is what you'll see when you'll press enter after the above command. If you'll start typing, nothing
will appear as you are in command mode. By default vi opens in command mode.
Look at the above snapshot, it is blank as it is a new file. To start typing, you have to move to the insert
mode. At the end of the terminal window, directory name and file name are displayed.
2.INSERT MODE
To move to the insert mode press i. Although, there are other commands also to move to insert mode
which we'll study in next page.
From above snapshot, after pressing i we have entered into insert mode. Now we can write anything. To
move to the next line press enter.
Once you have done with your typing, press esc key to return to the command mode.
53
FOSS
COMMANDS IN VI EDITOR
1. OPEN VI EDITOR FILE
To open vi editors, we just need to type the command as:
vi [file_name]
Here, [file_name] = “macas” this is the file name we want to create or to open the pre-existing file.
Creating a new file with `file_name` = macas
vi macas.txt
54
FOSS
55