Cli
This is the DEPRECATED Linode CLI. Use https://github.com/linode/linode-cli
Install / Use
/learn @linode/CliREADME
Linode CLI
Overview
Linode CLI is a simple command-line interface to the Linode platform. Note: There is a newer version of the Linode CLI (linode-cli) that uses the new Linode API V4.
Installation
Linode CLI is currently packaged for Debian, Ubuntu, CentOS, Fedora, NixOS and through Homebrew on Mac OS X. Final versions of linode-cli will be packaged up and very easy to install for major distributions.
Debian/Ubuntu
sudo bash -c 'echo "deb http://apt.linode.com/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/linode.list'
wget -O- https://apt.linode.com/linode.gpg | sudo apt-key add -
sudo apt-get update
sudo apt-get install linode-cli
Fedora
Fedora's official repositories include Linode CLI (in F24 and newer). To install,
sudo dnf install linode-cli
CentOS
Installing Linode CLI on CentOS requires the EPEL repository to be installed and enabled, before installing Linode CLI.
sudo yum install epel-release
sudo yum install linode-cli
NixOS/Nix
Linode CLI is included in NixPkgs, so installation should be straightforward
# Using symbolic name.
nix-env -i perl-linode-cli
# Using attribute name. (Channel name is derived using $() here)
nix-env -iA $(nix-channel --list | head -n1 | cut -d' ' -f1).linode-cli
Mac OS X
Installing the packaged version of Linode CLI on Mac OS X requires Homebrew: http://brew.sh
brew install linode/cli/linode-cli
Mac OS X segmentation faults
Linode-cli must be built using the system perl, so if you end up with segmentation faults when running linode on OSX, try
brew unlink perl
brew uninstall linode-cli
brew install linode-cli
Others
You'll need the following Perl modules. They can be installed from the CPAN using your preferred method.
- JSON
- LWP
- Mozilla::CA
- Try::Tiny
- WebService::Linode
To install with root:
sudo cpan -i JSON LWP Mozilla::CP Try::Tiny WebService::Linode
To install with local::lib:
perl -MCPAN -Mlocal::lib -e 'CPAN::install(JSON, LWP, Mozilla::CA, Try::Tiny, WebService::Linode)'
Then, download the Linode CLI tarball, extract it, and install:
curl -Lo linode-cli.tar.gz https://github.com/linode/cli/archive/master.tar.gz
tar xf linode-cli.tar.gz
cd cli-master && perl Makefile.PL && sudo make install
Initial configuration
You can configure defaults, including your API key and common deployment options, by running the configuration helper:
linode configure
This will walk you through setting default values for common options.
Linode Manager username
>>
...
By default, this will (over)write $HOME/.linodecli/config. If you specify a username (-u), it will (over)write $HOME/.linodecli/config_username.
Options are in the format of option value, for example:
api-key foobarbaz123456
The API key can also be set using an environment variable (LINODE_API_KEY). Alternatively, you can pass an --api-key option on the command line.
Examples
If you didn't place linode-cli somewhere in your PATH, you'll need to call it directly: /path/to/linode-cli/linode. Otherwise, you can simply use linode.
Listing Linodes
linode list
linode list My-Linode-Label
linode list My-Linode-Label1 My-Linode-Label2
Showing details about a single Linode
linode show My-Linode-Label
Starting, stopping, or restarting a Linode
linode start My-Linode-Label
linode stop My-Linode-Label
linode restart My-Linode-Label
Renaming a Linode
linode rename mylinodename mylinodenewname
Creating a new Linode
Warning: This will attempt to charge the credit card on file, or use any account credit available, and spin up a new Linode 2GB.
linode create New-Linode --location dallas --plan linode2G --payment-term 1 --distribution 'Debian 9' --group Frontends
Resizing a Linode
Warning: This will shut the Linode down, charge/credit the account, and issue a migration to another host server.
This example resizes a Linode 2GB to a Linode 4GB.
linode resize mylinode linode4GB
Deleting a Linode
Warning: This will permanently delete a Linode, its disk images and configuration profiles.
linode delete New-Linode
Working with multiple Linodes
Actions can be performed on multiple Linodes using their labels. Using multiple --label arguments will accomplish the same thing.
linode start My-Linode-Label1 My-Linode-Label2
linode show --label My-Linode-Label1 --label My-Linode-Label2
Working with Domains
Create a master domain (requires an SOA email address).
linode domain create example.com admin@example.com
Create a slave domain (requires a master DNS server ip).
linode domain create example.com slave X.X.X.X
Displaying domains.
linode domain list
linode domain show example.com
Updating a domain.
linode domain update example.com --group main
Creating domain records.
linode domain record-create example.com A www2 X.X.X.X
linode domain record-create example.com MX subdomain mail.example.com
Updating a domain record.
linode domain record-update example.com MX mail.example.com --priority 20
Removing a domain record.
linode domain record-delete example.com A www2
Displaying domain records.
linode domain record-list example.com
linode domain record-list example.com MX
linode domain record-show example.com
linode domain record-show example.com example.com MX
Working with NodeBalancers
Create a NodeBalancer in your datacenter of choice.
linode nodebalancer create mynodebalancer dallas
Set the NodeBalancer up to handle traffic on a port (configuration).
linode nodebalancer config-create mynodebalancer 80
Create NodeBlanacer Nodes, balancing the incoming traffic between your Linodes.
linode nodebalancer node-create mynodebalancer 80 mylinode1 xx.xx.xx.1:80
linode nodebalancer node-create mynodebalancer 80 mylinode2 xx.xx.xx.2:80
linode nodebalancer node-create mynodebalancer 80 mylinode3 xx.xx.xx.3:80
Displaying NodeBalancers.
linode nodebalancer list
Displaying the Nodes, which will list the Linodes handing traffic on the port requested.
linode nodebalancer node-list mynodebalancer 80
Working with StackScripts
Actions can be performed on StackScripts.
linode stackscript list
linode stackscript create --label "StackScript Name" --codefile "/path/myscript.sh" --distribution "Debian 9"
linode stackscript show My-StackScript-Label
linode stackscript source mystackscript > myscript.sh
Working with Linode Images
Listing a Linode's disks (displays disk names and disk IDs)
linode disk-list mylinodelabel
Creating a Linode Image
linode image-create mylinodelabel --diskid diskid
Listing your Linode Images
linode image-list
Updating or removing your Linode Images
linode image-update --imageid imageid --name newname
linode image-delete --imageid imageid
Displaying account information
Account information, including the current account balance and network transfer pool usage, can be queried with the linode-account tool.
linode account show
managed yes
balance $ 0.00
transfer pool 7527.00GB
transfer billable 0.00GB
active since 2013-09-10 14:44:27.0
transfer used 1.00GB
JSON output
JSON output is available for actions.
linode list --output json
linode list --json
{
"linodefrontend1" : {
"location" : "dallas",
"group" : "",
"status" : "powered off",
"backupsenabled" : false,
"totalram" : "2GB",
"request_error" : "",
"totalhd" : "24GB",
"label" : "linodefrontend1",
"linodeid" : 900001
},
"linodebackend1" : {
"location" : "dallas",
"group" : "backend",
"status" : "running",
"backupsenabled" : true,
"totalram" : "4GB",
"request_error" : "",
"totalhd" : "48GB",
"label" : "linodebackend1",
"linodeid" : 900002
}
}
Using with multiple accounts
Multiple accounts and configuration files can be accomplished with the username option.
linode list -u username1
linode list -u username2
linode configure -u username1
linode configure -u username2
...
Usage
Options
-a, --action: An action to perform on one Linode. One of: create, start, stop, restart, rename, group, resize, delete. Read-only operations are available as well: list, show.
Each action has a set of options that apply to it, which are outlined in the section ACTIONS.
--api-key: API key to use when communicating with the Linode API. Alternatively, you can specify the API key in $HOME/.linodecli/config, using the format api-key foobar.
-u, --username: Optional. Allows users to specify the username, if using with multiple accounts and configuration files.
-j, --json: Optional. JSON output.
-h, --help: Displays help documentation.
Linode Actions
Create
Create and start a new Linode.
-l, --label: Required. A Linode to operate on.
-L, --location, --datacenter: Required. The datacenter to use for deployment. Locations are Atlanta, Dallas, Frankfurt, Fremont, London, Newark, Singapore, Shinagawa.
-d, --distribution: Required when not using imageid. Distribution name or DistributionID to deploy.
-i, --imageid: Required when not using distribution. The ID of the gold-master image to use for deployment.
-p, --plan: Required. The Plan to deploy. Plans are:
Standard Instances:
linode2GB, linode4GB, linode8GB, linode16GB, linode32GB, linode64GB, linode96GB, linode128GB, linode192GB
High Memory Instances:
linode24GB, linode48GB, linode90GB, linode150GB, linode300GB
N
