1.5. Interacting with the CLI


The CLI is an interactive shell for controlling your Red Hat Enterprise Virtualization environment from the command line. Type the required command and any additional parameters.

Example 1.1. Entering a shell command

[RHEVM shell (connected)]# show vm RHEL6-Server
Copy to Clipboard Toggle word wrap
To support the construction of command and parameter combinations, the CLI includes the functionality to list and automatically complete commands and parameters by pressing the TAB key twice, similar to the bash shell.

Example 1.2. Listing and automatic completion of commands and parameters

Press double TAB at a blank prompt to list all available commands.
[RHEVM shell (connected)]# TAB TAB
EOF           clear         echo          history       remove        summary       
action        connect       exit          info          shell         update        
add           console       file          list          show          
capabilities  disconnect    help          ping          status
Copy to Clipboard Toggle word wrap
Choose a command and press double TAB to view the next set of available parameters for the command. For the add command, this lists all resources.
[RHEVM shell (connected)]# add TAB TAB
affinitygroup  datacenter     event          group          nic
quota          label          template       vmpool         cdrom
disk           filter         host           permission     role
storagedomain  user           cluster        qos            glustervolume
network        permit         snapshot       tag            vm
Copy to Clipboard Toggle word wrap
Double TAB also completes commands and parameters.
[RHEVM shell (connected)]# add vm TAB TAB
comment      console-enabled     cpu-architecture  delete_protected 
description  disks-clone         display-type      io-threads
memory       name                os-type           rng_device-source 
stateless    soundcard_enabled   start_paused      timezone
[RHEVM shell (connected)]# add vm naTAB TAB
[RHEVM shell (connected)]# add vm --name
Copy to Clipboard Toggle word wrap
Note that the double TAB also automatically formats na to the --name parameter, including the prefix.
If the incomplete parameter matches multiple parameters, double TAB lists them.
[RHEVM shell (connected)]# add vTAB TAB
vmpool        vm
Copy to Clipboard Toggle word wrap
The CLI provides functions to run Linux commands using either the shell command or the bang (!) character.

Example 1.3. Running Linux shell commands

Use the shell command:
[RHEVM shell (connected)]# shell ls -la
Copy to Clipboard Toggle word wrap
Or use the bang (!) character:
[RHEVM shell (connected)]# !ls -la
Copy to Clipboard Toggle word wrap
Similar to the Linux shell, the CLI can pipe data to other commands and sources.

Example 1.4. Piping CLI commands

Pipe CLI data to a Linux shell command:
[RHEVM shell (connected)]# list vms --show-all | grep "Example"
name                      : Example1
name                      : Example2
name                      : ExampleEngineering
description               : An Example description
name                      : BestExampleVM
Copy to Clipboard Toggle word wrap
Pipe CLI data to a file:
[RHEVM shell (connected)]# list vms --show-all > list vms --show-all > VM_List.txt
Copy to Clipboard Toggle word wrap
The CLI also contains an online help system to provide descriptions and syntax for each command via the help command.

Example 1.5. Using online help for the show command

[RHEVM shell (connected)]# help show
Copy to Clipboard Toggle word wrap
You can also connect to the Manager from the Linux shell to execute specific commands, in the form of "command resource" and print them to STDIO

Example 1.6. Connecting to the Manager to execute specific commands

Use the --execute or -E parameter to connect to the Manager to execute the specific commands.
# rhevm-shell -c -l "https://[server]/api" -P [port] -u "[user@domain]" -A "[certificate]" -E "list vms;list hosts"
[RHEVM shell (connected)]# list vms

id         : 9e6977f4-4351-4feb-bba0-dc7c22adec30                                                                                                                                      
name       : desktop-01                                                                                                                                                                   

id         : 60b12e28-7965-4296-86bf-c991aa32c2d5                                                                                                                                      
name       : server-01                                                                                                                                                                     

[RHEVM shell (connected)]# list hosts

id         : 3598cdb9-d21b-49bd-9491-59faff89b113                                                                                                                                      
name       : Gluster                                                                                                                                                                   

id         : a0c384f9-0940-4562-9c42-4ceaadf8f1f1                                                                                                                                      
name       : Host-01                                                                                                                                                                  

id         : 593ec966-c3ea-4bdc-84ad-5dc3f9fe64c7                                                                                                                                      
name       : Host-03
Copy to Clipboard Toggle word wrap
Back to top
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2025 Red Hat