20
rsync -avP /home/user/.profile hpux3:/home/user/.profile
bash: rsync: command not found

If I did ssh to hpux3 machine

rsync  
version 3.1.1  protocol version 31
Copyright (C) 1996-2014 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
output truncated

I have set PATH in $HOME/.profile and $HOME/.bashrc. Should I set it in the /etc/profile file?

  • The rsync command must be present on your local machine. – ott-- Apr 26 '15 at 21:44
  • 1
    Of course is present in both machines – elbarna Apr 27 '15 at 0:56
30

Your .profile is only read when you log in interactively. When rsync connects to another machine to execute a command, /etc/profile and ~/.profile are not read.

If your login shell is bash, then ~/.bashrc may be read (this is a quirk of bash — ~/.bashrc is read by non-login interactive shells, and in some circumstances by login non-interactive shells). This doesn't apply to all versions of bash though.

The easiest way to make rsync work is probably to pass the --rsync-path option, e.g.

rsync --rsync-path=/home/elbarna/bin/rsync -avP /home/user/.profile hpux3:/home/user/.profile

If you log in over SSH with key-based authentication, you can set the PATH environment variable via your ~/.ssh/authorized_keys. See sh startup files over ssh for explanations of how to arrange to load .profile when logging in over SSH with a key.

| improve this answer | |
  • 9
    Note: --rsync-path is used to set the path of rsync on the remote computer. (at first sight I was wondering how was it possible to specify the path to rsync while lauching rsync on the same machine) – A.L Apr 27 '15 at 8:56
  • @Gilles 'SO- stop being evil' Any idea why I have to do this? Bash is not my default shell. Ksh is my default shell. I login with ksh then switch to bash. – cokedude Nov 14 '19 at 22:36
  • 1
    @cokedude If rsync is installed on your account rather than at the system level, you have to do some configuration on your account to be able to use it. It's not enough to put the rsync binary somewhere: you also need to arrange for it to be found. – Gilles 'SO- stop being evil' Nov 14 '19 at 23:04
5

This error can also occur when trying to sync files and directories from remote machine to local system, if the rsync is not installed on the remote side.

rsync -zarvh oem@172.20.0.12:/var/www/html/release /var/www/html/release
bash: rsync: command not found

Installing rsync on remote side will solve this case

| improve this answer | |
  • Note that the issue here is not that the utility isn't installed on the remote system, but that it's installed in a location on the remote system which is not in the default $PATH. – Kusalananda Sep 25 at 6:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.