we often find a file in Linux, but do not know where to put it, you can use some of the following commands to search:whichView the location of the executable file. WhereisView the location of the file. LocateView the file location with the database. Findactual search hard disk query file name. The purpose of the which command is to search for the location of a system command in the path specified by the path variable, and return the first search result. That is, with the which command, you can see whether a system command exists, and the command that executes exactly which location. 1. Command format:whichexecutable file name2. Command function: The which directive searches for the location of a system command in the path specified by the path variable, and returns the first search result. 3. Command parameters:-n Specifies the length of the file name, which must be greater than or equal to the longest file name in all files. -P and-The n parameter is the same, but the path to the file is included here. -WSpecifies the width of the field at the output. -V display version information4. Use instance: Instance 1: Find file, show command path command:which Lsmod[[Email protected]~]#which pwd/bin/pwd[[Email protected]~]#whichAddUser/usr/sbin/Adduser[[email protected]~] #说明:whichis to search for a running file based on the directory within the PATH variable that the user has configured! Therefore, the different PATH configuration content found the command of course not the same! Example 2: UsingwhichTo find outwhichcommand:which which[[Email protected]~]#which whichaliaswhich='alias |/usr/bin/which--tty-only--read-alias--SHOW-DOT--show-tilde'/usr/bin/which[[Email protected]~] #说明: There's going to be two of them.which, one of which is alias, which is called the "command alias", which means the inputwhichwill be waiting for the next sequence of orders! Example 3: Find the CD this command command:whichCD Description: cd this common command can not find Ah! Why is it? This is because the CD is a command built in bash! ButwhichThe default is to find the PATH within the standard directory, so certainly can not find!
Linux Command Learning Note (+): which command