如何在linux alpine中为整个机器添加PATH变量的路径?

Sae*_*ati 6 linux bash path environment-variables alpine-linux

我知道我可以在当前会话中export PATH="$PATH:my_path"添加PATH变量。

我还知道我可以添加此行以~/.bash_profile使其在用户的会话中持续存在:

echo 'PATH="$PATH:my_path"' >> ~/.bash_profile

我还知道在 Linux 中ubuntu我可以添加该行/etc/bash.bashrc,并且它始终可供所有用户使用。

但是,我的 linux 在容器内alpine,我不知道在哪里添加该文件。我在谷歌中找不到它。

小智 1

Alpine Linux 默认使用 ash 作为 shell,它与 bash 非常相似。每个人的设置都在文件 /etc/profile 中

/sf/answers/2474990801/

如果我必须自己找到这个,我会运行一个 find 来查看 PATH 的设置位置,我会 grep 遍历 etc 目录。

grep "PATH=" /etc/*
Run Code Online (Sandbox Code Playgroud)