nerdexam
Linux_Foundation

LFCS · Question #786

While editing a file in vi, an administrator realizes that the wrong file is being changed. Which of the following vi command sequences will allow the administrator to quit without saving any changes?

The correct answer is B. :q! To quit the vi editor without saving any changes, the administrator should use the esc :q! command sequence.

Submitted by skyler.x· Apr 18, 2026Essential Commands

Question

While editing a file in vi, an administrator realizes that the wrong file is being changed. Which of the following vi command sequences will allow the administrator to quit without saving any changes?

Options

  • A:Q!
  • B:q!
  • C:w!
  • D:wq!

How the community answered

(38 responses)
  • A
    3% (1)
  • B
    87% (33)
  • C
    5% (2)
  • D
    5% (2)

Why each option

To quit the vi editor without saving any changes, the administrator should use the `esc :q!` command sequence.

A:Q!

While `:Q` can be equivalent to `:q` in some vi variants, the exclamation mark `!` is crucial to force quit without saving, and `:q!` is the canonical form.

B:q!Correct

The `esc :q!` command sequence forces vi to quit without saving any modifications made to the file, which is useful when realizing the wrong file is being edited.

C:w!

`:w!` saves the file forcefully but does not exit the editor.

D:wq!

`:wq!` saves the file and then quits the editor, which is the opposite of quitting without saving.

Concept tested: vi editor quit without saving

Source: https://man7.org/linux/man-pages/man1/vi.1.html

Topics

#vi editor#text editing#quitting files

Community Discussion

No community discussion yet for this question.

Full LFCS Practice