FC5462 - Operating System
Practical No. 4
Aim: a) Use Operating services (Editor, GUI, File Handling.)
b) Run commands to start, stop and restart the special service in Linux.
Theory:
a) Use Operating services Editor:
There are many ways to edit files in Unix or Linux. These editors enable you to edit lines
in context with other lines in the file. You can also use these editors to just read a text
file.
An improved version of the vi editor, VIM (Vi IMproved ) is available now.
Vi Editor:
Study the commands and execute the same.
i) Input mode Commands
Commands Function
i Inserts text to left of cursor
l Inserts text at beginning of cursor
a Appends text to right of cursor
A Appends text at end of line
o Opens line below
O Opens line above
rch Replaces single character under cursor with character
R Replaces text from cursor to right
s Replaces single character under sursor with any number of characters
S Replaces entire line
Practical No. 4
FC5462 - Operating System
ii) Paging Functions
Command Function
<control-f> Scrolls full page forward
<control-b> Scrolls full page backward
<control-d> Scrolls half page downwards
<control-u> Scrolls half page upwards
<control-l> Redraws page screen
iii) Cursor Movement Commands
Command Function
H or backspace Moves cursor left
j Moves cursor down
k Moves cursor up
l Moves cursor right
$ Moves cursor to end of line
b Moves cursor back to beginning of word
e Moves cursor forward to end of word
w Moves cursor forward to beginning of word
^ Moves cursor to beginning of first word of line
0 or l Moves cursor to beginning of line
iv) Commands for Deletion, changing and Yanking
Command Function
D$ or D Deletes from cursor to end of line
5dd Deletes five lines
d30G Deletes from cursor up to line number 30
co Changes from cursor to beginning of line
c$ or C Changes from cursor to end of line
3cw or c3w Changes three words
cc Changes current line
cG Changes from cursor to end of line
y$ or Y Yanks from cursor to end of file
3yw or y3w Yanks three words from cursor position
5yy Yanks five lines
Practical No. 4
FC5462 - Operating System
v) Yanking (copying text) using yy
yy command yanks a copy of current line into a buffer
P command puts line in buffer after cursor
p command puts line in buffer before cursor
“regYY yanks a line into buffer register reg.
n”regYY yanks n lines into buffer register reg.
“regP puts the contents of register reg after cursor.
vi) Colon Mode Commands
Saving text and quiting vi
Commands Actions
:w Saves files and remains in editing mode
:x Saves files and quits editing mode
:wq Saves files and quits editing mode
:q Quits editing mode when no changes are made to file
:sh Escape to the unix shell
Practical No. 4
FC5462 - Operating System
vii) Set options used by vi in colon mode / ex mode
Option Abbreviation Significance
Autoindent ai Next line starts at the previous indented
Ignorecase ic Ignore case while searching for patterns
Magic magic Treats the characters of the regular expression set special
while searching for patterns
Number nu Displays line number on screen
Showmode showmode Displays current mode
Showmatch sm Shows a momentarily the match to a) and}
Tabstop ts Sets tab for display
wrapscan ws Counting pattern search by moving to the other end of a
file
i) Abbreviations using abbr command : The abbr command is used to expand short strings to
long words. The abbr command in the colon mode maps the first argument to the following
string.
For example :
: abbr GPA Government Polytechnic Amravati This indicates that when you enter the word GPA
followed by a key which is neither alphanumeric nor the underscore character, the words
“Government Polytechnic Amravati” would be substituted in place of the string.
ii) Map command : Map command is colon mode command used to assign undefined keys or
reassign defined ones so that when such a key is pressed, it expands it to a command sequence.
It is particularly useful to convert a sequence of keystrokes into a macro. In the ex mode (:
mode ),the map command is followed by the key which needs mapping and the key sequence
which is mapped.
GUI:
Linux system provides both the interface that is GUI and CLI. As per the requirement you can
decide when you should use Linux command line interface (CLI) and when you should use a
graphical user interface (GUI).
Practical No. 4
FC5462 - Operating System
File Handling:
All data in Linux is organized into files. All files are organized into directories. These directories
are organized into a tree-like structure called the file system.
When you work with Linux, one way or another, you spend most of your time working with
files.
In Linux, there are three basic types of files −
Ordinary Files − An ordinary file is a file on the system that contains data, text, or program
instructions. In this tutorial, you look at working with ordinary files.
Directories − Directories store both special and ordinary files. For users familiar with Windows
or Mac OS, Linux directories are equivalent to folders.
Special Files − Some special files provide access to hardware such as hard drives, CD-ROM
drives, modems, and Ethernet adapters. Other special files are similar to aliases or shortcuts
and enable you to access a single file using different names.
Basic Linux Navigation and File Management (Terminal)
Finding Where You Are with the “pwd” Command.
Looking at the Contents of Directories with “ls”
Moving Around the Filesystem with “cd”
Create a File with “touch”
Create a Directory with “mkdir”
Moving and Renaming Files and Directories with “mv”
Copying Files and Directories with “cp”
Practical No. 4
FC5462 - Operating System
Basic Linux Navigation and File management (GUI)
1) Create Directory:
To make a directory
1. Right click and select New Folder.
2. Type the name of folder and click on create button.
Practical No. 4
FC5462 - Operating System
2) Rename Directory :
To rename a directory -
1. Right click and select Rename.
2. Type the new name of directory and click on rename button.
3) Copy Directory :
To copy a directory
1. Right click and select Copy.
2. Select folder , double click on that folder and inside it right click and select paste.
Practical No. 4
FC5462 - Operating System
4) Move Directory:
To move a directory -
1. Right click and select Move to.
2. Select Folder and click on select button.
Practical No. 4
FC5462 - Operating System
5) Deleting Directory
To delete a directory -
Right click and select Move to Trash.
b) Run commands to start, stop and restart the special service in Linux.
Following are the process commands:
Command to add and remove services in your system start-up:
Use chkconfig
Practical No. 4
FC5462 - Operating System
To show currently running services.
ls /etc/init.d
for e.g. – apache2 is a service running currently.
To restart service –
sudo service apache2 restart
To stop the service –
sudo service apache2 stop
To start the service –
sudo service apache2 start
Practical No. 4
Exercise:
1. Give the difference between GUI & CLI.
GUI CUI
GUI refers to Graphical User Interface. CUI stands for Character User Interface
It is a user Interface which interacts with In CUI user has to interact with the
applications by making use of graphics. applications by making use of commands.
In GUI more than one task can run In CUI only one task can run at a time.
simultaneously.
Navigation is difficult. Navigation is easy.
User interacts with computer using mouse, Keyboard is needed to type commands in
keyboard or any other pointing device. order to interact with the computer.
GUI is highly customizable. CUI appearance is not easily changeable.
2. List various menus & sub-menus available in GEdit.
gedit is the default text editor of the GNOME desktop environment and part of the GNOME
Core Applications.
Following are the menus in the GEdit.
a) New Window: Opens the new Window.
b) Open: It opens the file from system.
c) Save All: Save the all changes.
d) Find: Find a word or keyword.
e) Find and Replace: Find a given word and Replace it with given word.
f) Go to Line: Highlights the given line.
g) View: It shows the view options which we see on editor and we can manage it as our
need.
h) Tools: It shows the different tools like Spelling Check, Insert date and Time, etc.
i) Keyboard Shortcuts: Shows the shortcuts.
Sub-Menus in Tools menu
a) Check Spelling: It checks the spellings.
b) Set Language: We can set it to native language.
c) Highlight: It highlights the misspelled words with using red underline.
d) Insert Date and Time: Used to specify the date and time format.
Sub-Menus in View Menu
a) Side Panel: It shows the Panel on right side and shows all the opened files there.
b) Highlight Mode: In this we can select a language which ig going to be used in our file
and the editor will manage the color and error highlighting accordingly.
Conclusion: Thus, we Successfully use Operating services (Editor, GUI, File Handling), Run
commands to start, stop and restart the special service in Linux.