LPI Linux Professional Institute BSD Specialist 702-100 Question # 10 Topic 2 Discussion
702-100 Exam Topic 2 Question 10 Discussion:
Question #: 10
Topic #: 2
While using vi as superuser. the attempt to save a file while quitting the editor leads to an error indicating that the file is read-only. How can the file permissions be overridden to save the edits to the file and quit the editor?
The wq! command is used to save a file and quit the vi editor, even if the file is read-only. The w command means write, the q command means quit, and the ! command means force. By combining these commands, the vi editor will override the file permissions and save the changes to the file, then exit the editor. The other options are either invalid syntax or do not force the write operation. For example, wq will save and quit only if the file is writable, ql will quit without saving, and fw! will force write but not quit. References:
[vi] - FreeBSD vi(1) Manual Page
[wq!] - How to save a file in vi / vim editor in Linux / Unix
Contribute your Thoughts:
Chosen Answer:
This is a voting comment (?). You can switch to a simple comment. It is better to Upvote an existing comment if you don't have anything to add.
Submit