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.

Create a Linode account to try this guide with a $100 credit.
This credit will be applied to any valid services used during your first 60 days.

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:

  1. 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

  1. Ensure that all available packages are up to date:

    sudo apt update
    
  2. Install python3 and pip3:

    sudo apt install python3 && sudo apt install python3-pip
    
  3. Install the Linode CLI using pip3:

    sudo pip3 install linode-cli
    

CentOS/RHEL Stream and Fedora

  1. Ensure that all available packages are up to date:

    dnf upgrade
    
  2. Install python3 and pip3:

    sudo dnf install python3 && sudo dnf install python3-pip
    
  3. Install the Linode CLI using pip3:

    sudo pip3 install linode-cli
    

CentOS 7

  1. Ensure that all available packages are up to date:

    sudo yum update
    
  2. Install python3 and pip3:

    sudo yum install python3 && sudo yum install python3-pip
    
  3. Install the Linode CLI using pip3:

    sudo pip3 install linode-cli
    

Windows 10

  1. Download the latest stable Windows package for python3 for your system at Python’s Downloads Page.

  2. Open up the installer .exe to begin the python installation process using Window’s GUI.

  3. Before proceeding, ensure that your version of Python is added to PATH by checking the box which enables this option:

    Python Windows Path Option

  4. Select the Customize Installation option to proceed.

  5. Ensure that pip all desired optional features are selected before proceeding to the next step. The pip installation is required by the Linode CLI.

  6. In the next step, ensure that the Install for all users option is enabled. Your configuration should reflect the following:

    Python on Windows Advanced Options

  7. 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.

  8. 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

  1. You need a Personal Access Token to use the CLI. Use the Linode Cloud Manager to obtain a token.

  2. 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 running linode-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:
Note
The CLI installs a bash completion file. On OSX, you may have to source this file before it can be used. To do this, add source /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
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
[
  {
    "country": "us",
    "id": "us-central"
  },
  {
    "country": "us",
    "id": "us-west"
  },
  {
    "country": "us",
    "id": "us-southeast"
  },
  {
    "country": "us",
    "id": "us-east"
  },
  ...
]

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
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
id	country
us-central	us
us-west	us
us-southeast	us
us-east	us
eu-west	uk
ap-south	sg
eu-central	de
ap-northeast	jp
ap-northeast-1a	jp
ca-east         ca
linode-cli regions list --text --delimiter ";"
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
id;country
us-central;us
us-west;us
us-southeast;us
us-east;us
eu-west;uk
ap-south;sg
eu-central;de
ap-northeast;jp
ap-northeast-1a;jp
ca-east;ca

This page was originally published on


Your Feedback Is Important

Let us know if this guide made it easy to get the answer you needed.