linode/cli
The Linode Command Line Interface. Built from linode/linode-cli.
Using a Linode API Token:
docker run --rm -it -e LINODE_CLI_TOKEN=$LINODE_TOKEN linode/cli:latest linodes list
Using an existing config file:
docker run --rm -it -v $HOME/.config/linode-cli:/home/cli/.config/linode-cli linode/cli:latest linodes list
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 (see "Configuration" below for details), 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
The first time the CLI runs, it will prompt you to configure it. The CLI defaults to using web-based configuration, which is fast and convenient for users who have access to a browser.
To manually configure the CLI or reconfigure it if your token expires,
you can run the configure
command:
linode-cli configure
If you prefer to provide a token directly through the terminal, possibly
because you don't have access to a browser where you're configuring
the CLI, pass the --token
flag to the configure command as shown:
linode-cli configure --token
When configuring multiple users using web-based configuration, you may need to log out of cloud.linode.com before configuring a second user.
When running certain commands, you may need to specify multiple values
for a list argument. This can be done by specifying the argument
multiple times for each value in the list. For example, to create a
Linode with multiple tags
you can execute the following:
linode-cli linodes create --region us-east --type g6-nanode-1 --tags tag1 --tags tag2
When running certain commands, you may need to specify an argument that
is nested in another field. These arguments can be specified using a .
delimited path to the argument. For example, to create a firewall with
an inbound policy of DROP
and an outbound policy of ACCEPT
, you can
execute the following:
linode-cli firewalls create --label example-firewall --rules.outbound_policy ACCEPT --rules.inbound_policy DROP
If you configured default values for image
, authorized_users
,
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.
To generate a completion file for a given shell type, use the
completion
command; for example to generate completions for bash run:
linode-cli completion bash
The output of this command is suitable to be included in the relevant completion files to enable command completion on your shell.
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.
You may also use environment variables to store your Object Storage Keys
for the obj
plugin that ships with the CLI. To do so, simply set
LINODE_CLI_OBJ_ACCESS_KEY
and LINODE_CLI_OBJ_SECRET_KEY
to the
appropriate values. This allows using Linode Object Storage through the
CLI without having a configuration file, which is desirable in some
situations.
If you use the Linode CLI to manage multiple Linode accounts, you may
configure additional users using the linode-cli configure
command. The
CLI will automatically detect that a new user is being configured based
on the token given.
To see what users are configured, simply run the following:
linode-cli show-users
The user who is currently active will be indicated by an asterisk.
You may change the active user for all requests as follows:
linode-cli set-user USERNAME
Subsequent CLI commands will be executed as that user by default.
Should you wish to execute a single request as a different user, you can
supply the --as-user
argument to specify the username you wish to act
as for that command. This will not change the active user.
To remove a user from you previously configured, run:
linode-cli remove-user USERNAME
Once a user is removed, they will need to be reconfigured if you wish to use the CLI for them again.
By default, the CLI displays on some pre-selected fields for a given type of response. If you want to see everything, just ask:
linode-cli linodes list --all
Using --all will cause the CLI to display all returned columns of output. Note that this will probably be hard to read on normal-sized screens for most actions.
If you want even finer control over your output, you can request specific columns be displayed:
linode-cli linodes list --format 'id,region,status,disk,memory,vcpus,transfer'
This will show some identifying information about your Linode as well as the resources it has access to. Some of these fields would be hidden by default -that's ok. If you ask for a field, it'll be displayed.
While the CLI by default outputs human-readable tables of data, you can use the CLI to generate output that is easier to process.
To get more machine-readable output, simply request it:
linode-cli linodes list --text
If a tab is a bad delimiter, you can configure that as well:
linode-cli linodes list --text --delimiter ';'
You may also disable header rows (in any output format):
linode-cli linodes list --no-headers --text
To get JSON output from the CLI, simple request it:
linode-cli linodes list --json --all
While the --all is optional, you probably want to see all output fields in your JSON output. If you want your JSON pretty-printed, we can do that too:
linode-cli linodes list --json --pretty --all
The Linode CLI allows its features to be expanded with plugins. Some official plugins come bundled with the CLI and are documented above. Additionally, anyone can write and distribute plugins for the CLI - these are called Third Party Plugins.
To register a Third Party Plugin, use the following command:
linode-cli register-plugin PLUGIN_MODULE_NAME
Plugins should give the exact command required to register them.
Once registered, the command to invoke the Third Party Plugin will be
printed, and it will appear in the plugin list when invoking
linode-cli --help
.
To remove a previously registered plugin, use the following command:
linode-cli remove-plugin PLUGIN_NAME
This command accepts the name used to invoke the plugin in the CLI as it
appears in linode-cli --help
, which may not be the same as the module
name used to register it.
For information on how To write your own Third Party Plugin, see the Plugins documentation.
docker pull linode/cli