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
- provides a wide range of commands and parameters that allow users to flexibly configure and manage infrastructure to meet the unique requirements of organization. Users can perform operations such as creating, modifying, scaling and deleting resources, configuring security settings, and more. Unlike the graphical user interface (GUI), where interaction with the system is done with a mouse and graphical elements, the CLI allows the user to more precisely control operations and perform complex tasks using commands. It makes it possible to automate tasks, create scripts to execute a series of commands, and integrate the CLI with other programs and systems.
- allows users to automate tasks and operations in your infrastructure using scripts and batch files. You can create scripts to execute a series of commands, which greatly simplifies and speeds up repetitive tasks and processes. This saves time and resources, and ensures repeatability and consistency in infrastructure management.
- provides direct and fast access to operations and infrastructure resources. You can use commands to perform actions and get results instantly, without having to navigate via a graphical interface. This saves time and simplifies the management process.
- provides full control and manageability over your infrastructure. You can pinpoint settings and configurations and monitor and analyze resource health. The CLI allows you to manage access and user rights, ensuring security and compliance with your organization's policies.
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 is a Serverspace utility that allows you to interact with the infrastructure in the terminal.
Result:
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:
- create virtual machines (VMs);
- View server information and manage server power;
- scale the VM configuration;
- connect networks;
- manage SSH keys;
- create snapshots;
- create and delete gateways, and configure NAT and Firewall rules;
- view detailed information about the project;
- create and delete a domain name.
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.
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:
To add a new directory to the list, use the command:
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:
After navigating to the desired directory, run the command:
Don't forget to set the PATH in Windows.
Detailed configuration instructions are available on GitHub.