Sunday, 11 January 2015

How to open/edit/close file in linux

You can open/edit file in linux using vi editor
Syntax:
  • vi [options] <file name or path to file> then press 'i' to open in insert[edit] mode

Examples:
  • vi file1
  • vi /tmp/file2
edit file in vi editor


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>



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

No comments:

Post a Comment