linode-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLinode 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
undefinedbash
undefinedInstall 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
undefinedexport LINODE_CLI_TOKEN=your_api_token_here
undefinedGetting Help
获取帮助
bash
undefinedbash
undefinedView 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
undefinedlinode-cli images list
undefinedListing Resources
列出资源
bash
undefinedbash
undefinedList 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
undefinedlinode-cli linodes list --all
undefinedCreating Compute Instances
创建计算实例
bash
undefinedbash
undefinedCreate 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!"
--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!"
--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
--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
--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..."
--type g6-standard-2
--region us-west
--image linode/debian11
--label secure-server
--root_pass "Password123!"
--authorized_keys "ssh-rsa AAAAB3Nz..."
undefinedlinode-cli linodes create
--type g6-standard-2
--region us-west
--image linode/debian11
--label secure-server
--root_pass "Password123!"
--authorized_keys "ssh-rsa AAAAB3Nz..."
--type g6-standard-2
--region us-west
--image linode/debian11
--label secure-server
--root_pass "Password123!"
--authorized_keys "ssh-rsa AAAAB3Nz..."
undefinedManaging Kubernetes (LKE)
管理Kubernetes (LKE)
bash
undefinedbash
undefinedCreate 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
--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
--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
--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
--label renamed-cluster
--tags production
--tags monitoring
--tags backup
Update node pool size
更新节点池规模
linode-cli lke pool-update $CLUSTER_ID $POOL_ID
--count 5
--count 5
linode-cli lke pool-update $CLUSTER_ID $POOL_ID
--count 5
--count 5
Delete a cluster
删除集群
linode-cli lke cluster-delete $CLUSTER_ID
undefinedlinode-cli lke cluster-delete $CLUSTER_ID
undefinedDNS Management
DNS管理
bash
undefinedbash
undefinedCreate a domain
创建域名
linode-cli domains create
--type master
--domain example.com
--soa_email admin@example.com
--type master
--domain example.com
--soa_email admin@example.com
linode-cli domains create
--type master
--domain example.com
--soa_email admin@example.com
--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
--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
--type A
--name www
--target 192.0.2.1
Delete a domain
删除域名
linode-cli domains delete $DOMAIN_ID
undefinedlinode-cli domains delete $DOMAIN_ID
undefinedVolume Management
存储卷管理
bash
undefinedbash
undefinedCreate a Block Storage volume
创建块存储卷
linode-cli volumes create
--label my-volume
--size 100
--region us-east
--label my-volume
--size 100
--region us-east
linode-cli volumes create
--label my-volume
--size 100
--region us-east
--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_id $LINODE_ID
linode-cli volumes attach $VOLUME_ID
--linode_id $LINODE_ID
--linode_id $LINODE_ID
Detach volume
卸载存储卷
linode-cli volumes detach $VOLUME_ID
undefinedlinode-cli volumes detach $VOLUME_ID
undefinedAdvanced Usage
高级用法
bash
undefinedbash
undefinedFiltering 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
--type g6-nanode-1
--region $region
--image linode/alpine3.18
--label "test-$region"
--root_pass "TempPassword123!" done
undefinedfor 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
--type g6-nanode-1
--region $region
--image linode/alpine3.18
--label "test-$region"
--root_pass "TempPassword123!" done
undefinedReference 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 to read specific reference files when detailed information is needed.
view本技能在目录中包含完整文档:
references/- other.md - 指向GitHub上的官方Linode CLI Wiki,包含额外文档、指南和社区资源
当需要详细信息时,使用命令查看特定参考文件。
viewWorking with This Skill
如何使用本技能
For Beginners
面向初学者
- Start with installation: Run and configure with
pip3 install linode-clilinode-cli configure - Learn the basics: Use flag extensively to discover available commands
--help - Practice listing: Start with simple list commands like
linode-cli linodes list - Test in safe mode: Use small, inexpensive instance types (g6-nanode-1) for testing
- Read the output: Default table output is designed to be human-readable
- 从安装开始:运行并通过
pip3 install linode-cli完成配置linode-cli configure - 学习基础操作:广泛使用参数探索可用命令
--help - 练习列出资源:从简单的列表命令开始,如
linode-cli linodes list - 安全测试:使用小型低成本实例类型(g6-nanode-1)进行测试
- 阅读输出内容:默认表格格式专为人类可读性设计
For Intermediate Users
面向中级用户
- Master output formatting: Learn ,
--json, and--formatflags for scripting--all - Automate common tasks: Create bash scripts for repetitive operations
- Combine with jq: Use jq for powerful JSON filtering and processing
- Manage multiple resources: Create infrastructure as code with shell scripts
- Use environment variables: Set for non-interactive automation
LINODE_CLI_TOKEN
- 掌握输出格式化:学习使用、
--json和--format参数用于脚本开发--all - 自动化常见任务:创建bash脚本完成重复性操作
- 结合jq使用:利用jq实现强大的JSON过滤和处理
- 管理多类资源:通过shell脚本实现基础设施即代码
- 使用环境变量:设置实现非交互式自动化
LINODE_CLI_TOKEN
For Advanced Users
面向高级用户
- CI/CD integration: Incorporate linode-cli into deployment pipelines
- Infrastructure automation: Build complete infrastructure provisioning scripts
- API exploration: Use the CLI to understand Linode's API structure
- Custom tooling: Wrap linode-cli in your own management tools
- OpenAPI access: Contribute to the OpenAPI spec for new features
- CI/CD集成:将linode-cli融入部署流水线
- 基础设施自动化:构建完整的基础设施部署脚本
- API探索:通过CLI了解Linode的API结构
- 自定义工具开发:基于linode-cli封装自有管理工具
- OpenAPI访问:为新功能贡献OpenAPI规范
Navigation Tips
导航技巧
- Discover resources: Use to see all available resource types
linode-cli --help - Action discovery: Each resource has different actions (list, create, update, delete, etc.)
- Parameter help: Use on any action to see required and optional parameters
--help - JSON inspection: Use to see all available fields for any resource
--json - Region planning: Run before creating resources
linode-cli regions list
- 发现资源类型:使用查看所有可用资源类型
linode-cli --help - 探索操作选项:每个资源有不同的操作(列出、创建、更新、删除等)
- 查看参数帮助:对任意操作使用查看必填和可选参数
--help - JSON内容检查:使用查看任意资源的所有可用字段
--json - 区域规划:创建资源前运行查看可用数据中心
linode-cli regions list
Common Patterns
常见模式
Authentication Setup
认证配置
bash
undefinedbash
undefinedMethod 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
undefinedInstance Lifecycle
实例生命周期
bash
undefinedbash
undefinedCreate → 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
undefinedlinode-cli linodes delete $LINODE_ID
undefinedScripting Pattern
脚本编写示例
bash
#!/bin/bash
set -e # Exit on errorbash
#!/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)
--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)
--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!"
undefinedwhile true; do
STATUS=$(linode-cli linodes view $LINODE_ID --json | jq -r '.[0].status')
echo "当前状态: $STATUS"
[[ "$STATUS" == "running" ]] && break
sleep 5
done
echo "Linode实例已就绪!"
undefinedResources
相关资源
Official Documentation
官方文档
- GitHub Repository: https://github.com/linode/linode-cli
- Akamai TechDocs: https://techdocs.akamai.com/cloud-computing/docs/cli
- API Documentation: https://www.linode.com/docs/api/
- Getting Started Guide: https://techdocs.akamai.com/cloud-computing/docs/getting-started-with-the-linode-cli
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 files (git-ignored)
.env - 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 flag for detailed error information
--debug - JSON inspection: Use to see full API responses
--json --pretty - Check status: Use commands to inspect resource details
view - API reference: Consult the API docs for endpoint specifics
- 详细输出:添加参数获取详细错误信息
--debug - JSON内容检查:使用查看完整API响应
--json --pretty - 查看资源状态:使用view命令检查资源详情
- 参考API文档:查阅API文档了解端点具体信息
Troubleshooting
故障排除
Authentication Issues
认证问题
bash
undefinedbash
undefinedVerify 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
undefinedlinode-cli configure
undefinedCommon 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
undefinedbash
undefinedCheck 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
undefinedcat ~/.config/linode-cli
undefinedNotes
注意事项
- 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 for the most current command documentation
--help
- 本技能基于官方Linode CLI文档生成
- CLI由Linode的OpenAPI规范自动生成
- 所有命令和示例均基于官方Linode API v4
- 命令语法和可用选项可能随API更新而变化
- 始终使用查看最新的命令文档
--help
Updating
更新说明
To stay current with Linode CLI:
bash
undefined如需保持Linode CLI为最新版本:
bash
undefinedUpdate 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仓库获取发布说明和破坏性变更信息。