croussou
croussou

Reputation: 77

Linux - Remote command execution and .bashrc

I have a number of custom aliases on a Linux host (a) and when I am trying to execute some commands from another Linux host (b), the entries in ~/.bashrc complain that those commands cannot be found. Can you please explain how to avoid those errors.

Please refer to the example below.

from (b) to (a)

[root@localhost /]# sshpass -p 'my_pass' ssh -p port_number root@host "uptime"

/root/.bashrc: line 17: hello1: command not found

/root/.bashrc: line 18: hello2: command not found

/root/.bashrc: line 19: hello3: command not found

03:05:56 up 3 days, 23:29,  1 user,  load average: 1.16, 0.78, 0.47

Please advise, thanks a lot.

Upvotes: 1

Views: 284

Answers (1)

Simonlbc
Simonlbc

Reputation: 651

This is normal, as the ~/.bashrc on your remote and host machines are not the same if you changed the ~/.bashrc on your machine but not on your remote machine. One way would just copy the different lines from your host machine ~/.bashrc to your remote one. If you do that you'll be able to use your aliases that you defined on your host machine in your remote machine.

Upvotes: 2

Related Questions