How to save and exit after editing files on the Ubuntu command line

After editing a file in the Ubuntu command line, you can save and exit using the following steps:

  1. CtrlPress the key and key combination on your keyboard Xto exit edit mode.
  2. If the file has changed, you'll see a prompt asking whether to save the changes. Press Ythe key to confirm saving changes, or press Nthe key to cancel saving.
  3. If you choose to save changes, Ubuntu will display a filename prompt. By default, the filename is the name of the file you originally opened. If you want to change the filename, you can edit the filename here and press Enter/Return to confirm.
  4. If the filename is correct, press Enter/Return, which will save the file and exit the editor.
  5. If you choose not to save changes, the editor will exit without saving the file.

Commonly used command-line text editors are Vi or Vim, which are among the most common text editors on Linux systems. If you are using Vi or Vim for editing, please follow the steps below to save and exit:

  1. Make sure you are in Command mode by pressing the Esc key.
  2. Enter :wq(without quotes) to save and exit.

If you just want to exit without saving your changes, enter (without quotes) in step 2 :q!and press Enter/Return. Note that this will not save changes in the file.

Guess you like

Origin blog.csdn.net/m0_51913750/article/details/131735671