25.05.2023

CLI. How to manage cloud infrastructure via the command line

Users can manage cloud infrastructure via various management tools, for example the Application Program Interface (API) or the Command Line Interface (CLI). In this article, we'll take an in-depth look at what the CLI is and how this tool allows you to work with your virtual infrastructure. The command line allows administrators and developers to perform various operations using familiar commands and scripts, providing a convenient and efficient way to manage.

Before the advent of graphical interfaces (GUIs), one of the few ways to interact with a PC was via command language. Despite the advent of GUIs, today the command line is still an important tool, it provides the fastest access to computer/server functions.

What is CLI?

The CLI (Command Line Interface) is a tool for interacting with a computer system or software by entering commands in text format.

The CLI main idea is entering commands at the command line, the system executes them, and returns the results. Commands can include operations such as creating, reading, updating, and deleting resources, configuring system settings, managing network connections, and more. In the case of cloud providers, the CLI allows users to control the infrastructure in the terminal.

CLI features

The CLI is routinely used by system administrators, software developers, network engineers, and other technical professionals to manage and configure computer systems, servers, networks, and programs. It can also be useful for automating daily tasks, managing remote systems and programs over a network, and improving work efficiency.

How the CLI works

The user needs to enter text commands into the interface line and wait for the result. During this process, the CLI converts the queries into functions that the OS understands and then outputs a response. Commands can include a single word or multiple lines (scripts).

For example, this command in Serverspace CLI allows you to know the size of the hard disk:

>s2ctl server get-volume l1s12345 --volume-id 20210

* s2ctl is a Serverspace utility that allows you to interact with the infrastructure in the terminal.

Result:

id: 20210
name: boot
server_id: l1s12345
size_mb: 25600
created: '1970-01-01T0:00:00.0000000Z'

The CLI tool is useful for automating tasks. You or your team can develop a list of commands that the system will execute at a particular time or in a particular situation.

Serverspace cloud CLI

The Serverspace CLI allows you to manage cloud infrastructure and other services. The following functions are available: configuring and monitoring virtual machines, managing network settings, security with SSH keys and project coordination. The CLI allows you to execute the actions available in the Serverspace control panel using commands and the input line.

Whether you use Linux or Windows, executable binaries are available for you to download from the GitHub CLI. Simply download the desired file and run it on your computer. To make the CLI easier to access, you can also add the path to the executable folder to your PATH environment variable. This will allow you to call the CLI from any directory on your system, making it even more convenient and accessible to use.

The CLI allows you to automate interaction with cloud servers and get prompt responses to requests without opening the control panel. The main actions that can be done using the command line interface:

To start using the Serverspace CLI, you must install it, which will differ depending on the operating system: Linux or Windows.

Linux command line interface

First you need to download the file from GitHub and then unzip the archive.

tar -xzf s2ctl-vX.X.X-linux.tar.gz

You can also add the folder where you put the s2ctl to your PATH environment variable so you can access it from anywhere on your system. To see what your $PATH is now, type this into the terminal:

echo $PATH

To add a new directory to the list, use the command:

export PATH=$PATH:""

This $PATH variable is set by your shell each time it starts, but you can set it so that it always includes your new path whenever you open a new shell. The exact way to do this depends on which shell you're using.

Detailed setup instructions are available on GitHub.

Windows command line interface

Download the file from GitHub and unzip it. Then run the command line on your computer. By default, the command line displays the directory of the current user. Navigate to the directory with the extracted file:

cd

After navigating to the desired directory, run the command:

s2ctl

Don't forget to set the PATH in Windows.

Detailed configuration instructions are available on GitHub.