未找到命令“abc”...每次我通过 SSH 进入服务器时都会安装每个命令

未找到命令“abc”...每次我通过 SSH 进入服务器时都会安装每个命令

每次断开 SSH 连接时,我都必须重新安装每个程序。有人能解释一下我做错了什么吗?我是 Linux 新手,如果你能用简短的语言解释一下,那将有很大帮助。

我在终端输入了以下几行:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
brew update

注销服务器并重新登录,相同的终端会话

brew update

我收到错误:未找到命令“brew”

这是完整的终端会话:

user@laptop:~$ ssh -p port# user@ServerAddress
user@ServerAddress's password: 
Welcome to Ubuntu 20.04 LTS (GNU/Linux 5.4.0-37-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Mon 15 Jun 2020 03:04:03 AM UTC

  System load:  0.02               Temperature:           60.0 C
  Usage of /:   3.7% of 195.13GB   Processes:             196
  Memory usage: 2%                 Users logged in:       1
  Swap usage:   0%                 IPv4 address for eno1: ServerAddress

 * MicroK8s gets a native Windows installer and command-line integration.

     https://ubuntu.com/blog/microk8s-installers-windows-and-macos

0 updates can be installed immediately.
0 of these updates are security updates.


Last login: Mon Jun 15 02:18:15 2020 from Address
user@server:~$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
==> This script will install:
/home/linuxbrew/.linuxbrew/bin/brew
/home/linuxbrew/.linuxbrew/share/doc/homebrew
/home/linuxbrew/.linuxbrew/share/man/man1/brew.1
/home/linuxbrew/.linuxbrew/share/zsh/site-functions/_brew
/home/linuxbrew/.linuxbrew/etc/bash_completion.d/brew
/home/linuxbrew/.linuxbrew/Homebrew
==> The following existing directories will be made writable by user only:
/home/linuxbrew/.linuxbrew/share/zsh
/home/linuxbrew/.linuxbrew/share/zsh/site-functions

Press RETURN to continue or any other key to abort
[sudo] password for user: 
==> /usr/bin/sudo /bin/chmod u+rwx /home/linuxbrew/.linuxbrew/share/zsh /home/linuxbrew/.linuxbrew/share/zsh/site-functions
==> /usr/bin/sudo /bin/chmod 755 /home/linuxbrew/.linuxbrew/share/zsh /home/linuxbrew/.linuxbrew/share/zsh/site-functions
==> Downloading and installing Homebrew...
HEAD is now at 0125c4cd5 Merge pull request #7740 from vidusheeamoli/add-tapioca
Already up-to-date.
Warning: /home/linuxbrew/.linuxbrew/bin is not in your PATH.
==> Installation successful!

==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics
No analytics data has been sent yet (or will be during this `install` run).

==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations

==> Next steps:
- Run `brew help` to get started
- Further documentation: 
    https://docs.brew.sh
- Install the Homebrew dependencies if you have sudo access:
  Debian, Ubuntu, etc.
    sudo apt-get install build-essential
  Fedora, Red Hat, CentOS, etc.
    sudo yum groupinstall 'Development Tools'
  See https://docs.brew.sh/linux for more information.
- Configure Homebrew in your /home/user/.profile by running
    echo 'eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)' >> /home/user/.profile
- Add Homebrew to your PATH
    eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
- We recommend that you install GCC by running:
    brew install gcc

user@server:~$ eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
user@server:~$ brew update
Already up-to-date.
user@server:~$ exit
logout
Connection to ServerAddress closed.
user@laptop:~$ ssh -p port# user@ServerAddress
user@ServerAddress's password: 
Welcome to Ubuntu 20.04 LTS (GNU/Linux 5.4.0-37-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Mon 15 Jun 2020 03:12:51 AM UTC

  System load:  0.05               Temperature:           57.0 C
  Usage of /:   3.7% of 195.13GB   Processes:             191
  Memory usage: 2%                 Users logged in:       1
  Swap usage:   0%                 IPv4 address for eno1: ServerAddress

 * MicroK8s gets a native Windows installer and command-line integration.

     https://ubuntu.com/blog/microk8s-installers-windows-and-macos

0 updates can be installed immediately.
0 of these updates are security updates.


Last login: Mon Jun 15 03:04:03 2020 from Address
user@server:~$ brew update

Command 'brew' not found, did you mean:

  command 'brec' from deb bplay (0.991-10build1)
  command 'qbrew' from deb qbrew (0.4.1-8build1)

Try: sudo apt install <deb name>

user@server:~$ 

可能相关的随机事实:

  • 第三次安装 Ubuntu 20.04 LTS,每次都出现同样的问题(我花了一些时间才找出这个问题)
  • 安装OS时只选择安装openSSH

谢谢阅读。

答案1

必须将此命令eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv) 添加到您的文件.bashrc末尾。

通过添加此命令,它将修改您的 PATH 变量。

这样之后命令brew才可用。

相关内容