Docker-compose in /usr/bin

I encountered a problem:

[***@localhost ***]$ sudo docker-compose
sudo: docker-compose: command not found
[***@localhost ***]$ sudo whereis docker-compose
docker-compose: /usr/local/bin/docker-compose

I installed docker-compose, but there's no such command if executed as root. Pretty weird. I read what permission the file was and changed it, wish that works:

[***@localhost ***]$ ls -l /usr/local/bin/docker-compose
-rwxr-xr-x. 1 root root 8856752 Nov  5 09:25 /usr/local/bin/docker-compose
[****@localhost ****]$ sudo chmod 777 /usr/local/bin/docker-compose
[sudo] password for **:
[****@localhost ****]$ ls -l /usr/local/bin/docker-compose         
-rwxrwxrwx. 1 root root 8856752 Nov  5 09:25 /usr/local/bin/docker-compose
[****@localhost ****]$ sudo docker-compose
sudo: docker-compose: command not found
[****@localhost ****]$

As you see, it's useless, root user still not found docker-compose command. Therefore, I asked my friend. He suggested that I should type sudo /usr/local/bin/docker-compose command to see absolute path works or not.

It works -- But I don't want to type absolute path always, what should I do? He said,

Move to /usr/bin, and that's done.

Yes, moved to /usr/bin works. However, why it works? What's different between /usr/local/bin and /usr/bin?

Here are my notes:

  1. /usr/local/bin contain commands what user have.
  2. Whereas, /usr/bin contain commands what system have.
  3. But, if /usr/local/bin contain commands what user have, why sudo -- that is, root user-- cannot run /usr/local/bin? The answer is, /usr/local/bin don't have shell script for root user, as root user is so powerful that any action may result into danger.

That's all.

References