Which command must be entered in vi to save the current file as filea.txt?

Prepare for the LPI 101-500 Certification Exam. Utilize flashcards, navigate multiple choice questions, and benefit from hints and explanations. Begin your Linux certification journey today!

The correct command to save the current file as filea.txt in vi is :w filea.txt. This command is used to write the contents of the current buffer to the specified filename. When you prefix the filename with a colon and use 'w,' you are explicitly instructing vi to save the changes you've made to the file.

In the context of vi, the colon followed by a command indicates that you are entering command mode. The 'w' stands for 'write,' and appending the filename specifies the name under which you want to save the file. If the specified file already exists, it will overwrite that file with the current contents.

Other commands, such as %s filea.txt and %w filea.txt, do not function correctly in the context of saving files in vi. The %s would typically be used for substitutions within the text, while %w does not have a defined saving function in this editor. Similarly, :save is not a recognized command in vi for saving files; the correct format is :w. Thus, the correct command to save the file with the new name is :w filea.txt.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy