This set of Unix Multiple Choice Questions & Answers (MCQs) focuses on “Vi Basics and Modes – 1”.
1. Which editor is used by the UNIX system to edit files?
a) vi
b) notepad
c) word
d) notepad++
View Answer
Explanation: It doesn’t matter what kind of work we are doing on a UNIX system, we always need an editor to edit some system files or ordinary files. For this purpose, vi editor is used in UNIX. Currently, vim (vi improved) is an improved version which is supported by LINUX systems.
2. What does the following command do?
$ vi file001
a) open file named file001
b) edit file named file001
c) delete a file named file001
d) open file if it exists else creates a new file
View Answer
Explanation: vi editor can be used for creating and editing files. In the above command, if file001 already exists, then the contents of the file will be displayed. Otherwise, an empty file named file001 will be created.
3. Which option is used by vi editor to open a file in read mode only?
a) -r
b) -R
c) -d
d) -f
View Answer
Explanation: To open an existing file in read-mode only, -R is used with the filename (as an argument). For example,
$ vi -R file001 // open file in read mode only
4. How many types of modes are used by vi editor?
a) 2
b) 4
c) 3
d) 1
View Answer
Explanation: Before working with vi editor, it is necessary to be familiar with the modes in which vi editor works. There are three different kinds of modes, namely command mode, input mode and ex mode each of which is used for a specific purpose.
5. What is the default mode of vi editor?
a) Command mode
b) Input mode
c) Ex mode
d) Insert mode
View Answer
Explanation: The default mode of vi editor is command mode, where every key which is pressed is interpreted as a command to run on the text. To perform operations on text like deleting, copying, the first step you’ll have to follow is to be in the command mode so that you can run commands according to your suitability.
6. To insert text into a file, _____ mode is used.
a) Command mode
b) Input mode
c) Ex mode
d) def mode
View Answer
Explanation: Input mode provides us with a feature of inputting text in files. Every key pressed in this mode is recorded in the file.
7. ex mode is used for what purpose?
a) file handling
b) substitution
c) file handling and substitution
d) Inputting text in files
View Answer
Explanation: ex mode performs various file handling and substitution operations like saving the file, quitting the editor, search and replace operations etc.
8. Which one of the following key is used to switch from command mode to input mode?
a) i
b) :
c) esc
d) ;
View Answer
Explanation: To switch from command mode to input mode press the ‘i’ key.
9. ____ key is used for switching to command mode from input mode.
a) i
b) A
c) :
d) esc
View Answer
Explanation: Command mode allows us to enter commands for performing operations on the text entered. To switch from the input mode to command mode press the ‘esc’ key. This operation will not be displayed on the screen but changes our mode to command mode.
10. Which of the following key is used to enter in ex-mode?
a) ESC
b) i
c) :
d) ;
View Answer
Explanation: To enter into ex-mode press the ‘:’ key. After that, we can press any ex-mode command followed by [Enter] to perform suitable operations.
Sanfoundry Global Education & Learning Series – Unix.
To practice all areas of Unix, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Get Free Certificate of Merit in Unix
- Participate in Unix Certification Contest
- Become a Top Ranker in Unix
- Take Unix Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Buy Computer Science Books
- Practice MCA MCQs
- Buy MCA Books
- Buy Unix Books
- Apply for Computer Science Internship