The Linode Command Line Interface
From pypi:
pip install linode-cli
From source:
git clone [email protected]:linode/linode-cli.git cd linode-cli make install
This will need to be repeated on each pull. For a build to succeed, see Building from Source below.
To upgrade to the latest version of the Linode CLI:
pip install linode-cli --upgrade
The Linode CLI is invoked with the linode-cli. The CLI accepts two primary arguments, command and action:
linode-cli <command> <action>
command is the part of the CLI you are interacting with, for example "linodes". You can see a list of all available commands by using --help:
linode-cli --help
action is the action you want to perform on a given command, for example "list". You can see a list of all available actions for a command with the --help for that command:
linode-cli linodes --help
Some actions don't require any parameters, but many do. To see details on how to invoke a specific action, use --help for that action:
linode-cli linodes create --help
The first time you invoke the CLI, you will be asked to configure it with a token, and optionally select some default values for "region," "image," and "type." If you configure these defaults, you may omit them as parameters to actions and the default value will be used.
List Linodes:
linode-cli linodes list
List Linodes in a Region:
linode-cli linodes list --region us-east
Make a Linode:
linode-cli linodes create --type g5-standard-2 --region us-east --image linode/debian9 --label cli-1 --root_pass
Make a Linode using Default Settings:
linode-cli linodes create --label cli-2 --root_pass
Reboot a Linode:
linode-cli linodes reboot 12345
View available Linode types:
linode-cli linodes types
View your Volumes:
linode-cli volumes list
View your Domains:
linode-cli domains list
View records for a single Domain:
linode-cli domains records-list 12345
View your user:
linode-cli profile view
If your token expires or you want to otherwise change your configuration, simply run the configure command:
linode-cli configure
If you configured default values for image, region, and Linode type, they will be sent for all requests that accept them if you do not specify a different value. If you want to send a request without these arguments, you must invoke the CLI with the --no-defaults option. For example, to create a Linode with no image after a default Image has been configured, you would do this:
linode-cli linodes create --region us-east --type g5-standard-2 --no-defaults
In some situations, like when the CLI is out of date, it will generate a warning in addition to its normal output. If these warnings can interfere with your scripts or you otherwise want them disabled, simply add the --suppress-warnings flag to prevent them from being emitted.
If you prefer, you may store your token in an environment variable named LINODE_CLI TOKEN instead of using the configuration file. Doing so allows you to bypass the initial configuration, and subsequent calls to linode-cli configure will allow you to set defaults without having to set a token. Be aware that if the environment variable should be unset, the Linode CLI will stop working until it is set again or the CLI is reconfigured with a token.