如何解决错误“ bash:wget:命令未找到”

Wget是一个非交互式下载器,可以从Internet下载文件。 HTTP和FTP协议用于通过Internet下载文件。 但是,如果尚未在系统上安装wget实用程序,则在运行时可能会收到“ bash:wget:找不到命令”错误。 本文将快速帮助您解决“ bash:wget:找不到命令”错误。

错误说明:

使用wget命令时,您将收到以下错误消息:

[[email protected] ~]# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
-bash: wget: command not found

如何解决“重击:wget:找不到命令”错误

为了解决“ bash:wget:找不到命令”错误,您需要在服务器上安装wget实用程序。

在Debian和Ubuntu上:

[email protected]ubuntu:~# apt-get install wget

示例安装日志:

[email protected]:~# apt-get install wget
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  wget
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 298 kB of archives.
After this operation, 901 kB of additional disk space will be used.
Get:1 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64                                                                                         
wget amd64 1.17.1-1ubuntu1.2 [298 kB]
Fetched 298 kB in 0s (401 kB/s)
Selecting previously unselected package wget.
(Reading database ... 51222 files and directories currently installed.)
Preparing to unpack .../wget_1.17.1-1ubuntu1.2_amd64.deb ...
Unpacking wget (1.17.1-1ubuntu1.2) ...
Processing triggers for install-info (6.1.0.dfsg.1-5) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up wget (1.17.1-1ubuntu1.2) ...

在RHEL和Centos上。

[[email protected] ~]# yum install wget

示例安装日志:

[[email protected] ~]# yum install wget
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 0:1.14-13.el7 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
========================================================================================================================================================================
Package                        Arch                             Version                               Repository                                                  Size
========================================================================================================================================================================
Installing:
wget                           x86_64                           1.14-13.el7                           rhui-REGION-rhel-server-releases                           546 k
 
Transaction Summary
========================================================================================================================================================================
Install  1 Package
 
Total download size: 546 k
Installed size: 2.0 M
Is this ok [y/d/N]: y
Downloading packages:
wget-1.14-13.el7.x86_64.rpm                                                                                                                      | 546 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : wget-1.14-13.el7.x86_64                                                                                                                              1/1
  Verifying  : wget-1.14-13.el7.x86_64                                                                                                                              1/1
 
Installed:
  wget.x86_64 0:1.14-13.el7
 
Complete!
[[email protected] ~]#

如何使用wget通过Internet下载文件。

句法:

wget http://url/file
 
or
 
wget ftp://url/file

加载日志示例:

[[email protected] ~]# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
--2017-05-06 11:21:34--  http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
Resolving packages.sw.be (packages.sw.be)... failed: Name or service not known.
wget: unable to resolve host address ‘packages.sw.be’
[[email protected] ~]# wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm
--2017-05-06 11:21:34--  http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm
Resolving dl.fedoraproject.org (dl.fedoraproject.org)... 209.132.181.24, 209.132.181.25, 209.132.181.23
Connecting to dl.fedoraproject.org (dl.fedoraproject.org)|209.132.181.24|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 14704 (14K) [application/x-rpm]
Saving to: ‘epel-release-7-9.noarch.rpm’
 
100%[==============================================================================================================================>] 14,704      57.8KB/s   in 0.2s
 
2017-05-06 11:21:34 (57.8 KB/s) - ‘epel-release-7-9.noarch.rpm’ saved [14704/14704]

在上面的示例中,我们从URL“ packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2”下载了文件“ rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm”。 “ el6.rf.x86_64.rpm”使用HTTP协议。

Sidebar