Loading

×Sorry to interrupt
CSS Error

Refresh

Cookie Preference Center

General Information on cookies

When you visit our website, we use cookies to ensure that we give you the best experience. This information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies by clicking on the different category headings to find out more and change your settings. However, blocking some types of cookies may impact your experience on the site and the services we are able to offer. Further information can be found in our

Cookie Policy.

Strictly Necessary

Strictly Necessary

Always Active

Strictly Necessary

Strictly necessary cookies are always enabled since they are essential for our website to function. They enable core functionality such as security, network management, and website accessibility. You can set your browser to block or alert you about these cookies, but this may affect how the website functions. For more information please visit www.aboutcookies.org or www.allaboutcookies.org.

Cookie Details‎

Performance

Performance

Performance

Performance cookies are used to analyze the user experience to improve our website by collecting and reporting information on how you use it. They allow us to know which pages are the most and least popular, see how visitors move around the site, optimize our website and make it easier to navigate.

Cookie Details‎

Please confirm your settings by refreshing the page.

Functional

Functional

Functional

Functional cookies help us keep track of your past browsing choices so we can improve usability and customize your experience. These cookies enable the website to remember your preferred settings, language preferences, location and other customizable elements such as font or text size. If you do not allow these cookies, then some or all of these services may not function properly.

Cookie Details‎

Advertising

Advertising

Advertising

Advertising cookies are used to send you relevant advertising and promotional information. They may be set through our site by third parties to build a profile of your interests and show you relevant advertisements on other sites. These cookies do not directly store personal information, but their function is based on uniquely identifying your browser and internet device.

Cookie Details‎

Advertising Cookies

Consent Leg.Interest

Select All Vendors

Select All Vendors

Select All Hosts

Select All

Clear Filters

Information storage and access

Apply

Confirm My Choices Reject All Allow All

My Subscriptions

Loading

Knowledge Base

Editing files on an ESXi host using vi (1020302)

Last Updated: 6/29/2020Categories: How toTotal Views: 353084Language:
Chinese (Simplified)JapaneseEnglish

33 like this article

Subscribe to get an email
newsletter with new updates

33 people found this helpful Please provide article feedback:

Learn how VMware Skyline Advisor and Skyline Health Diagnostics work together to provide proactive intelligence and self-service log analysis.

Use Skyline Advisor to avoid issues before they occur across VCF, vSphere, vSAN, NSX, vROps & Horizon. Skyline Findings are based on top KBs, VMSAs/CVEs and design best practices.

Use Skyline Health Diagnostics to root cause vSphere & vSAN logs when an issue occurs. Skyline Health Diagnostic Findings are based on top KBs and VMSA/CVEs. You can use the Skyline Health Diagnostics tool in online or offline mode.

If you require additional help from technical support, please use Skyline Advisor to initiate a Log Assist to reduce time to upload logs. TSEs can also initiate logs to reduce effort.

Purpose

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

Resolution

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:

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.

Move down to the last line in the file.

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.

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.

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:

Type vi /etc/hosts and press Enter.

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.

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:

Type vi /etc/hosts and press Enter to edit the file.

Arrow down to the line to delete.

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:

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.

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.

In nano, you do not need to enter and leave insert mode, you can just start editing.

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
Cancel.

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.

Related 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.

Notes:

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

Detectable by VMware SkylineTM

Actions

Copy

link to clipboard
copied!

Print

Language:
Chinese (Simplified)JapaneseEnglish

Attachments

Additional Resources

KB
•
End Of General Availability of the Free vSphere Hypervisor (ESXi 7.x and 8.x) (2107518)

Result 1 of 1

Ask The Community

Get answers quickly from VMware experts in the community

Post Subject

CONTINUE IN COMMUNITIES

Related Products:

VMware vSphere ESXi

VMware vSphere ESXi

VMware ESX Server

Related Versions:

VMware vSphere ESXi 7.0.0

VMware vSphere ESXi 6.5

VMware vSphere ESXi 6.0

VMware vSphere ESXi 5.5

VMware vSphere ESXi 5.1

VMware vSphere ESXi 5.0

VMware ESXi 4.1.x Installable

VMware ESXi 4.1.x Embedded

VMware ESXi 4.0.x Installable

VMware ESXi 4.0.x Embedded

VMware ESXi 3.5.x Installable

VMware ESXi 3.5.x Embedded

VMware ESX Server 3.5.x

VMware ESX Server 3.0.x

VMware ESX Server 2.5.x

VMware ESX 4.0.x

view all

Take Our Survey

Support Assistant