How Do You Exit a Read Only File in Linux?
Contents

Note that pressing L seems to do pretty much the same thing. The file will be saved but remains opened in Vi/Vim for more editing or reading. We can now exit normally by typing ESC :q! since the file is still opened as read-only.

How do I close a read only file in Linux?

To save a file that’s read-only, use the following command: :wq! The exclamation point after write-quit is to override the read-only status of the file.

How do I change a read only file in Linux?

Long Answer

  1. Log in as the root user: [email protected]:~$ sudo su –
  2. Open hostname: [email protected]:~# vi /etc/hostname.
  3. You will see oldName . …
  4. Open hosts: [email protected]:~# vi /etc/hosts. …
  5. Similarly to what you did in step 3, change the computer name from oldName to newName . …
  6. Exit the root user: [email protected]:~# exit.
Alexander Ross

Alexander Ross

Gaming, Esports & Interactive Media Writer

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.

Share this article
Twitter Facebook Pinterest