![命令在 ssh 登入時運行,不希望它這樣做](https://rvso.com/image/1127597/%E5%91%BD%E4%BB%A4%E5%9C%A8%20ssh%20%E7%99%BB%E5%85%A5%E6%99%82%E9%81%8B%E8%A1%8C%EF%BC%8C%E4%B8%8D%E5%B8%8C%E6%9C%9B%E5%AE%83%E9%80%99%E6%A8%A3%E5%81%9A.png)
當我透過 SSH 連接到我的 ubuntu 伺服器時,我得到了正常的系統資訊啟動畫面,但隨後立即運行了一個命令,而且我似乎無法追蹤它。
Last login: Tue Jun 30 15:20:22 2015 from [removed]
][: command not found
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)`
我假設這是當我嘗試正確安裝 java 以與 Jira/Confluence 一起使用時。
我嘗試回溯我正在查看的一些舊指南,但似乎找不到我可能不][
小心進入的地方。有想法嗎?
答案1
啟動互動式登入 shell 時讀取的使用者設定檔如下ssh
:
使用者設定檔
~/.bash_profile
,~/.bash_login
,~/.profile
(其中任何一個,按該順序搜尋)全域設定檔
/etc/profile
現在提到的問題必須位於這些文件之一或源自這些文件的任何其他文件中。因此,我們需要搜尋這些文件,並且~/.bashrc
需要將其包含在內,因為 Ubuntu~/.bashrc
源自~/.profile
.
如果][
我們可以這樣做:
grep '\]\[' ~/.bash_profile ~/.bash_login ~/.profile ~/.bashrc /etc/profile 2>/dev/null
另一方面,如果java
我們需要:
grep 'java' ~/.bash_profile ~/.bash_login ~/.profile ~/.bashrc /etc/profile 2>/dev/null
找到有問題的行後,我們需要修復這些行以使其正確(或在不需要時刪除它們)。