linode-cli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Linode CLI Skill

Linode CLI 使用技能

The official command-line interface for Linode/Akamai cloud infrastructure. Provides easy access to Linode API endpoints directly from the terminal for managing compute instances, Kubernetes clusters, volumes, networking, DNS, and more.
Linode/Akamai云基础设施的官方命令行界面。可直接从终端访问Linode API端点,用于管理计算实例、Kubernetes集群、存储卷、网络、DNS等资源。

When to Use This Skill

何时使用本技能

This skill should be triggered when:
  • Managing Linode compute instances (creating, listing, updating, deleting Linodes)
  • Working with Linode Kubernetes Engine (LKE) clusters and node pools
  • Configuring DNS domains and records through Linode's DNS Manager
  • Managing Block Storage volumes and volume attachments
  • Setting up NodeBalancers and networking infrastructure
  • Automating Linode operations in scripts or CI/CD pipelines
  • Learning Linode CLI commands and API interactions
  • Debugging Linode CLI issues or authentication problems
  • Formatting CLI output (JSON, tables, custom fields)
当出现以下场景时,应使用本技能:
  • 管理Linode计算实例(创建、列出、更新、删除Linode实例)
  • 操作Linode Kubernetes Engine (LKE) 集群和节点池
  • 通过Linode DNS管理器配置DNS域名及记录
  • 管理块存储卷及卷挂载
  • 设置NodeBalancers和网络基础设施
  • 在脚本或CI/CD流水线中自动化Linode操作
  • 学习Linode CLI命令及API交互方式
  • 调试Linode CLI问题或认证故障
  • 格式化CLI输出(JSON、表格、自定义字段)

Key Concepts

核心概念

CLI Architecture

CLI架构

  • Auto-generated from OpenAPI: The CLI is automatically generated from Linode's OpenAPI specification, providing direct access to all API endpoints
  • Python-based: Built with Python 3.10+, installed via pip
  • Command structure:
    linode-cli <resource> <action> [options]
  • Authentication: Uses API tokens stored in configuration or environment variables
  • 基于OpenAPI自动生成:CLI由Linode的OpenAPI规范自动生成,可直接访问所有API端点
  • 基于Python开发:使用Python 3.10+构建,通过pip安装
  • 命令结构
    linode-cli <资源> <操作> [选项]
  • 认证方式:使用存储在配置文件或环境变量中的API令牌

Core Resources

核心资源

  • linodes: Compute instances (virtual machines)
  • lke: Linode Kubernetes Engine clusters
  • domains: DNS domain management
  • volumes: Block Storage volumes
  • nodebalancers: Load balancers
  • regions: Available data center locations
  • images: OS images and custom images
  • linodes:计算实例(虚拟机)
  • lke:Linode Kubernetes Engine集群
  • domains:DNS域名管理
  • volumes:块存储卷
  • nodebalancers:负载均衡器
  • regions:可用的数据中心位置
  • images:操作系统镜像和自定义镜像

Output Formatting

输出格式

  • Default: Organized tables with key information
  • --json: Raw JSON output for scripting
  • --pretty: Formatted JSON with indentation
  • --format: Custom field selection
  • --all: Show all available fields
  • 默认格式:包含关键信息的结构化表格
  • --json:用于脚本开发的原始JSON输出
  • --pretty:带缩进的格式化JSON输出
  • --format:自定义字段选择
  • --all:显示所有可用字段

Quick Reference

快速参考

Installation and Setup

安装与配置

bash
undefined
bash
undefined

Install via pip

通过pip安装

pip3 install linode-cli
pip3 install linode-cli

First-time configuration (interactive)

首次交互式配置

linode-cli configure
linode-cli configure

Set API token via environment

通过环境变量设置API令牌

export LINODE_CLI_TOKEN=your_api_token_here
undefined
export LINODE_CLI_TOKEN=your_api_token_here
undefined

Getting Help

获取帮助

bash
undefined
bash
undefined

View all available commands

查看所有可用命令

linode-cli --help
linode-cli --help

View help for specific resource

查看特定资源的帮助

linode-cli linodes --help
linode-cli linodes --help

View help for specific action

查看特定操作的帮助

linode-cli linodes create --help
linode-cli linodes create --help

List all available regions

列出所有可用数据中心

linode-cli regions list
linode-cli regions list

List all available images

列出所有可用镜像

linode-cli images list
undefined
linode-cli images list
undefined

Listing Resources

列出资源

bash
undefined
bash
undefined

List all Linodes on your account

列出账户下所有Linode实例

linode-cli linodes list
linode-cli linodes list

List domains

列出域名

linode-cli domains list
linode-cli domains list

List volumes

列出存储卷

linode-cli volumes list
linode-cli volumes list

List Kubernetes clusters

列出Kubernetes集群

linode-cli lke clusters-list
linode-cli lke clusters-list

Format output with custom fields

自定义字段格式输出

linode-cli linodes list --format "id,label,status,region"
linode-cli linodes list --format "id,label,status,region"

Output as JSON

以JSON格式输出

linode-cli linodes list --json
linode-cli linodes list --json

Output all available fields

显示所有可用字段

linode-cli linodes list --all
undefined
linode-cli linodes list --all
undefined

Creating Compute Instances

创建计算实例

bash
undefined
bash
undefined

Create a basic Linode (uses defaults from config)

创建基础Linode实例(使用配置默认值)

linode-cli linodes create
--type g6-standard-2
--region us-east
--image linode/debian11
--label my-server
--root_pass "SecurePassword123!"
linode-cli linodes create
--type g6-standard-2
--region us-east
--image linode/debian11
--label my-server
--root_pass "SecurePassword123!"

Create with specific configuration

创建自定义配置的Linode实例

linode-cli linodes create
--type g6-standard-4
--region us-central
--image linode/ubuntu22.04
--label production-web
--root_pass "MySecurePass!"
--group webservers
linode-cli linodes create
--type g6-standard-4
--region us-central
--image linode/ubuntu22.04
--label production-web
--root_pass "MySecurePass!"
--group webservers

Create with authorized SSH keys

创建带授权SSH密钥的Linode实例

linode-cli linodes create
--type g6-standard-2
--region us-west
--image linode/debian11
--label secure-server
--root_pass "Password123!"
--authorized_keys "ssh-rsa AAAAB3Nz..."
undefined
linode-cli linodes create
--type g6-standard-2
--region us-west
--image linode/debian11
--label secure-server
--root_pass "Password123!"
--authorized_keys "ssh-rsa AAAAB3Nz..."
undefined

Managing Kubernetes (LKE)

管理Kubernetes (LKE)

bash
undefined
bash
undefined

Create a Kubernetes cluster with multiple node pools

创建包含多个节点池的Kubernetes集群

linode-cli lke cluster-create
--label my-k8s-cluster
--region us-central
--k8s_version 1.28
--node_pools.type g6-standard-4 --node_pools.count 3
--node_pools.type g6-standard-8 --node_pools.count 2
--tags production
linode-cli lke cluster-create
--label my-k8s-cluster
--region us-central
--k8s_version 1.28
--node_pools.type g6-standard-4 --node_pools.count 3
--node_pools.type g6-standard-8 --node_pools.count 2
--tags production

List all clusters

列出所有集群

linode-cli lke clusters-list
linode-cli lke clusters-list

Update cluster configuration

更新集群配置

linode-cli lke cluster-update $CLUSTER_ID
--label renamed-cluster
--tags production
--tags monitoring
--tags backup
linode-cli lke cluster-update $CLUSTER_ID
--label renamed-cluster
--tags production
--tags monitoring
--tags backup

Update node pool size

更新节点池规模

linode-cli lke pool-update $CLUSTER_ID $POOL_ID
--count 5
linode-cli lke pool-update $CLUSTER_ID $POOL_ID
--count 5

Delete a cluster

删除集群

linode-cli lke cluster-delete $CLUSTER_ID
undefined
linode-cli lke cluster-delete $CLUSTER_ID
undefined

DNS Management

DNS管理

bash
undefined
bash
undefined

Create a domain

创建域名

linode-cli domains create
--type master
--domain example.com
--soa_email admin@example.com
linode-cli domains create
--type master
--domain example.com
--soa_email admin@example.com

List domains

列出域名

linode-cli domains list
linode-cli domains list

Create DNS record

创建DNS记录

linode-cli domains records-create $DOMAIN_ID
--type A
--name www
--target 192.0.2.1
linode-cli domains records-create $DOMAIN_ID
--type A
--name www
--target 192.0.2.1

Delete a domain

删除域名

linode-cli domains delete $DOMAIN_ID
undefined
linode-cli domains delete $DOMAIN_ID
undefined

Volume Management

存储卷管理

bash
undefined
bash
undefined

Create a Block Storage volume

创建块存储卷

linode-cli volumes create
--label my-volume
--size 100
--region us-east
linode-cli volumes create
--label my-volume
--size 100
--region us-east

List volumes

列出存储卷

linode-cli volumes list
linode-cli volumes list

Attach volume to Linode

将存储卷挂载到Linode实例

linode-cli volumes attach $VOLUME_ID
--linode_id $LINODE_ID
linode-cli volumes attach $VOLUME_ID
--linode_id $LINODE_ID

Detach volume

卸载存储卷

linode-cli volumes detach $VOLUME_ID
undefined
linode-cli volumes detach $VOLUME_ID
undefined

Advanced Usage

高级用法

bash
undefined
bash
undefined

Filtering output with jq (requires jq installed)

使用jq过滤输出(需提前安装jq)

linode-cli linodes list --json | jq '.[] | select(.status=="running")'
linode-cli linodes list --json | jq '.[] | select(.status=="running")'

Using variables in scripts

在脚本中使用变量

LINODE_ID=$(linode-cli linodes list --json | jq -r '.[0].id') echo "First Linode ID: $LINODE_ID"
LINODE_ID=$(linode-cli linodes list --json | jq -r '.[0].id') echo "第一个Linode实例ID: $LINODE_ID"

Bulk operations example

批量操作示例

for region in us-east us-west eu-central; do linode-cli linodes create
--type g6-nanode-1
--region $region
--image linode/alpine3.18
--label "test-$region"
--root_pass "TempPassword123!" done
undefined
for region in us-east us-west eu-central; do linode-cli linodes create
--type g6-nanode-1
--region $region
--image linode/alpine3.18
--label "test-$region"
--root_pass "TempPassword123!" done
undefined

Reference Files

参考文件

This skill includes comprehensive documentation in
references/
:
  • other.md - Links to official Linode CLI Wiki on GitHub with additional documentation, guides, and community resources
Use
view
to read specific reference files when detailed information is needed.
本技能在
references/
目录中包含完整文档:
  • other.md - 指向GitHub上的官方Linode CLI Wiki,包含额外文档、指南和社区资源
当需要详细信息时,使用
view
命令查看特定参考文件。

Working with This Skill

如何使用本技能

For Beginners

面向初学者

  1. Start with installation: Run
    pip3 install linode-cli
    and configure with
    linode-cli configure
  2. Learn the basics: Use
    --help
    flag extensively to discover available commands
  3. Practice listing: Start with simple list commands like
    linode-cli linodes list
  4. Test in safe mode: Use small, inexpensive instance types (g6-nanode-1) for testing
  5. Read the output: Default table output is designed to be human-readable
  1. 从安装开始:运行
    pip3 install linode-cli
    并通过
    linode-cli configure
    完成配置
  2. 学习基础操作:广泛使用
    --help
    参数探索可用命令
  3. 练习列出资源:从简单的列表命令开始,如
    linode-cli linodes list
  4. 安全测试:使用小型低成本实例类型(g6-nanode-1)进行测试
  5. 阅读输出内容:默认表格格式专为人类可读性设计

For Intermediate Users

面向中级用户

  1. Master output formatting: Learn
    --json
    ,
    --format
    , and
    --all
    flags for scripting
  2. Automate common tasks: Create bash scripts for repetitive operations
  3. Combine with jq: Use jq for powerful JSON filtering and processing
  4. Manage multiple resources: Create infrastructure as code with shell scripts
  5. Use environment variables: Set
    LINODE_CLI_TOKEN
    for non-interactive automation
  1. 掌握输出格式化:学习使用
    --json
    --format
    --all
    参数用于脚本开发
  2. 自动化常见任务:创建bash脚本完成重复性操作
  3. 结合jq使用:利用jq实现强大的JSON过滤和处理
  4. 管理多类资源:通过shell脚本实现基础设施即代码
  5. 使用环境变量:设置
    LINODE_CLI_TOKEN
    实现非交互式自动化

For Advanced Users

面向高级用户

  1. CI/CD integration: Incorporate linode-cli into deployment pipelines
  2. Infrastructure automation: Build complete infrastructure provisioning scripts
  3. API exploration: Use the CLI to understand Linode's API structure
  4. Custom tooling: Wrap linode-cli in your own management tools
  5. OpenAPI access: Contribute to the OpenAPI spec for new features
  1. CI/CD集成:将linode-cli融入部署流水线
  2. 基础设施自动化:构建完整的基础设施部署脚本
  3. API探索:通过CLI了解Linode的API结构
  4. 自定义工具开发:基于linode-cli封装自有管理工具
  5. OpenAPI访问:为新功能贡献OpenAPI规范

Navigation Tips

导航技巧

  • Discover resources: Use
    linode-cli --help
    to see all available resource types
  • Action discovery: Each resource has different actions (list, create, update, delete, etc.)
  • Parameter help: Use
    --help
    on any action to see required and optional parameters
  • JSON inspection: Use
    --json
    to see all available fields for any resource
  • Region planning: Run
    linode-cli regions list
    before creating resources
  • 发现资源类型:使用
    linode-cli --help
    查看所有可用资源类型
  • 探索操作选项:每个资源有不同的操作(列出、创建、更新、删除等)
  • 查看参数帮助:对任意操作使用
    --help
    查看必填和可选参数
  • JSON内容检查:使用
    --json
    查看任意资源的所有可用字段
  • 区域规划:创建资源前运行
    linode-cli regions list
    查看可用数据中心

Common Patterns

常见模式

Authentication Setup

认证配置

bash
undefined
bash
undefined

Method 1: Interactive configuration

方式1:交互式配置

linode-cli configure
linode-cli configure

Method 2: Environment variable

方式2:环境变量

export LINODE_CLI_TOKEN=your_token_here
export LINODE_CLI_TOKEN=your_token_here

Method 3: Config file (~/.config/linode-cli)

方式3:配置文件(~/.config/linode-cli)

[DEFAULT] token = your_token_here region = us-east type = g6-standard-2 image = linode/ubuntu22.04
undefined
[DEFAULT] token = your_token_here region = us-east type = g6-standard-2 image = linode/ubuntu22.04
undefined

Instance Lifecycle

实例生命周期

bash
undefined
bash
undefined

Create → Boot (automatic) → Use → Power off → Delete

创建 → 启动(自动)→ 使用 → 关机 → 删除

linode-cli linodes create --label test --type g6-nanode-1 --region us-east --image linode/alpine3.18 --root_pass "Test123!"
linode-cli linodes create --label test --type g6-nanode-1 --region us-east --image linode/alpine3.18 --root_pass "Test123!"

Get ID from output or list

从输出或列表中获取实例ID

LINODE_ID=$(linode-cli linodes list --json | jq -r '.[] | select(.label=="test") | .id')
LINODE_ID=$(linode-cli linodes list --json | jq -r '.[] | select(.label=="test") | .id')

Shutdown

关机

linode-cli linodes shutdown $LINODE_ID
linode-cli linodes shutdown $LINODE_ID

Delete

删除

linode-cli linodes delete $LINODE_ID
undefined
linode-cli linodes delete $LINODE_ID
undefined

Scripting Pattern

脚本编写示例

bash
#!/bin/bash
set -e  # Exit on error
bash
#!/bin/bash
set -e  # 出错即退出

Configuration

配置参数

REGION="us-central" TYPE="g6-standard-2" IMAGE="linode/debian11"
REGION="us-central" TYPE="g6-standard-2" IMAGE="linode/debian11"

Create instance

创建实例

echo "Creating Linode..." RESULT=$(linode-cli linodes create
--type "$TYPE"
--region "$REGION"
--image "$IMAGE"
--label "auto-server-$(date +%s)"
--root_pass "$(openssl rand -base64 32)"
--json)
echo "正在创建Linode实例..." RESULT=$(linode-cli linodes create
--type "$TYPE"
--region "$REGION"
--image "$IMAGE"
--label "auto-server-$(date +%s)"
--root_pass "$(openssl rand -base64 32)"
--json)

Extract ID

提取实例ID

LINODE_ID=$(echo "$RESULT" | jq -r '.[0].id') echo "Created Linode ID: $LINODE_ID"
LINODE_ID=$(echo "$RESULT" | jq -r '.[0].id') echo "已创建Linode实例ID: $LINODE_ID"

Wait for running status

等待实例进入运行状态

while true; do STATUS=$(linode-cli linodes view $LINODE_ID --json | jq -r '.[0].status') echo "Status: $STATUS" [[ "$STATUS" == "running" ]] && break sleep 5 done
echo "Linode is ready!"
undefined
while true; do STATUS=$(linode-cli linodes view $LINODE_ID --json | jq -r '.[0].status') echo "当前状态: $STATUS" [[ "$STATUS" == "running" ]] && break sleep 5 done
echo "Linode实例已就绪!"
undefined

Resources

相关资源

Official Documentation

官方文档

Key Features

核心特性

  • Auto-completion: Bash completion available for command discovery
  • OpenAPI-driven: Always up-to-date with latest API features
  • Cross-platform: Works on Linux, macOS, and Windows (via WSL)
  • Scriptable: Perfect for automation and infrastructure as code
  • Comprehensive: Access to all Linode API endpoints
  • 自动补全:支持Bash自动补全,便于命令发现
  • OpenAPI驱动:始终与最新API功能保持同步
  • 跨平台:支持Linux、macOS和Windows(通过WSL)
  • 可脚本化:非常适合自动化和基础设施即代码场景
  • 功能全面:可访问所有Linode API端点

Community

社区信息

  • Contributors: 49 active contributors
  • License: BSD-3-Clause
  • Language: Python (98.8%)
  • Installation: PyPI package (pip installable)
  • 贡献者:49位活跃贡献者
  • 许可证:BSD-3-Clause
  • 开发语言:Python(98.8%)
  • 安装方式:PyPI包(可通过pip安装)

Tips and Best Practices

技巧与最佳实践

Security

安全建议

  • Protect tokens: Never commit API tokens to version control
  • Use environment variables: Store tokens in
    .env
    files (git-ignored)
  • Rotate regularly: Generate new tokens periodically
  • Limit permissions: Use scoped tokens with minimal required permissions
  • Strong passwords: Always use strong root passwords for instances
  • 保护令牌:切勿将API令牌提交到版本控制系统
  • 使用环境变量:将令牌存储在.gitignore的.env文件中
  • 定期轮换令牌:定期生成新令牌
  • 限制权限:使用仅包含必要权限的范围令牌
  • 强密码:始终为实例设置强密码

Cost Management

成本管理

  • Start small: Use nanode instances (g6-nanode-1) for testing
  • Delete unused: Remove test instances to avoid unnecessary charges
  • Monitor usage: Regularly check your account for active resources
  • Use tags: Organize resources with tags for easier management
  • 从小规模开始:使用nanode实例(g6-nanode-1)进行测试
  • 删除未使用资源:移除测试实例以避免不必要的费用
  • 监控使用情况:定期检查账户中的活跃资源
  • 使用标签:通过标签组织资源,便于管理

Debugging

调试技巧

  • Verbose output: Add
    --debug
    flag for detailed error information
  • JSON inspection: Use
    --json --pretty
    to see full API responses
  • Check status: Use
    view
    commands to inspect resource details
  • API reference: Consult the API docs for endpoint specifics
  • 详细输出:添加
    --debug
    参数获取详细错误信息
  • JSON内容检查:使用
    --json --pretty
    查看完整API响应
  • 查看资源状态:使用view命令检查资源详情
  • 参考API文档:查阅API文档了解端点具体信息

Troubleshooting

故障排除

Authentication Issues

认证问题

bash
undefined
bash
undefined

Verify token is set

验证令牌是否已设置

echo $LINODE_CLI_TOKEN
echo $LINODE_CLI_TOKEN

Test authentication

测试认证

linode-cli account view
linode-cli account view

Reconfigure CLI

重新配置CLI

linode-cli configure
undefined
linode-cli configure
undefined

Common Errors

常见错误

  • 401 Unauthorized: Invalid or expired API token
  • 404 Not Found: Resource ID doesn't exist or wrong region
  • 422 Unprocessable: Missing required parameters or validation error
  • 429 Rate Limited: Too many requests, implement backoff
  • 401 Unauthorized:API令牌无效或已过期
  • 404 Not Found:资源ID不存在或区域错误
  • 422 Unprocessable:缺少必填参数或验证失败
  • 429 Rate Limited:请求过于频繁,需实现退避机制

Getting Help

获取帮助

bash
undefined
bash
undefined

Check CLI version

检查CLI版本

linode-cli --version
linode-cli --version

View debug information

查看调试信息

linode-cli linodes list --debug
linode-cli linodes list --debug

Check configuration

检查配置

cat ~/.config/linode-cli
undefined
cat ~/.config/linode-cli
undefined

Notes

注意事项

  • This skill was generated from official Linode CLI documentation
  • The CLI is automatically generated from Linode's OpenAPI specification
  • All commands and examples are based on the official Linode API v4
  • Command syntax and available options may change with API updates
  • Always refer to
    --help
    for the most current command documentation
  • 本技能基于官方Linode CLI文档生成
  • CLI由Linode的OpenAPI规范自动生成
  • 所有命令和示例均基于官方Linode API v4
  • 命令语法和可用选项可能随API更新而变化
  • 始终使用
    --help
    查看最新的命令文档

Updating

更新说明

To stay current with Linode CLI:
bash
undefined
如需保持Linode CLI为最新版本:
bash
undefined

Update via pip

通过pip升级

pip3 install --upgrade linode-cli
pip3 install --upgrade linode-cli

Check for new features

查看新功能

linode-cli --help
linode-cli --help

Review changelog

查看更新日志

pip3 show linode-cli

The CLI is regularly updated to reflect changes in the Linode API. Check the GitHub repository for release notes and breaking changes.
pip3 show linode-cli

CLI会定期更新以匹配Linode API的变化。请查看GitHub仓库获取发布说明和破坏性变更信息。