How to execute shell command through api ?

I have ubuntu instance running in linode. How can I run shell command in that ubuntu instance through API ? for example: I may want to know what are the files in the home directory. So I would like to execute following command from api.

cd /var/www/html/ && ls

3 Replies

You can't… This is not the purpose of the Linode API. The Linode API doesn't know anything about the particular distro your Linode is running (or even if it's running Linux -- I have a Linode that doesn't run Linux and yet I can manage it remotely from my laptop using the Linode REST API with curl(1)).

The Linode API doesn't know anything about user accounts or logins or shells. The purpose of the Linode API is to automate management of Linode-supplied resources…disc volumes, object storage, node balancers, DNS records, etc. I use it to update my DKIM key every month and to run a weekly snapshot backup.

If your intent is to just run your command remotely, you can do that with ssh(1):

ssh ls /var/www/html

This command will login to with account foo (properly honoring authentication) and run the command ls /var/www/html.

-- sw

To add more detail to the response from @stevewi:

The purpose of the Linode API is to allow users to perform the actions of our Cloud Manager utilizing the command line rather than interacting with our GUI via You can perform “managerial” tasks in a swift manner without leaving your terminal - this includes anything from updating your billing information to deploying new servers.

When it comes to remotely accessing the internals of your servers, though, you won’t be able to do that through API. As stevewi mentioned, you’ll still have to connect to your Linode via SSH and run commands from there.

To learn more about our API and how it works, you can review our document Getting Started with the Linode API. In addition, you can access our API Documenation for a full list of the tasks you can execute utilizing this tool.


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct