DEV Community

Cover image for Where this command comes from?
Talles L
Talles L

Posted on

Where this command comes from?

The which command gives you the local path of it:

$ which redis-cli
/usr/bin/redis-cli
Enter fullscreen mode Exit fullscreen mode

And, if you are using a Debian based distro, you can combine it with dpkg to figure it out from which package does it comes from:

$ dpkg -S `which redis-cli` 
redis-tools: /usr/bin/redis-cli
Enter fullscreen mode Exit fullscreen mode

Top comments (5)

Collapse
 
devh0us3 profile image
Alex P

if which returns empty result – try the type, and then you may see that the command could be an alias

Some more useful commands: whereis, whatis

Demo:

Image description

Collapse
 
moopet profile image
Ben Sinclair

Another tip is that you can use command -v instead of which. It's slightly less memorable, but it should work on every system you use; which might not.

Collapse
 
viiik profile image
Eduard

If you use PowerShell, the equivalent is where.

Collapse
 
moopet profile image
Ben Sinclair

I'd suggest using command -v instead of which as it's more portable. Also using $(...) instead of backticks in general, so:

dpky -S $(command -v redis-cli)

because it's usually easier to use this kind of substitution. For one thing, you can nest it, and if you end up using it for some things, then using it for everything makes sense, right?

Collapse
 
phalkmin profile image
Paulo Henrique

Whaaaaaat 🤯