secureCRT连接后提示-bash: User: command not found的解决办法

简介:

今日SSH连接测试机时,欢迎界面提示如下内容:

1
2
3
4
5
Last login: Tue Jul 28 22:08:07 2015 from 10.241.10.7
欢迎回来
-bash: .bashrc: command not found
-bash: User: command not found
-bash: Source: command not found

.bashrc前十行如下

1
2
3
4
5
6
7
8
9
10
11
root@samba ~$cat -n .bashrc | head
      1    .bashrc
      2    
      3    User specific aliases and functions
      4    
      5    alias rm='rm -i'
      6    alias cp='cp -i'
      7    alias mv='mv -i'
      8    
      9    Source global definitions
     10    if [ -f /etc/bashrc ]; then

经与另外一台机器对比后发现,第一、三、九行少了一个"#"号,添加完后上述错误提示即消失。

1
2
3
4
5
6
7
8
9
10
11
root@samba ~$cat -n .bashrc | head
      1    #.bashrc
      2    
      3    #User specific aliases and functions
      4    
      5    alias rm='rm -i'
      6    alias cp='cp -i'
      7    alias mv='mv -i'
      8    
      9    #Source global definitions
     10    if [ -f /etc/bashrc ]; then
1
2
3
4
5
6
7
Connecting to 10.240.210.233:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.
 
Last login: Tue Jul 28 22:19:30 2015 from 10.241.10.7
欢迎回来
root@samba ~$

远程连接登陆Linux服务器时,/etc/profile、~/.bash_profile、~/.bashrc的启动顺序如下

首先启动 /etc/profile 文件,然后再启动用户目录下的 ~/.bash_profile。如果 ~/.bash_profile文件存在的话,一般还会执行 ~/.bashrc文件。因为在 ~/.bash_profile文件中一般会有下面的代码:

1
2
3
if  [ -f ~/.bashrc ] ;  then
. . /bashrc
fi

~/.bashrc中,一般还会有以下代码:

1
2
3
if  [ -f  /etc/bashrc  ] ;  then
/bashrc
fi

所以,~/.bashrc会调用 /etc/bashrc文件。最后,在退出shell时,还会执行 ~/.bash_logout文件。

执行顺序为:/etc/profile -> (~/.bash_profile | ~/.bash_login | ~/.profile) -> ~/.bashrc -> /etc/bashrc -> ~/.bash_logout


PS:写这篇博客时房间已停电,吼吼吼,不过正好练习了下盲打。




本文转自 xoyabc 51CTO博客,原文链接:http://blog.51cto.com/xoyabc/1679412,如需转载请自行联系原作者

相关文章
|
6月前
|
关系型数据库 MySQL Shell
【Linux命令】-bash: mysql: command not found
【Linux命令】-bash: mysql: command not found
56 0
|
2月前
|
Linux Shell
mac/linux提示bash: telnet: command not found
mac/linux提示bash: telnet: command not found
|
4月前
|
Shell 应用服务中间件 开发工具
bash: vi: command not found
bash: vi: command not found
|
9月前
|
Shell
bash: accelerate: command not found
bash: accelerate: command not found
1572 3
|
4月前
|
Linux Shell Windows
4:Bash shell命令-步入Linux的现代方法
4:Bash shell命令-步入Linux的现代方法
53 0
|
8月前
|
Ubuntu 安全 Linux
不用安装虚拟机,直接在Windows上面运行Linux Bash Shell,嗯!真香!!!
不用安装虚拟机,直接在Windows上面运行Linux Bash Shell,嗯!真香!!!
152 0
|
9月前
|
Kubernetes Shell Linux
linux中sh/bash 进程为何不接受kill SIGTERM
在k8s的优雅终止中,如果容器的入口进程是sh 或者bash,需要注意你设定的gracefulterminate是无效的
105 0
|
10月前
|
Java Shell Linux
如何在 Linux 中使用 Bash For 循环
如何在 Linux 中使用 Bash For 循环
90 0
|
10月前
|
Unix Shell Linux
Linux中sh与bash的区别(详细介绍)
Linux中sh与bash的区别(详细介绍)
311 0
|
11月前
|
Shell Linux
Linux pip命令报错 -bash: pip: command not found
Linux pip命令报错 -bash: pip: command not found
254 0

相关课程

更多