今天学习 3 个 Linux
小命令 分别是 reboot
、poweroff
、wget
reboot
命令用于重启系统
poweroff
命令用于关闭系统
以上两个命令需使用 root 权限执行。
wget
命令用于从网络下下载资源文件,其格式为 wget [参数] 下载地址
wget [option]... [URL]...
常用选项:
-b
后台下载模式,启动后转入后台执行-P
下载到指定目录-t
最大尝试次数-c
断点续传-p
下载页面内所有资源-r
递归下载参考实例:
首先 我们使用 Docker 下载的是一个非常干净的系统,并不会存在 wget 命令,不信,你可以试下
[root@3d38bf89f74a /]# wget
bash: wget: command not found
那么,怎么办呢?我们可以使用默认的 yum
命令安装 wget
[root@3d38bf89f74a /]# yum install wget
Failed to set locale, defaulting to C.UTF-8
CentOS-8 - AppStream 1.8 MB/s | 5.8 MB 00:03
CentOS-8 - Base 1.8 MB/s | 2.2 MB 00:01
CentOS-8 - Extras 7.9 kB/s | 7.0 kB 00:00
Dependencies resolved.
====================================================================================================
Package Architecture Version Repository Size
====================================================================================================
Installing:
wget x86_64 1.19.5-8.el8_1.1 AppStream 735 k
Installing dependencies:
libpsl x86_64 0.20.2-5.el8 BaseOS 61 k
publicsuffix-list-dafsa noarch 20180723-1.el8 BaseOS 56 k
Transaction Summary
====================================================================================================
Install 3 Packages
Total download size: 852 k
Installed size: 3.0 M
Is this ok [y/N]: y
Downloading Packages:
CentOS-8 - Base 196% [==========================================================-] 1.8(1/3): publicsuffix-list-dafsa-20180723-1.el8.noarch.rpm 1.2 MB/s | 56 kB 00:00
(2/3): libpsl-0.20.2-5.el8.x86_64.rpm 1.2 MB/s | 61 kB 00:00
(3/3): wget-1.19.5-8.el8_1.1.x86_64.rpm 1.5 MB/s | 735 kB 00:00
----------------------------------------------------------------------------------------------------
Total 116 kB/s | 852 kB 00:07
warning: /var/cache/dnf/AppStream-02e86d1c976ab532/packages/wget-1.19.5-8.el8_1.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 8483c65d: NOKEY
CentOS-8 - AppStream 1.6 MB/s | 1.6 kB 00:00
Importing GPG key 0x8483C65D:
Userid : "CentOS (CentOS Official Signing Key) <security@centos.org>"
Fingerprint: 99DB 70FA E1D7 CE22 7FB6 4882 05B5 55B3 8483 C65D
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : publicsuffix-list-dafsa-20180723-1.el8.noarch 1/3
Installing : libpsl-0.20.2-5.el8.x86_64 2/3
Installing : wget-1.19.5-8.el8_1.1.x86_64 3/3
Running scriptlet: wget-1.19.5-8.el8_1.1.x86_64 3/3
Verifying : wget-1.19.5-8.el8_1.1.x86_64 1/3
Verifying : libpsl-0.20.2-5.el8.x86_64 2/3
Verifying : publicsuffix-list-dafsa-20180723-1.el8.noarch 3/3
Installed:
libpsl-0.20.2-5.el8.x86_64 publicsuffix-list-dafsa-20180723-1.el8.noarch
wget-1.19.5-8.el8_1.1.x86_64
Complete!
接着,就可以使用了 wget
命令了。
下载 PHP7.4.8 源码
wget https://www.php.net/distributions/php-7.4.8.tar.gz
后台下载
[root@f709031398b1 /]# wget -b https://www.php.net/distributions/php-7.4.8.tar.gz
Continuing in background, pid 78.
在进行后台下载时,如果需要查看下载进度,可以使用以下命令来查看
[root@f709031398b1 /]# tail -f wget-log
--2020-07-19 11:05:54-- https://www.php.net/distributions/php-7.4.8.tar.gz
Resolving www.php.net (www.php.net)... 185.85.0.29, 2a02:cb40:200::1ad
Connecting to www.php.net (www.php.net)|185.85.0.29|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 16505222 (16M) [application/octet-stream]
Saving to: 'php-7.4.8.tar.gz'
0K .......... .......... .......... .......... .......... 0% 89.9K 2m59s
50K .......... .......... .......... .......... .......... 0% 77.8K 3m12s
100K .......... .......... .......... .......... .......... 0% 236K 2m30s
150K .......... .......... .......... .......... .......... 1% 66.9K 2m52s
200K .......... .......... .......... .......... .......... 1% 53.0K 3m17s
下载并以不同的名称保存 使用参数 -O
指定文件名
wget -O php74 https://www.php.net/distributions/php-7.4.8.tar.gz
ok,以上就是几个常用的实例,更多实例请参考 https://man.linuxde.net/wget