简体   繁体   English

在 Linux 中,“bash”命令何时提供 ~/.bash_profile 或 ~/.profile 文件?

[英]In Linux, when does the “bash” command source a ~/.bash_profile or ~/.profile file?

I am currently using ssh to access a linux computer.我目前正在使用 ssh 访问 linux 计算机。 I use the command:我使用命令:

ssh -t user@hostaddress 'cd ~/Desktop && bash'

When I get there, I see that neither ~/.bash_profile nor ~/.profile are sourced.当我到达那里时,我看到~/.bash_profile~/.profile都没有来源。 What are the rules surrounding when these are sourced in?何时采购这些产品的规则是什么? The reason I call bash is because I am able to get terminal colors when I do bash (blue folders, etc) that I otherwise cannot get just by using ssh user@hostaddress .我调用 bash 的原因是因为我在执行 bash(蓝色文件夹等)时能够获得终端颜色,否则我无法仅通过使用ssh user@hostaddress获得这些颜色。

You're not running bash as a login shell -- using bash -l should source .bash_profile .您没有将bash作为登录外壳运行 - 使用bash -l应该提供.bash_profile Otherwise you can use .bashrc .否则你可以使用.bashrc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM