For example, I have git installed on my system.
But I don’t remember where I installed it, so which command is fit to find this out?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
If it is in your path, then you can run either type git or which git. The which command has had problems getting the proper path (confusion between environment and dot files). For type, you can get just the path with the -p argument.
If it is not in your path, then it’s best to look for it with locate -b git It will find anything named ‘git’. It’ll be a long list, so might be good to qualify it with locate -b git | fgrep -w bin.
Method 2
The POSIX standard way to do this is command -v git. All UNIX-like systems should support this.
Method 3
whereis git and you get the path to the command.
that is just if the git is in you PATH variable, in case you have installed it not through you package manager, it is more complex and you should use the find or locate commands.
Method 4
The other answers here seem to be largely geared towards modern versions of Linux, so if you happen to use git on an OS that doesn’t have locate, whereis, which, or apropos (like Solaris, HPUX, etc), then there is always the old standby find.
find / -name git
One some older versions of the systems listed above, you may need a -print option supplied to find.
find / -name git -print
And if you do use locate, make sure you run updatedb periodically. (locate.updatedb on some BSD derivatives)
Method 5
To get the path to the installed program you either use whereis or which. If you happen to forget it’s name, you can useapropos with a synonym or description of your utility, e.g. apropos "version control" will find git. Following that is of course the whatis command to briefly summarize the function of a program. This does however not apply to all programs and functions on your system. Try for instance whatis "the meaning of life, universe and everything".
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0