How to open and edit files in Linux

You can open/edit file in Linux using vi editor

  • vi [options] <file name or path to file> then press ‘i’ to open in insert[edit] mode


  • vi file1
  • vi /tmp/file2
open/edit/close file in linux
To close opened file, follow below commands of vi editor:
  • To save file, type:
    • :wq<Enter Key>
  • To save file forcefully, type:
    • :wq!<Enter Key>
  • To close file without saving, type:
    • :q<Enter Key>
  • To close file forcefully, type:
    • :q!<Enter Key>
open/edit/close file in linux

Note: If you are in insert mode and want to close file, then press Esc key first.

You may want to see
How to use crontab in Linux

Cron is the system process that will automatically perform tasks for you according to a set schedule. The schedule is Read more

How to extract archive file in Linux

To extract archive file in Linux, you can use the tar command, used for extracting content from the archive files. "tar" Read more

How to Change permission of a file in Linux

chmod command is used to change the permission of a file in Linux. In Linux, there is a set of rules for Read more

How to create and remove the directory in Linux

There is a separate command to create and remove the directory in Linux. mkdir command is used to create a directory/folder Read more

Leave a Reply

Your email address will not be published. Required fields are marked *