# Linux terminal through exec node

**URL:** <https://discourse.nodered.org/t/linux-terminal-through-exec-node/25292>\
**Category:** General\
**Created:** [22 April 2020 09:56 UTC](https://discourse.nodered.org/t/linux-terminal-through-exec-node/25292 "2020-04-22T09:56:11Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ward](https://avatars.discourse-cdn.com/v4/letter/w/439d5e/32.png) [@Ward](https://discourse.nodered.org/u/Ward)\
**Post date:** [22 April 2020 09:56 UTC](https://discourse.nodered.org/t/linux-terminal-through-exec-node/25292/1 "2020-04-22T09:56:11Z")

</div>

Hi,

I'm looking for a way to enter command line from node red to the terminal of my linux pc.I was looking online and i found that the node exec would do the trick.

The command line i want to use for a example is: influxd backup -portable /tmp/backup\_ex  
It works if i directly enter this in my terminal. And for this instruction you don't need to enter your pasword. This is why i choose this instruction as a first step.

I did unclicked the append msg.payload as suggested online.  
But i keep getting the error: /bin/sh: 1: influxd: not found

So i'm wondering because the error say that it did not find a directory that this is not the node i am looking for. And this node starts a program or i'm i wrong?

And if so wich node can i use?

Thanks at advance,  
Kind regards!  
Ward

PS: the code of the node:

```auto
[{"id":"b703d18a.ec6b1","type":"exec","z":"3263073.a348778","command":"influxd backup -portable /tmp/backup_ex","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"Backup InfluxDB","x":400,"y":160,"wires":[[],["24aa3131.cf9eae"],[]]}]

```

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [22 April 2020 10:00 UTC](https://discourse.nodered.org/t/linux-terminal-through-exec-node/25292/2 "2020-04-22T10:00:25Z")

</div>

you will need to fully qualify the path to the command. so outside of Node-RED type `which influxd` - then use that full path to the command in the exec node.

---

<div class="post-metadata">

**Author:** ![Ward](https://avatars.discourse-cdn.com/v4/letter/w/439d5e/32.png) [@Ward](https://discourse.nodered.org/u/Ward)\
**Post date:** [22 April 2020 10:28 UTC](https://discourse.nodered.org/t/linux-terminal-through-exec-node/25292/3 "2020-04-22T10:28:50Z")

</div>

Oke i send the location with it: /usr/bin influxd backup -portable /tmp/backup\_ex

But now i get the error:/bin/sh: 1: /usr/bin: Permission denied  
But i've got no pasword on my InfluxDB account? And if i did how do you send the pasword with it?

---

<div class="post-metadata">

**Author:** ![Ward](https://avatars.discourse-cdn.com/v4/letter/w/439d5e/32.png) [@Ward](https://discourse.nodered.org/u/Ward)\
**Post date:** [22 April 2020 10:42 UTC](https://discourse.nodered.org/t/linux-terminal-through-exec-node/25292/4 "2020-04-22T10:42:53Z")

</div>

I was too quick to reply. My apologies for that.

But after searching a little more i think it's because the files in linux (Influxd in my case) doesn't have the right permission settings. Only the root user can ask it and in the terminal you are the root user but not through node red. Is this correct what i'm thinking?

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [22 April 2020 10:44 UTC](https://discourse.nodered.org/t/linux-terminal-through-exec-node/25292/5 "2020-04-22T10:44:22Z")

</div>

> [@Ward](#):
>
> Oke i send the location with it: /usr/bin influxd backup -portable /tmp/backup\_ex

I think you have missed a slash, it should be `/usr/bin/influxd`

---

<div class="post-metadata">

**Author:** ![Ward](https://avatars.discourse-cdn.com/v4/letter/w/439d5e/32.png) [@Ward](https://discourse.nodered.org/u/Ward)\
**Post date:** [22 April 2020 10:48 UTC](https://discourse.nodered.org/t/linux-terminal-through-exec-node/25292/6 "2020-04-22T10:48:00Z")

</div>

Hi kuema  
I first did it with the slash but then he did not find the file so i think you don't need to write it because he will else expect another folder and not a application file.

But i could be wrong.

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [22 April 2020 10:49 UTC](https://discourse.nodered.org/t/linux-terminal-through-exec-node/25292/7 "2020-04-22T10:49:56Z")

</div>

The slash is required for an absolute path. Otherwise the exec node tries to start `/usr/bin`, which is a directory, not a file.

You have to use the exact output of `which influxd`.

---

<div class="post-metadata">

**Author:** ![Ward](https://avatars.discourse-cdn.com/v4/letter/w/439d5e/32.png) [@Ward](https://discourse.nodered.org/u/Ward)\
**Post date:** [22 April 2020 10:59 UTC](https://discourse.nodered.org/t/linux-terminal-through-exec-node/25292/8 "2020-04-22T10:59:59Z")

</div>

Thanks for the reply kuema

In the next screenshot you find the right path

 ![Path Influxd](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/f/bf6d1124e1b2b8b5577872d15dbd753b95d1442e.png)

So if i write: /usr/bin/influxd backup -portable /tmp/backup\_ex  
It should be working then, no? So what i'm i missing then?

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [22 April 2020 11:06 UTC](https://discourse.nodered.org/t/linux-terminal-through-exec-node/25292/9 "2020-04-22T11:06:54Z")

</div>

Yes, but you'd have to execute it as the correct user as well. That user needs the permission to access Influx' data files.

However, I'm not sure how the backups are created in newer versions, maybe that's no longer valid, if backups are done by the Influx service.

Offline backups seem to be deprecated, so it should be working.

> **[Back up and restore InfluxDB OSS | InfluxData Documentation](https://docs.influxdata.com/influxdb/v1.8/administration/backup_and_restore/)**
>
> Using InfluxDB OSS backup and restore utilities for online, Enterprise-compatible use and portability between InfluxDB Enterprise and InfluxDB OSS servers..

---

<div class="post-metadata">

**Author:** ![Ward](https://avatars.discourse-cdn.com/v4/letter/w/439d5e/32.png) [@Ward](https://discourse.nodered.org/u/Ward)\
**Post date:** [22 April 2020 11:13 UTC](https://discourse.nodered.org/t/linux-terminal-through-exec-node/25292/10 "2020-04-22T11:13:02Z")

</div>

It works if i use the command line in the linux terminal.

But how do you execute it in node red as the right user?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [22 April 2020 12:15 UTC](https://discourse.nodered.org/t/linux-terminal-through-exec-node/25292/11 "2020-04-22T12:15:06Z")

</div>

Can you export a mini-flow just consisting of an inject node, the exec node, and debug nodes showing the result and post it here please, then we can try it ourselves.

---

<div class="post-metadata">

**Author:** ![Ward](https://avatars.discourse-cdn.com/v4/letter/w/439d5e/32.png) [@Ward](https://discourse.nodered.org/u/Ward)\
**Post date:** [22 April 2020 14:11 UTC](https://discourse.nodered.org/t/linux-terminal-through-exec-node/25292/12 "2020-04-22T14:11:36Z")

</div>

@Colin Off course here it is:

```auto
[{"id":"3263073.a348778","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"b703d18a.ec6b1","type":"exec","z":"3263073.a348778","command":"/usr/bin/influxd backup -portable /tmp/backup_ex","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"Backup InfluxDB","x":400,"y":160,"wires":[[],["24aa3131.cf9eae"],[]]},{"id":"ccd5cf5a.1847d8","type":"inject","z":"3263073.a348778","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":100,"y":160,"wires":[["b703d18a.ec6b1"]]},{"id":"24aa3131.cf9eae","type":"debug","z":"3263073.a348778","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":740,"y":140,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![Ward](https://avatars.discourse-cdn.com/v4/letter/w/439d5e/32.png) [@Ward](https://discourse.nodered.org/u/Ward)\
**Post date:** [22 April 2020 14:12 UTC](https://discourse.nodered.org/t/linux-terminal-through-exec-node/25292/13 "2020-04-22T14:12:52Z")

</div>

And here is my debug screen

 ![Debug](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/b/db0ccc3e83b0a56e7a99806570a3c43c0f150d36.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [22 April 2020 14:44 UTC](https://discourse.nodered.org/t/linux-terminal-through-exec-node/25292/14 "2020-04-22T14:44:25Z")

</div>

Well that is very odd, the error is saying that it cannot find /usr/bin/influxd, and your flow works for me.  
What do you see if you run, in a terminal  
`ls -l /usr/bin/influxd`  
also put that command in the exec node and run it. Put a debug node on output 1 so you can see what is in the payload.  
Can I just check that the terminal you are running the command in is connected to the machine running node red, not the one running the browser (if that is different).

---

<div class="post-metadata">

**Author:** ![Ward](https://avatars.discourse-cdn.com/v4/letter/w/439d5e/32.png) [@Ward](https://discourse.nodered.org/u/Ward)\
**Post date:** [22 April 2020 14:50 UTC](https://discourse.nodered.org/t/linux-terminal-through-exec-node/25292/15 "2020-04-22T14:50:38Z")

</div>

hi Colin

I have run the code in the terminal and the result is.  
ward@ward-VM:~$ ls -l /usr/bin/influxd  
-rwxrwxrwx 1 root root 68710254 Feb 7 07:56 /usr/bin/influxd

I have to say i thought it had something to do with my File permission so i changed it to chmod 777 as you can see. But still the same error

For the result in Node Red you can see below

 ![Debug2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/a/2aab8af0e78c7fd9d76b28090a17da7f50fee7b7.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [22 April 2020 14:53 UTC](https://discourse.nodered.org/t/linux-terminal-through-exec-node/25292/16 "2020-04-22T14:53:04Z")

</div>

How did you install node-red? Are you running it in Docker or a snap or something? It appears it doesn't have full access to the operating system. Also I note that he terminal might be running in a VM. That could also be significant. Is it the same VM that node-red is running in?

---

<div class="post-metadata">

**Author:** ![Ward](https://avatars.discourse-cdn.com/v4/letter/w/439d5e/32.png) [@Ward](https://discourse.nodered.org/u/Ward)\
**Post date:** [22 April 2020 14:55 UTC](https://discourse.nodered.org/t/linux-terminal-through-exec-node/25292/17 "2020-04-22T14:55:08Z")

</div>

i installed it through snap. And i am running it in a VMware but the node red is also opened (and installed) in the same VMware.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [22 April 2020 14:58 UTC](https://discourse.nodered.org/t/linux-terminal-through-exec-node/25292/18 "2020-04-22T14:58:48Z")

</div>

> [@Ward](#):
>
> i installed it through snap

That, I am sure, is the issue. Snaps do not have full access to the OS, you have to specifically give them the permissions they need. I don't know how to do that. Unless you have a good reason to use the snap then I suggest doing a regular install. If it is a Debian based system such as Ubuntu you can use the install script from the docs. It mostly reference the Pi but it works fine with Ubuntu too.  
[https://nodered.org/docs/getting-started/raspberrypi](https://nodered.org/docs/getting-started/raspberrypi)

---

<div class="post-metadata">

**Author:** ![Ward](https://avatars.discourse-cdn.com/v4/letter/w/439d5e/32.png) [@Ward](https://discourse.nodered.org/u/Ward)\
**Post date:** [22 April 2020 15:02 UTC](https://discourse.nodered.org/t/linux-terminal-through-exec-node/25292/19 "2020-04-22T15:02:51Z")

</div>

Ooh oke that's explain alot thanks.  
I installed it on a linux mint but i will reinstall it then and try it again.

Once again a big thanks!

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [22 April 2020 15:04 UTC](https://discourse.nodered.org/t/linux-terminal-through-exec-node/25292/20 "2020-04-22T15:04:31Z")

</div>

> [@Ward](#):
>
> I installed it on a linux mint

The script should work on Mint too. Take the snap out first.

[Next page](https://discourse.nodered.org/t/linux-terminal-through-exec-node/25292.md?page=2)
