---恢复内容开始---

1、登陆一个新的vps时候,发现git的版本是1.8的,太久了,于是就源码安装了新的版本2.4。

2、老版本在/usr/bin/git,新版本安装的/usr/local/bin/git

3、问题来了,安装完新的后,卸载了旧的版本,在运行git --version时,却提示如下错误:

-bash: /usr/bin/git: No such file or directory

4、我去,bash只搜索旧的路径,查看了一下PATH变量:

[root@noi bin]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

没有问题,而且/usr/local/bin还在前面,但系统却不搜索,我晕,这是啥问题?

5、经过一番折腾,终于找到答案,原来Bash路径也是有缓存地,只要运行过的命令,bash就会保存到一张hash表里,下次直接从hash表里找地址,就不按个路径找了。

6、运行:help hash查看一下:

[root@noi bin]# help hash
hash: hash [-lr] [-p pathname] [-dt] [name ...]
Remember or display program locations. Determine and remember the full pathname of each command NAME. If
no arguments are given, information about remembered commands is displayed. Options:
-d forget the remembered location of each NAME
-l display in a format that may be reused as input
-p pathname use PATHNAME is the full pathname of NAME
-r forget all remembered locations
-t print the remembered location of each NAME, preceding
each location with the corresponding NAME if multiple
NAMEs are given
Arguments:
NAME Each NAME is searched for in $PATH and added to the list
of remembered commands. Exit Status:
Returns success unless NAME is not found or an invalid option is given.

7、在运行hash命令,查看hash表里都有啥?

[root@noi bin]# hash
hits command
/usr/bin/git
/usr/sbin/ifconfig
/usr/bin/rm
/usr/bin/vim
/usr/bin/wget
/usr/bin/mv
/usr/bin/yum
/usr/bin/ln
/usr/bin/man
/usr/bin/make
/usr/bin/tar
/usr/bin/ls

果然,第一个就是git,而且地址还是老地址。

8、运行: hash -d git 删除掉git的缓存。

9、再次执行git --version 哈哈,正确显示了新安装的版本。

---恢复内容结束---

最新文章

  1. pxe无人值守安装多网卡注意事项
  2. Mongodb的备份,恢复,导入与导出(cmd命令行实现)
  3. sql-将一个表中的数导入另一个表中
  4. php微信接口实例
  5. 2015-2016 ACM-ICPC, NEERC, Southern Subregional Contest, B. Layer Cake
  6. StackTrace,Trim
  7. Netdom query基本用法
  8. YII 快速创建项目GII
  9. Windows Phone使用sliverlight toolkit实现页面切换动画效果
  10. 基于lua的网页脚本开发语言cgilua(转)
  11. 安卓组件-BroadcastReceiver
  12. 为什么ABAP开发者需要使用面向对象技术?
  13. 【TensorFlow 官网 可以直接访问】让中国开发者更容易地使用TensorFlow打造人工智能应用
  14. Python 实现 KD-Tree 最近邻算法
  15. [OC] NSTimer
  16. grafana--邮箱告警配置
  17. [LeetCode] Number of Matching Subsequences 匹配的子序列的个数
  18. SaltStack安装配置详解
  19. 学习笔记11—MATLAB 界面设计
  20. SpringMVC参考

热门文章

  1. <摘录>cocos2d-x 从环境搭建到win32项目移植android平台
  2. PatchGuard Disabled V3
  3. Visio显示不完整
  4. 在matlab中clear,clc,clf,hold作用介绍
  5. 表单对象属性disabled和readOnly
  6. c++类模板template中的typename使用方法-超级棒
  7. (转)HBase 常用Shell命令
  8. libev客户端
  9. MySQL : ERROR 1042 (HY000): Can't get hostname for your address
  10. leetcode 282. 给表达式添加运算符