Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Linux whereis command

Linux whereis command

Linux Command Reference Linux Command Reference

The Linux whereis command is used to locate files.

This command searches specific directories for files that meet the criteria. These files should be source code, binary files, or help files.

This command can only find binary files, source code files, and man pages; to locate general files, use the locate command.

Syntax

whereis [-bfmsu][-B <目录>...][-M <目录>...][-S <目录>...][文件...]

Parameters:

  • -b: search only for binary files.
  • -B search for binary files only under the specified directory.
  • -f: do not display the path name before the file name.
  • -m: search only for documentation files.
  • -M search for documentation files only under the specified directory.
  • -s: search only for source code files.
  • -S search for source code files only under the specified directory.
  • -u: find files that do not contain the specified type.
  • Example

    To use the "whereis" command to view the location of the "bash" command, enter the following command:

    
    
    $ whereis bash 
    
    

    After running the above command, the output is as follows:

    
    
    bash:/bin/bash/etc/bash.bashrc/usr/share/man/man1/bash.1.gz 
    
    

    Note: the above output, from left to right, shows the queried program name, the bash path, and the path to bash's man page.

    If the user needs to query binary files or help files separately, the following commands can be used:

    
    
    $ whereis -b bash 
    
    $ whereis -m bash 
    
    

    The output is as follows:

    
    
    $ whereis -b bash               #显示bash 命令的二进制程序  
    
    bash: /bin/bash /etc/bash.bashrc /usr/share/bash    # bash命令的二进制程序的地址  
    
    $ whereis -m bash               #显示bash 命令的帮助文件  
    
    bash: /usr/share/man/man1/bash.1.gz  #bash命令的帮助文件地址  
    
    

    Linux Command Reference Linux Command Reference