Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
5 Ways to Find a ‘Binary Command’ Description and Location on File System
Have you ever encountered a binary command and wondered where it's located on your file system? A binary command is a compiled program that you can run in your terminal. It's easy to get lost in the maze of directories on your computer, but fear not ? we have compiled five ways to find a binary command's description and location on your file system.
Use "which" Command
The which command is a simple but effective way to locate a binary command's location. It tells you the full path of the command you are looking for. Simply open your terminal and type:
which <command>
For example, if you're looking for the location of the ls command, type:
which ls
/bin/ls
This will output the location of the ls command, which is usually located in the /bin/ directory.
Use "whereis" Command
The whereis command is similar to which, but it provides additional information, such as the location of the binary, source files, and manual page. To use the whereis command, open your terminal and type:
whereis <command>
For example, if you're looking for the location of the gcc command:
whereis gcc
gcc: /usr/bin/gcc /usr/lib/gcc /usr/share/man/man1/gcc.1.gz
This outputs the location of the gcc binary, as well as related files and manual pages.
Use "locate" Command
The locate command is a powerful tool for finding files on your system. It works by indexing your file system and creating a database of all files. To use the locate command:
locate <command>
For example, if you're looking for the location of the grep command:
locate grep
This will output a list of all files that contain the word "grep" in their name or path. You can narrow down your search by looking for files in the /bin/ directory.
Use "find" Command
The find command is another powerful tool for searching files based on specific criteria. To search for a binary command across the entire file system:
find / -name <command> -type f -executable 2>/dev/null
For example, to find the curl command:
find / -name curl -type f -executable 2>/dev/null
This searches your entire file system for executable files named "curl". The 2>/dev/null suppresses permission errors.
Use "type" Command
The type command is similar to which, but it also tells you whether the command is a built-in command, function, or alias:
type <command>
For example:
type echo
echo is a shell builtin
type ls
ls is /bin/ls
Additional Methods
Package Manager Commands
For Debian-based systems, use dpkg to find which package contains a binary:
dpkg -S <command>
For Red Hat-based systems, use:
rpm -qf $(which <command>)
Check PATH Environment Variable
When you run a command, your shell searches directories listed in the PATH variable:
echo $PATH
Use Manual Pages
To get detailed information about a command:
man <command>
Comparison of Methods
| Command | Purpose | Information Provided |
|---|---|---|
| which | Find executable location | Full path only |
| whereis | Find binary, source, manual | Binary, source files, man pages |
| type | Identify command type | Built-in, function, alias, or path |
| locate | Fast file search | All matching files (uses database) |
| find | Real-time file search | Live search with criteria |
Conclusion
Finding the location of binary commands on your file system is an essential skill for system administrators and developers. The which and type commands provide quick answers for basic queries, while whereis, locate, and find offer more comprehensive information when needed.
