Getting started with the OpenStack command line client


OpenStack is open-source software that allows you to create private and public clouds. A command line tool is available which makes it easy to work with. This article explains how to install this client on your cloud instance.


The OpenStack command line client can be installed in several ways. This article shows how to install it by running pip in a virtualenv as well as installing globally.

Install python-dev

Install python-dev so you can build Python extensions. This is necessary to install the openstackclient using pip.

If you're using Python 2:

[user@localhost]$ sudo apt-get install python2.7-dev

If you're using Python 3:

[user@localhost]$ sudo apt-get install python3-dev

Install pip

First, run the following to see if pip is installed:

If you're running Python 2

[user@localhost]$ pip -V

If you're running Python 3

[user@localhost]$ pip3 -V

If it's not, install with the following:

If you're running Python 2

[user@localhost]$ sudo apt-get install python-pip

If you're running Python 3

[user@localhost]$ sudo apt-get install python3-pip

Install virtualenv

One way to install the OpenStack CLI is in a virtual environment. Now that pip is installed, run the following to install virtualenv:

[user@localhost]$ sudo apt-get install python-virtualenv

Install OpenStack CLI

Installing within a virtualenv

This is a safe method as your installation is housed within a virtual environment and does not touch anything else in your system. To do this, create a virtual environment, activate it, and install the OpenStack CLI within it.

If you're using Python 2, run the command pip. If you're using Python 3, run the command pip3.

This example creates a new virtualenv directory named venv in your user's home directory.

[user@localhost]$ virtualenv ~/venv
[user@localhost]$ source ~/venv/bin/activate
(venv)user@localhost$ pip install python-openstackclient

This installs the client in a virtual environment separated from the rest of your system. In order to be able to use the client you will have to activate the virtual environment using the source command above.

Installing globally

You can also install on your system globally using pip for Python 2.

[user@localhost]$ sudo pip install python-openstackclient

Or pip3 for Python3.

[user@localhost]$ sudo pip3 install python-openstackclient

You may see the following error when installing.

Command python egg_info failed with error code 1

If so, run the following:

[user@localhost]$ pip install --upgrade setuptools

Or if you're using Python 3:

[user@localhost]$ pip3 install --upgrade setuptools

Try again and you should be able to install without an error.


The easiest way to configure the client is to use the OpenRC file. View the following article for instructions on how to download this file:

In order to use the OpenRC file, run:

[user@localhost]$ source

Basic commands

The OpenStack command line client combines the functionality of all of the other OpenStack service specific command line clients, such as the nova client and the cinder client. Here are some basic commands that are useful:

[user@localhost]$ openstack server list
| ID                                   | Name        | Status | Networks                                                     | Image Name   |
| 4c40d015-33b3-4bc3-ba50-d794356eef4f | mariadb     | ACTIVE | public=2607:f298:5:101d:f816:3eff:feeb:ca8c, | Ubuntu-16.04 |
| bf500ff3-7b37-4d01-a77e-5efc086de5f0 | nextcloud-1 | ACTIVE | public=2607:f298:5:101d:f816:3eff:fef1:9c6a,  | Ubuntu-16.04 |
| af01d391-7604-482e-84b9-3ccee872d69f | nextcloud   | ACTIVE | public=2607:f298:5:101d:f816:3eff:fea9:a69f, | Ubuntu-16.04 |
| 72c4271b-d447-444c-b5f6-0af401ca14d2 | wordpress   | ACTIVE | public=2607:f298:5:101d:f816:3eff:fe08:54c5, | Ubuntu-16.04 |

This lists the instances you have in your tennant with some basic information about them.

[user@localhost]$ openstack image list --status active
| ID | Name | Status |
| e87001f8-475e-403e-830d-24484187da08 | Debian-10 | active |
| 3272eb6f-b9cc-472e-ab0f-972670fc56a4 | Debian-11 | active |
| 40d4bb2e-bf2e-4af7-8b09-3bc6bd83fd65 | Debian-9 | active |
| b20aa3ec-2fd9-4350-80b3-0d590bd5998f | Fedora-33 | active |
| f9ef2681-3083-43ae-83b6-7c3e3be08ee3 | Fedora-34 | active |
| d920b7b4-36a4-4d46-b1f0-70c1bc9c9530 | Fedora-35 | active |
| 03a87e23-77e5-403b-a437-10e0b28b2583 | Ubuntu-14.04 | active |
| 6d73bd0e-1db4-452a-84c6-adaad0bae72a | Ubuntu-18.04 | active |
| 6da7de0c-fb47-4ffc-9f72-58323efcc842 | Ubuntu-20.04 | active |
| 2b2c61c6-324c-47f4-88c1-9ae8a978ddfd | Ubuntu-22.04 | active |

This lists the images available to your tennant.

[user@localhost]$ openstack volume list
| ID | Name | Status | Size | Attached to |
| 539dcff1-117b-472a-8cf6-f7069d8a545f | | in-use | 3 | Attached to Ubuntu22 on /dev/vda |

This lists the volumes you have created.

[user@localhost]$ openstack server create --key-name my_key --image Ubuntu-22.04 --flavor 100 awesome_server

This creates an Ubuntu 22.04 instance with the gp1.subsonic flavor (ID 100), and uses the key called my_key.


Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?