我是靠谱客的博主 淡定白羊,最近开发中收集的这篇文章主要介绍使用ssh登入不执行.bashrc解决方法,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

参考 : http://blog.csdn.net/lawrencesgj/article/details/8979803

https://wido.me/sunteya/understand-bashrc-and-profile/

login shell 和 no-login shell

“login shell” 代表用户登入, 比如使用 “su -“ 命令, 或者用 ssh 连接到某一个服务器上, 都会使用该用户默认 shell 启动 login shell 模式.

该模式下的 shell 会去自动执行 /etc/profile 和 ~/.profile 文件, 但不会执行任何的 bashrc 文件, 所以一般再 /etc/profile 或者 ~/.profile 里我们会手动去 source bashrc 文件.

而 no-login shell 的情况是我们在终端下直接输入 bash 或者 bash -c “CMD” 来启动的 shell.

该模式下是不会自动去运行任何的 profile 文件.

参考 ~/.profile:

[html]  view plain copy 在code上查看代码片 派生到我的代码片
  1. # ~/.profile: executed by the command interpreter for login shells.  
  2. # This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login  
  3. # exists.  
  4. # see /usr/share/doc/bash/examples/startup-files for examples.  
  5. # the files are located in the bash-doc package.  
  6.   
  7.   
  8. # the default umask is set in /etc/profile; for setting the umask  
  9. # for ssh logins, install and configure the libpam-umask package.  
  10. #umask 022  
  11.   
  12.   
  13. # if running bash  
  14. if [ -n "$BASH_VERSION" ]; then  
  15.     # include .bashrc if it exists  
  16.     if [ -f "$HOME/.bashrc" ]; then  
  17.         . "$HOME/.bashrc"  
  18.     fi  
  19. fi  
  20.   
  21.   
  22. # set PATH so it includes user's private bin if it exists  
  23. if [ -d "$HOME/bin" ] ; then  
  24.     PATH="$HOME/bin:$PATH"  
  25. fi  

最后

以上就是淡定白羊为你收集整理的使用ssh登入不执行.bashrc解决方法的全部内容,希望文章能够帮你解决使用ssh登入不执行.bashrc解决方法所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(45)

评论列表共有 0 条评论

立即
投稿
返回
顶部