在linux(CentOS7)服务器中,当执行某命令时,如果该命令不存在,会打印出“-bash: xxx: command not found”。
[root@elasticsearch ~]# shasum
-bash: shasum: command not found
[root@elasticsearch ~]# 
使用yum install command安装其对应的package时,有时会发现package包不可用,即:“No package shasum available”
[root@elasticsearch ~]# yum install shasum
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
No package shasum available.
Error: Nothing to do
[root@elasticsearch ~]# 
这时怎么办呢?yum provides命令就是用于查找提供特定文件的软件包,无论其文件是否已安装
1.yum provides用法
yum provides <command>
2.yum provides样例
命令:
yum provides shasum
[root@elasticsearch ~]# yum provides shasum
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
1:perl-Digest-SHA-5.85-4.el7.x86_64 : Perl extension for SHA-1/224/256/384/512
#命令的输出将显示提供该文件的软件包及其版本信息。
#如果文件真的未找到,则输出将为空。
Repo        : CentOS7
Matched from:
Filename    : /usr/bin/shasum[root@elasticsearch ~]# 
[root@elasticsearch ~]# yum install perl-Digest-SHA-5.85-4.el7.x86_64
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package perl-Digest-SHA.x86_64 1:5.85-4.el7 will be installed
--> Finished Dependency ResolutionDependencies Resolved=============================================================================================================================================================Package                                   Arch                             Version                                  Repository                         Size
=============================================================================================================================================================
Installing:perl-Digest-SHA                           x86_64                           1:5.85-4.el7                             CentOS7                            58 kTransaction Summary
=============================================================================================================================================================
Install  1 PackageTotal download size: 58 k
Installed size: 110 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transactionInstalling : 1:perl-Digest-SHA-5.85-4.el7.x86_64                                                                                                       1/1 Verifying  : 1:perl-Digest-SHA-5.85-4.el7.x86_64                                                                                                       1/1 Installed:perl-Digest-SHA.x86_64 1:5.85-4.el7                                                                                                                        Complete!
[root@elasticsearch ~]# shasum --help
Usage: shasum [OPTION]... [FILE]...
Print or check SHA checksums.
With no FILE, or when FILE is -, read standard input.-a, --algorithm   1 (default), 224, 256, 384, 512, 512224, 512256-b, --binary      read in binary mode-c, --check       read SHA sums from the FILEs and check them-t, --text        read in text mode (default)-p, --portable    read in portable modeproduces same digest on Windows/Unix/Mac-0, --01          read in BITS modeASCII '0' interpreted as 0-bit,ASCII '1' interpreted as 1-bit,all other characters ignoredThe following two options are useful only when verifying checksums:-s, --status      don't output anything, status code shows success-w, --warn        warn about improperly formatted checksum lines-h, --help        display this help and exit-v, --version     output version information and exitWhen verifying SHA-512/224 or SHA-512/256 checksums, indicate the
algorithm explicitly using the -a option, e.g.shasum -a 512224 -c checksumfileThe sums are computed as described in FIPS-180-4.  When checking, the
input should be a former output of this program.  The default mode is to
print a line with checksum, a character indicating type (`*' for binary,
` ' for text, `?' for portable, `^' for BITS), and name for each FILE.Report shasum bugs to mshelor@cpan.org
[root@elasticsearch ~]# 
另外,使用yum provides命令,需要具有root用户或具有sudo权限。