Command-line interfaces are critical tools for administrators, including those managing cloud environments. While managing a cloud-based virtual machine running Linux is a typical example, CLIs serve a spectrum of uses in cloud administration.
This article explores cloud CLI tools and details how to navigate them using Linux or Linux-inspired commands. It highlights the importance of CLI administration, examines the command-line environments offered by the big three cloud vendors, and provides practical examples of commonly used commands, along with tips to improve efficiency.
Everyday CLI Tasks for Cloud Administrators
Administrators often manage entire bare-metal Linux deployments through the command line. Cloud-based VMs have capabilities similar to those of CLI-based management. Beyond VMs, cloud services can also be managed via the CLI.
Common tasks include:
Provisioning and managing VMs, containers, and virtualization environments like Hyper-V or Kubernetes .
Managing storage, including creating, attaching, detaching, and deleting storage resources.
Configuring cloud network settings and virtual private clouds.
Managing access control settings for cloud users and groups.
Scripting repetitive tasks to streamline workflows.
Managing cloud licenses to ensure compliance and proper usage.
Improving performance metrics to optimize system efficiency.
Updating and patching systems to maintain security and functionality.
Managing system services, such as httpd, sshd, and firewall configurations.
Related:Cloud DLP Playbook: Stopping Data Leaks Before They Happen
Benefits of Command-Line Administration
Working with the CLI might seem retro to some, but seasoned administrators recognize the numerous advantages . Here are three significant benefits to consider:
Speed: The CLI is generally faster than a graphical environment, enabling rapid execution of tasks.
Scriptability: Commands can be added to executable files that systems can process to automate tasks.
Flexibility and options: The CLI often provides more configuration options than graphical tools, offering greater control and customization.
Major Cloud Providers’ CLI Toolsets Compared
The three major cloud providers – AWS, Microsoft, and Google – supply CLI toolsets that administrators can use to perform various tasks.
When using these CLIs, administrators might discover standard features like tab completion and command history. Tab completion autocompletes partially typed commands and suggests contextual subcommands, saving time and reducing errors. Command history enables administrators to quickly repeat recent commands without retyping lengthy strings. While features overlap across these toolsets, each cloud provider has unique capabilities tailored to its platforms.
Related:Bridging the Gap: How Hybrid Cloud Is Redefining the Role of the Data Center
The AWS CLI
The AWS CLI provides a powerful interface for cloud administrators to manage AWS resources. It is compatible with Linux, macOS, and Windows. Once you download and install AWS CLI , enter your AWS credentials.
For AWS Linux users, the AWS CLI comes preinstalled. In addition to the CLI, AWS offers AWS Management Console (graphical interface) and AWS Shell for resource management.
The AWS CLI allows administrators to manage compute, storage, and network resources and automate tasks through scripting. Commands are prefixed with "aws" and resemble standard Linux commands but include AWS-specific parameters.
Getting Started With AWS CLI
1.Installation and Setup
After installing the AWS CLI, open your terminal application and type the aws command to begin configuration and authentication.
Use the following command to configure your AWS credentials:
aws configureThe utility will prompt you for:
AWS Access Key ID
AWS Secret Access Key
Default region name
Default output format
2. Basic Commands
List available S3 buckets:
aws s3 lsListavailable EC2 instances:
aws ec2 describe-instances3. Help and Documentation
Get general help:
Related:How To Optimize Resource Utilization With Kubernetes Pod Scaling
aws helpGet service-specific help:
aws {service} help4. Enable command history:
aws configure set cli_history enabledThe Azure CLI
The Azure CLI is a versatile toolset for managing Azure cloud resources, allowing administrators to automate tasks, manage resources at scale, and interact efficiently with Azure services. It supports multiple platforms, including Windows, macOS, Linux, Docker containers, and the Azure Cloud Shell.
1. Installation
Windows: Use a package manager like WinGet to install Azure CLI.
Linux: Use the appropriate package manager for your distribution, such as dnf or apt.
macOS: Install Azure CLI using Homebrew .
Docker: Run Azure CLI in a Docker container.
Azure Cloud Shell: Access Azure CLI directly within the browser-based Cloud Shell.
2. Starting Azure CLI
On Windows, launch PowerShell or Command Prompt (cmd.exe).
On macOS or Linux, open the standard terminal application.
Type the az command to start the Azure CLI application.
Authentication and Account Management
1. Login:
Authenticating to your Azure environment by typing the following command:
az loginThis opens a browser window where you can sign in with your Azure credentials.
2. View Account Information:
Display your login credentials and Azure account details:
az account show3. Manage Tenants:
Listactive Azure tenant (a tenant is a single instance of a Microsoft Entra ID containing one or more subscriptions):
az account tenant list4. Switch Subscriptions:
Change the active subscription:
az account set --subscription "subscription-name"Command basics and help
Azure CLI commands begin with the az identifier.
To get general help, type the following:
az --helpUse tab completion and command history to streamline your command-line experience.
Additional Notes
Microsoft also offers the Azure PowerShell tool, which uses PowerShell cmdlets exclusively. In contrast, Azure CLI supports both Bash and PowerShell.
The GCP CLI
The Google Cloud Platform CLI enables admins to handle services like Compute Engine, Cloud Storage, Kubernetes, and more from a single interface. Like AWS CLI and Azure CLI, the GCP CLI is cross-platform, supporting Linux, macOS, and Windows. It offers complete support for provisioning and maintaining GCP infrastructure.
Key Features and Usage
1. Automation
Add gcloud commands to shell scripts and CI/CD pipelines to automate administrative tasks as part of DevOps workflows.
2. Local Emulators
One of GCP CLI's most interesting features is the use of local emulators like Bigtable, Datastore, and Firestone to create and test projects without incurring costs or risking live cloud resources.
Installation and Configuration
After installing GCP CLI, configure it by opening a terminal on your workstation and typing:
gcloud initThis command prompts you to:
Authenticate.
Connect to your GCP subscription.
Set preferences (e.g., default project and region).
Once complete, start the GCP CLI by typing gcloud in the terminal.
Authentication
Authenticate to your GCP account:
gcloud auth loginEnable Tab Completion:
For Bash, enable tab completion by running:
source <(gcloud completion bash)Similar commands are available for other shells like Zsh and Fish.
Command History:
GCP CLI uses the local shell's command history capabilities.
Common Commands:
1. Help and Documentation:
Access general help:
gcloud help2. Cloud Storage Management:
Use gsutil for tasks like uploading, downloading, and managing storage buckets.
3. BigQuery Administration
Use bq to manage datasets and queries in BigQuery.
The Value of Cloud CLI Tools
Working with a cloud service provider's CLI tools gives administrators many advantages, including efficiency, flexibility, and automation. Key features and standards to look out for include:
Scriptability and Automation: CLI tools enable administrators to automate repetitive tasks, ensuring consistency and saving time.
Preinstalled Utilities: Many cloud CLI tools come preinstalled on specific platforms (e.g., AWS CLI on AWS Linux), simplifying setup.
Command Prefixes: Each provider uses a unique prefix for commands:
AWS CLI: aws
Azure CLI: az
GCP Cli: gcloud
Ease of Deployment: CLI tools are easy to install and manage using package managers like apt, dnf, Homebrew, or WinGet, depending on your operating system.
If your organization has already selected a cloud service provider – or is operating in a multi-cloud scenario – start exploring the provider's CLI utility.
About the Author
Contributor, Cogspinner Coaction, LLC
Damon Garn owns Cogspinner Coaction, LLC, an IT writing and editing company. Damon authors articles, tutorials, and labs for today's top IT industry leaders. He regularly contributes to The New Stack, Informa TechTarget, and CompTIA. Damon has authored eight official courseware titles for CompTIA and developed hands-on labs for five of them. Damon has 20 years of experience as a technical trainer and sysadmin covering Linux, Windows Server, and security content. He lives in Colorado Springs with his family. He is a writer and musician.
You May Also Like