Bash

通過 ssh 訪問遠端機器時找不到命令異常

  • May 27, 2021

當我使用 ssh 訪問某個遠端機器時,我們有奇怪的行為

所有機器都是rhel 7.2版本

這就是我們得到的

ssh server142
Last login: Thu May 27 09:44:13 2021 from  server_ER




-bash: server: command not found
-bash: stratumweight: command not found
-bash: driftfile: command not found
-bash: $'rtcsync\r': command not found
-bash: makestep: command not found
-bash: bindcmdaddress: command not found
-bash: bindcmdaddress: command not found
-bash: keyfile: command not found
-bash: commandkey: command not found
-bash: $'generatecommandkey\r': command not found
-bash: $'\r': command not found
-bash: $'noclientlog\r': command not found
-bash: logchange: command not found
-bash: $'\r': command not found
-bash: logdir: command not found

所以我們檢查了$PATH壞伺服器並將其與其他好的伺服器進行比較,但兩個 $PATH 輸出是相同的輸出

例子

echo $PATH
/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

我們還比較了bashrc機器之間的好壞,也沒有區別

任何提示可能是這個問題的原因是什麼?

問題出在文件上/etc/bash_completion.d/chrony.conf

所以我們將此文件移動為

mv /etc/bash_completion.d/chrony.conf /var/tmp

某些消息中的\r強烈暗示您在文件中有 Windows 行結尾。

引用自:https://unix.stackexchange.com/questions/651613