CLI - Get Started
The Linode CLI is a wrapper around the Linode API that allows you to manage your Linode account from the command line. Virtually any task that can be done through the Linode Manager can be done through the CLI, making it an excellent tool for scripting.
This guide describes the basics of installing and working with the CLI. It also offers examples illustrating how to complete common tasks using the CLI.
Install the CLI
The easiest way to install the CLI is through Pip:
Install the CLI:
pip3 install linode-cli --upgrade
If you haven’t yet installed python3
and pip3
, below is a brief outline separated by Distro and Operating System to help you complete the basic installation process:
Ubuntu/Debian
Ensure that all available packages are up to date:
sudo apt update
Install python3 and pip3:
sudo apt install python3 && sudo apt install python3-pip
Install the Linode CLI using pip3:
sudo pip3 install linode-cli
CentOS/RHEL Stream and Fedora
Ensure that all available packages are up to date:
dnf upgrade
Install python3 and pip3:
sudo dnf install python3 && sudo dnf install python3-pip
Install the Linode CLI using pip3:
sudo pip3 install linode-cli
CentOS 7
Ensure that all available packages are up to date:
sudo yum update
Install python3 and pip3:
sudo yum install python3 && sudo yum install python3-pip
Install the Linode CLI using pip3:
sudo pip3 install linode-cli
Windows 10
Download the latest stable Windows package for python3 for your system at Python’s Downloads Page.
Open up the installer
.exe
to begin the python installation process using Window’s GUI.Before proceeding, ensure that your version of Python is added to PATH by checking the box which enables this option:
Select the Customize Installation option to proceed.
Ensure that
pip
all desired optional features are selected before proceeding to the next step. Thepip
installation is required by the Linode CLI.In the next step, ensure that the Install for all users option is enabled. Your configuration should reflect the following:
Select
Next
to proceed with the installation. Once the installation is complete, a message will confirm Python3 was successfully installed will appear that can be safely closed.Open the windows command prompt and enter the following command to complete installation of the Linode CLI:
sudo pip3 install linode-cli
Mac OSx
By default, python3 should already be installed and configured on the latest versions of Mac OSx. If for whatever reason it is not, you can use brew
to install python3 which will additionally include pip
by default:
brew install python3
Initial Configuration of the Linode CLI
You need a Personal Access Token to use the CLI. Use the Linode Cloud Manager to obtain a token.
Run the
linode-cli configure --token
command, you will be prompted with the CLI’s configuration script. Paste your access token (which will then be used by default for all requests made through the CLI) at the prompt. You will be prompted to choose defaults for Linodes created through the CLI (region, type, and image). These are optional, and can be overridden for individual commands. Update these defaults at any time by runninglinode-cli configure
:Welcome to the Linode CLI. This will walk you through some initial setup. First, we need a Personal Access Token. To get one, please visit https://cloud.linode.com/profile/tokens and click "Create a Personal Access Token". The CLI needs access to everything on your account to work correctly. Personal Access Token:
NoteThe CLI installs a bash completion file. On OSX, you may have to source this file before it can be used. To do this, addsource /etc/bash_completion.d/linode-cli.sh
to your~/.bashrc
file.
Options
Help
View information about any part of the CLI, including available actions and required parameters, with the --help
flag:
linode-cli --help
linode-cli linodes --help
linode-cli linodes create --help
Customize Output Fields
By default, the CLI displays a set of pre-selected fields for each type of response. If you would like to see all available fields, use the --all
flag:
linode-cli linodes list --all
Specify exactly which fields you would like to receive with the -format
option:
linode-cli linodes list --format 'id,region,memory'
JSON Output
The CLI returns output in tabulated format for easy readability. If you prefer to work with JSON, use the --json
flag. Adding the --pretty
flag formats the JSON output to make it more readable:
linode-cli regions list --json --pretty
|
|
Machine Readable Output
You can also display the output as plain text. By default, tabs are used as a delimiter, but you can specify another character with the --delimiter
option:
linode-cli regions list --text
|
|
linode-cli regions list --text --delimiter ";"
|
|
This page was originally published on