CLI commands for Compute Instances
Tasks related to Linode instances are performed with linode-cli linodes [ACTION]
.
-
List all of the compute instances on your account:
linode-cli linodes list
Filter results to a particular region:
linode-cli linodes list --region us-east
Filtering works on many fields throughout the CLI. Use
--help
for each action to see which properties are filterable. -
Create a new compute instance:
linode-cli linodes create --root_pass mypassword
The defaults you specified when configuring the CLI will be used for the new compute instance's type, region, and image. Override these options by specifying the values:
linode-cli linodes create --root_pass mypassword --region us-east --image linode/debian9 --group webservers
If you're not writing a script, it's more secure to use
--root_pass
without specifying a password. You're prompted to enter a password:linode-cli linodes create --root_pass
-
For commands targeting a specific compute instance, you need that compute instance's ID. The ID is returned when creating the compute instance, and can be viewed by listing the compute instances on your account. Store the ID of the target compute instance for later use:
export linode_id=<id-string>
-
View details about a particular compute instance:
linode-cli linodes view $linode_id
-
Boot, shut down, or reboot a compute instance:
linode-cli linodes boot $linode_id linode-cli linodes reboot $linode_id linode-cli linodes shutdown $linode_id
-
View a list of available IP addresses for a specific compute instance:
linode-cli linodes ips-list $linode_id
-
Add a private IP address to a compute instance:
linode-cli linodes ip-add $linode_id --type ipv4 --public false
-
Create a new disk for a compute instance:
linode-cli linodes disk-create $linode_id --size 2700 --root_pass mypassword --filesystem raw --no-defaults
Even if you set the
--filesystem
toraw
, the defaults you specified when configuring the CLI are used for setting a compute instance's disk image for this disk, overriding the filesystem setting. To create a disk without the default image, using only the parameters you send in this command, use the--no-defaults
flag. -
List all disks provisioned for a compute instance:
linode-cli linodes disks-list $linode_id
-
Upgrade your compute instance. If an upgrade is available, the compute instance the system places it in the migration queue. The system automatically shuts it down, migrates it, and returns to its last state:
linode-cli linodes upgrade $linode_id
-
Rebuild a compute instance:
linode-cli linodes rebuild $linode_id --image linode/debian9 --root_pass
-
Rebuild a compute instance, adding a populated
authorized_keys
file:linode-cli linodes rebuild $linode_id --image linode/debian9 --root_pass --authorized_keys "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEC+DOVfw+8Jsw1IPrYCcU9/HCuKayCsV8bXjsHqX/Zq email@example.com"
If your key exists on your filesystem, you can also substitute its value in the CLI command with
cat
. For example:linode-cli linodes rebuild $linode_id --image linode/debian9 --root_pass --authorized_keys "$(cat ~/.ssh/id_rsa.pub)"
Many other actions are available. Use linode-cli linodes --help
for a complete list.
Updated 2 months ago