Editing files on an ESXi host using vi
search cancel

Editing files on an ESXi host using vi


Article ID: 345284


Updated On:


VMware vSphere ESXi


This article provides steps for editing files on an ESXi\ESX host by using vi or nano.


VMware ESXi 3.5.x Installable
VMware ESXi 4.0.x Installable
VMware vSphere ESXi 5.0
VMware vSphere ESXi 5.5
VMware vSphere ESXi 7.0.0
VMware vSphere ESXi 6.5
VMware ESX 4.0.x
VMware ESXi 4.1.x Embedded
VMware ESX Server 3.0.x
VMware ESX Server 2.5.x
VMware ESXi 4.1.x Installable
VMware vSphere ESXi 5.1
VMware ESXi 3.5.x Embedded
VMware ESX Server 3.5.x
VMware vSphere ESXi 6.0
VMware ESXi 4.0.x Embedded


These steps can be used on an ESX 3.x or 4.x host.

Run an SSH session to your ESX host using SSH as the user root. If you have not established an SSH session to your ESX host yet, see Connecting to an ESX host using a SSH client (1019852).

You can also use these instructions after accessing the ESX host console directly or through a remote KVM, then pressing ALT+F1 and logging in as root.

To see what is in the file you can use the cat command to display the contents of, for example /etc/hosts, on the screen.

The output appears similar to:

<localhost> localhost
::1 localhost
<IPAddress> <FQDN>

Note: If you want to have a backup of this file prior to editing it, make a copy of it in /var/tmp. To make a copy, type cp /etc/hosts /var/tmp and press Enter.

Editing using vi

To add an entry for another ESXi\ESX host at IP <IPaddress> and FQDN into the /etc/hosts file using vi:
  1. Type vi /etc/hosts and press Enter. Now you are in the vi text editor. You can move around using page up, page down, and the arrow keys.
  2. Move down to the last line in the file.
  3. Enter insert mode.

    You can press i to start editing where the cursor is, you can also press shift+o to start editing on a new line above the cursor, or o to start editing on a new line below the cursor.

    You see -- INSERT -- at the bottom of the vi window while you are in insert mode within vi.
  4. Add your entry.

    Note: The number pad on the keyboard does not work within vi by default. Use the numbers above the letters on your keyboard. You can use the arrow, backspace, and delete keys as well as enter text while in edit mode.
  5. To quit and save changes press Esc, :, w, q, then press Enter.

    If you decide you are not comfortable with the changes and want to quit without saving, press Esc, :, q, then press Enter. You do not have to press Esc, :, and q at the same time.
To edit an entry using vi:
  1. Type vi /etc/hosts and press Enter.
  2. Without entering insert mode move to the character you want to change, press R, then press the key for the character you want to change to.
  3. To save and quit press Esc, :, w, q.

    Note: You may receive a warning indicating that the file is read only when you try to save and quit. To get around this, add an ! character to the end of the Esc, :, w, q sequence and press Enter.
    Note: If you are using putty and you are in insert mode, you can paste clipboard items into vi by left-clicking copied text.
To delete the entries using vi:
  1. Type vi /etc/hosts and press Enter to edit the file.
  2. Arrow down to the line to delete.
  3. Press d twice to delete the whole line. You can also press x to delete only one character at a time when you are not in insert mode.

Editing using nano

Note: Nano is not available in ESXi. Use VI editor in ESXi versions.
To edit a file using nano:
  1. Type nano /etc/hosts and press Enter. At the bottom of the nano window there are commands with a ^ character in front, which indicates you need to press and hold Ctrl and the character to run the command. For example, to Exit you press and hold Ctrl and press X.
  2. To make an entry arrow down to the place where you want to begin entering the text.

    Note: The number pad does not work by default. Pressing Num Lock actually opens help by default. Use the numbers above the letters on your keyboard.
  3. In nano, you do not need to enter and leave insert mode, you can just start editing.
  4. To Save and Quit, press Ctrl+X. You see the option to Save modified buffer (ANSWERING "No" WILL DESTROY CHANGES)? Then the option for Y YES, N NO or ^C

    Press Y to save. You can see a File Name to Write: /etc/hosts prompt. Save the file with another file name, but press Enter to save to /etc/hosts. The changes have been applied and saved.
Note: You can copy multiple items into the clipboard and paste them into nano to simplify bulk edits. Always copy and paste from a text editor like Notepad to ensure you are working with plain text.

Additional Information

Preferred Editors

There are different editors to choose from, depending on your running platform. The following is non-exhaustive list of editors available in different platforms:
  • VMware ESX includes the open source terminal-based editors nano and vi. For more information, see the vi man pages or the nano man pages.
  • VMware ESXi includes the open source terminal-based editor vi. For more information, see the vi man pages.
  • Windows-based machines include basic text editors such as Notepad and Wordpad. If you are using either of these text editors, you must ensure that you are saving files in their original format and encoding.
  • The editors available in the shell (vi or nano) are meant for troubleshooting purposes only and must be used only when directed by VMware. The vSphere Client, vCLI, and PowerCLI should be the primary method of propagating changes to your ESX/ESXi host.
  • Notepad saves documents as ANSI text which may not be the same file format as the files downloaded from a VMware ESX or ESXi host. For more information, see Using different language formats in Notepad from Microsoft's Windows XP Professional Product Documentation.

Note: The preceding links were correct as of September 22, 2014. If you find the links are broken, please provide feedback and a VMware employee will update the link.

仮想マシンの起動が、次のエラーで失敗する:Error : 'ethernet0.filter0.onFailure': DVFilter onFailure 'null' must be 'failOpen' or 'failClosed'
vMotion が 14% の時点で失敗し、次のエラーが表示される: 移行開始要求の待機中にタイム アウトになりました
仮想マシンの Storage vMotion が次の一般的なシステム エラーで失敗する: Storage VMotion で仮想マシン ディスクを 1 つ以上コピーできませんでした
ESX ホスト上で vi または nano を使用してファイルを編集する
vDGA で構成された Windows ゲスト OS で障害が発生して青色の診断画面が表示された後に、VMware ESXi 5.5.x ホストで障害が発生して紫色の診断画面が表示される
使用 vi 或 nano 编辑 ESX 主机上的文件
仮想ディスクの拡張が次のエラーで失敗する: msg.disklib.UNSUPPORTEDFEATURE