[How To]: Access to Shell via VI or VIM Editor

Shell Access via VI or VIM


Why do you need to access shell via VI or VIM?

A: sometimes, you have to copy result of a commands and paste those results to editor. For example, you are configuring SCSI devices as DM-Multipath devices, you have to run some commands like “multipath -l” for see “WWID” of specific device and add the “WWID” to “multipath.conf”.

As simple solution, you can run another ssh session and run the command on this session, then copy and paste the result. But I think, there is another good way to do it.

You can access to shell via VI or VIM editor and do your job!

But how to?

How to Access Shell via VI or VIM?


Run VI or VIM command to open the editors and start to edit your file. For accessing to shell, you must run the below command within VI or VIM:

:shell

Or this command:

:sh

Then you will access to shell and the editor is still open.

The shell is opened for your temporary, so you must have access to editor again. Press Ctrl+D or type “exit” and hit Enter for return back to the editor.

Davoud Teimouri

Professional blogger, vExpert 2015/2016/2017/2018/2019/2020/2021/2022/2023, vExpert NSX, vExpert PRO, vExpert Security, vExpert EUC, VCA, MCITP. This blog is started with simple posts and now, it has large following readers.

Leave a Reply

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