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:

  1. Install the CLI:

    pip3 install linode-cli --upgrade
    
  2. You need a Personal Access Token to use the CLI. Use the Linode Cloud Manager to obtain a token.

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