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,如需转载请自行联系原作者

相关文章
|
2天前
|
Shell Linux 开发工具
Anaconda安装后报错 -bash: conda: command not found 如何处理
【6月更文挑战第26天】Anaconda安装后报错 -bash: conda: command not found 如何处理
18 4
|
11天前
|
Shell Linux 开发工具
Anaconda安装后报错 -bash: conda: command not found 如何处理
【6月更文挑战第17天】Anaconda安装后报错 -bash: conda: command not found 如何处理
19 4
|
7天前
|
Shell Linux 开发工具
Anaconda安装后报错 -bash: conda: command not found 如何处理
【6月更文挑战第20天】Anaconda安装后报错 -bash: conda: command not found 如何处理
49 0
|
1月前
|
监控 安全 Shell
防止员工泄密的措施:在Linux环境下使用Bash脚本实现日志监控
在Linux环境下,为防止员工泄密,本文提出使用Bash脚本进行日志监控。脚本会定期检查系统日志文件,搜索敏感关键词(如"password"、"confidential"、"secret"),并将匹配项记录到临时日志文件。当检测到可疑活动时,脚本通过curl自动将数据POST到公司内部网站进行分析处理,增强信息安全防护。
142 0
|
1月前
|
Linux Shell Windows
4:Bash shell命令-步入Linux的现代方法
4:Bash shell命令-步入Linux的现代方法
63 0
|
10月前
|
Ubuntu 安全 Linux
不用安装虚拟机,直接在Windows上面运行Linux Bash Shell,嗯!真香!!!
不用安装虚拟机,直接在Windows上面运行Linux Bash Shell,嗯!真香!!!
191 0
|
8月前
|
关系型数据库 MySQL Shell
【Linux命令】-bash: mysql: command not found
【Linux命令】-bash: mysql: command not found
64 0
|
1月前
|
存储 Shell Linux
Linux Bash 脚本中的 IFS 是什么?
【4月更文挑战第25天】
41 0
Linux Bash 脚本中的 IFS 是什么?
|
1月前
|
Java Shell Linux
【linux进程控制(三)】进程程序替换--如何自己实现一个bash解释器?
【linux进程控制(三)】进程程序替换--如何自己实现一个bash解释器?
|
1月前
|
Shell Linux
【Linux】Bash支持各种指令选项的原理:命令行参数
【Linux】Bash支持各种指令选项的原理:命令行参数

相关课程

更多