为什么Linux不在PATH环境中的所有目录中寻找命令?

时间:2022-05-18 03:44:49

I first install docker through following command from docker site:

我首先通过docker site的以下命令安装docker:

curl -s -O https://get.docker.com/builds/Linux/x86_64/docker-1.6.1 && chmod +x docker-1.6.1 && sudo mv docker-1.6.1 /usr/local/bin/docker

Then I remove the docker in /usr/local/bin directory.

然后我删除/ usr / local / bin目录中的docker。

I install docker through yum again, this time docker is installed in /usr/bin directory:

我再次通过yum安装docker,这次docker安装在/ usr / bin目录中:

[root@dl380gen8snbjbb ~]# ls -lt /usr/bin/docker
-rwxr-xr-x 1 root root 13451927 Apr 20 13:44 /usr/bin/docker

When I execute docker in command:

当我在命令中执行docker时:

[root@dl380gen8snbjbb ~]# docker
-bash: /usr/local/bin/docker: No such file or directory

but the /usr/bin is actually in PATH:

但是/ usr / bin实际上是在PATH中:

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

Why does the system doesn't seek docker command in /usr/bin directory?

为什么系统不在/ usr / bin目录中寻找docker命令?

1 个解决方案

#1


Check following link: https://unix.stackexchange.com/q/5609/55635

请查看以下链接:https://unix.stackexchange.com/q/5609/55635

bash does cache the full path to a command. You can verify that the command you are trying to execute is hashed with the type command:

bash会缓存命令的完整路径。您可以使用type命令验证您尝试执行的命令是否已经过哈希处理:

$ type svnsync svnsync is hashed (/usr/local/bin/svnsync)

$ type svnsync svnsync被哈希(/ usr / local / bin / svnsync)

To clear the entire cache:

要清除整个缓存:

$ hash -r

$ hash -r

Or just one entry:

或者只是一个条目:

$ hash -d svnsync

$ hash -d svnsync

For additional information, consult help hash and man bash.

有关其他信息,请参阅help hash和man bash。

#1


Check following link: https://unix.stackexchange.com/q/5609/55635

请查看以下链接:https://unix.stackexchange.com/q/5609/55635

bash does cache the full path to a command. You can verify that the command you are trying to execute is hashed with the type command:

bash会缓存命令的完整路径。您可以使用type命令验证您尝试执行的命令是否已经过哈希处理:

$ type svnsync svnsync is hashed (/usr/local/bin/svnsync)

$ type svnsync svnsync被哈希(/ usr / local / bin / svnsync)

To clear the entire cache:

要清除整个缓存:

$ hash -r

$ hash -r

Or just one entry:

或者只是一个条目:

$ hash -d svnsync

$ hash -d svnsync

For additional information, consult help hash and man bash.

有关其他信息,请参阅help hash和man bash。