In the context of Linux commands, "find" and "which" have similar but distinct functions:
"Find" is a command used to search for files and directories within a specified location. It can be used to search for files based on various criteria, such as name, size, modification time, etc. For example: "find / -name myfile.txt" will search for the file named "myfile.txt" starting from the root directory "/".
"Which" is a command used to determine the location of a specified executable file in the system PATH. It returns the full path of the executable file if it is found, or an error message if it is not found. For example: "which ls" will return the full path of the "ls" executable, which is usually "/bin/ls".
In summary, "find" is used for searching for files and directories, while "which" is used for determining the location of executable files.
which ls
This command will return the full path of the "ls" executable, such as "/bin/ls".
which mysql
This will return the path of the mysql executable, typically something like /usr/bin/mysql
Find
Consider the following directory structure:
/
home/
user1/
file1.txt
file2.txt
user2/
file3.txt
find /home -type f
# find / -type d -name "etc"
OR
$ sudo find / -type d -name "etc"
OR
$ sudo find / -type d -iname "etc"
Top comments (0)