本文档风哥主要介绍常用工具(vim/wget/curl)的安装与使用,包括vim编辑器、wget下载工具、curl工具的安装、配置和使用技巧,参考RHEL 10官方文档,适合系统管理员在生产环境中使用。更多视频教程www.fgedu.net.cn
Part01-基础概念与理论知识
1.1 常用工具概述
Linux系统中的常用工具包括文本编辑器、下载工具、网络工具等,这些工具是系统管理员日常工作的基础工具。
- 文本编辑器:vim、nano、emacs
- 下载工具:wget、curl、axel
- 网络工具:ping、traceroute、netstat
- 系统工具:top、htop、iotop
- 压缩工具:tar、zip、gzip
1.2 vim编辑器介绍
vim(Vi IMproved)是Linux系统中最流行的文本编辑器之一,具有强大的编辑功能和丰富的插件生态。
- 模式切换:普通模式、插入模式、命令模式、可视模式
- 编辑功能:复制、粘贴、删除、查找、替换
- 配置文件:~/.vimrc、/etc/vimrc
- 插件系统:支持丰富的插件扩展
1.3 下载工具介绍
wget和curl是Linux系统中最常用的下载工具,支持HTTP、HTTPS、FTP等多种协议。
- wget:命令行下载工具,支持断点续传、递归下载
- curl:多协议数据传输工具,支持HTTP、HTTPS、FTP等
- 应用场景:文件下载、API调用、数据传输
Part02-生产环境规划与建议
2.1 工具选择策略
工具选择策略建议:
# 文本编辑器选择
– vim:功能强大,适合高级用户
– nano:简单易用,适合初学者
– emacs:功能丰富,学习曲线陡峭
# 下载工具选择
– wget:适合文件下载,支持断点续传
– curl:适合API调用,支持多种协议
– axel:多线程下载,适合大文件下载
# 使用场景
– 系统配置:vim编辑配置文件
– 文件下载:wget下载软件包
– API调用:curl调用REST API
– 数据传输:curl传输数据
2.2 配置规划
工具配置规划建议:
# vim配置
– 语法高亮:启用语法高亮
– 行号显示:显示行号
– 自动缩进:启用自动缩进
– 搜索高亮:搜索结果高亮
– 备份文件:配置备份文件位置
# wget配置
– 下载目录:设置默认下载目录
– 断点续传:启用断点续传
– 限速下载:限制下载速度
– 代理设置:配置代理服务器
– 日志记录:记录下载日志
# curl配置
– 超时设置:设置连接超时时间
– 重试次数:设置失败重试次数
– 用户代理:设置用户代理
– 认证方式:配置认证方式
– 输出格式:设置输出格式
2.3 最佳实践建议
工具使用最佳实践:
- vim使用:使用vim配置文件提高编辑效率
- wget使用:使用断点续传下载大文件
- curl使用:使用JSON格式处理API响应
- 安全考虑:验证下载文件的完整性
- 性能优化:使用多线程下载提高速度
Part03-生产环境项目实施方案
3.1 vim编辑器安装与配置
3.1.1 安装vim编辑器
# dnf install -y vim-enhanced
Updating Subscription Management repositories.
Last metadata expiration check: 0:30:00 ago on Fri 02 Apr 2026 10:00:00 AM CST.
Dependencies resolved.
================================================================================
Package Architecture Version Repository Size
================================================================================
Installing:
vim-enhanced x86_64 9.0.1895-1.el10 baseos 2.2 M
Installing dependencies:
vim-filesystem noarch 2:9.0.1895-1.el10 baseos 12 k
vim-common x86_64 2:9.0.1895-1.el10 baseos 6.8 M
vim-minimal x86_64 2:9.0.1895-1.el10 baseos 1.6 M
Transaction Summary
================================================================================
Install 4 Packages
Total download size: 10.6 M
Installed size: 35.2 M
Downloading Packages:
(1/4): vim-filesystem-9.0.1895-1.el10.noarch.rpm 12 kB/s | 12 kB 00:01
(2/4): vim-minimal-9.0.1895-1.el10.x86_64.rpm 1.6 MB/s | 1.6 MB 00:01
(3/4): vim-common-9.0.1895-1.el10.x86_64.rpm 6.8 MB/s | 6.8 MB 00:01
(4/4): vim-enhanced-9.0.1895-1.el10.x86_64.rpm 2.2 MB/s | 2.2 MB 00:01
——————————————————————————–
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/4
Installing : vim-filesystem-2:9.0.1895-1.el10.noarch 1/4
Installing : vim-common-2:9.0.1895-1.el10.x86_64 2/4
Installing : vim-minimal-2:9.0.1895-1.el10.x86_64 3/4
Installing : vim-enhanced-9.0.1895-1.el10.x86_64 4/4
Running scriptlet: vim-enhanced-9.0.1895-1.el10.x86_64 4/4
Verifying : vim-common-2:9.0.1895-1.el10.x86_64 1/4
Verifying : vim-filesystem-2:9.0.1895-1.el10.noarch 2/4
Verifying : vim-minimal-2:9.0.1895-1.el10.x86_64 3/4
Verifying : vim-enhanced-9.0.1895-1.el10.x86_64 4/4
Installed:
vim-enhanced-9.0.1895-1.el10.x86_64
vim-common-2:9.0.1895-1.el10.x86_64
vim-filesystem-2:9.0.1895-1.el10.noarch
vim-minimal-2:9.0.1895-1.el10.x86_64
Complete!
# 2. 验证vim安装
# vim –version
VIM – Vi IMproved 9.0 (2022 Jun 28, compiled Apr 1 2026 10:00:00)
Included patches: 1-1895
Modified by
Compiled by
Huge version without GUI. Features included (+) or not (-):
+acl +farsi +mouse_sgr -tag_old_static
+arabic +file_in_path -mouse_sysmouse -tag_any_white
+autocmd +find_in_path +mouse_urxvt -tcl
+autochdir +float +mouse_xterm +termguicolors
-autoservername +folding +multi_byte +terminal
-balloon_eval -footer +multi_lang +terminfo
+balloon_eval_term +fork() -mzscheme +termresponse
-browse +gettext +netbeans_intg +textobjects
++builtin_terms -hangul_input +num64 +textprop
+byte_offset +iconv +packages +timers
+channel +insert_expand +path_extra +title
+cindent +ipv6 -perl +toolbar
+clientserver +job +persistent_undo +user_commands
+clipboard +jumplist +popupwin +vartabs
+cmdline_compl +keymap +postscript +vertsplit
+cmdline_hist +lambda +printer +virtualedit
+cmdline_info +langmap +profile +visual
+comments +libcall -python +visualextra
+conceal +linebreak +python3 +viminfo
+cryptv +lispindent +quickfix +vreplace
+cscope +listcmds +reltime +wildignore
+cursorbind +localmap +rightleft +wildmenu
+cursorshape +lua +ruby +windows
+dialog_con +menu +scrollbind +writebackup
+diff +mksession +signs -X11
+digraphs +modify_fname +smartindent -xfontset
-dnd +mouse -sodium -xim
-ebcdic +mouseshape +sound -xpm
+emacs_tags +mouse_dec +spell -xsmp
+eval +mouse_gpm +startuptime -xterm_clipboard
+ex_extra -mouse_jsbterm +statusline -xterm_save
+extra_search +mouse_netterm -sun_workshop -xterm_italic
+farsi +mouse_sgr +syntax
system vimrc file: “/etc/vimrc”
user vimrc file: “$HOME/.vimrc”
2nd user vimrc file: “~/.vim/vimrc”
user exrc file: “$HOME/.exrc”
fall-back for $VIM: “/usr/share/vim”
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -D_FORTIFY_SOURCE=2 -O2 -flto=auto -ffat-lto-objects -fexceptions -gstack-clash-protection -fasynchronous-unwind-tables -fstack-clash-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fno-stack-protector-strong -fno-semantic-interposition -fno-signed-zeros -fpic -fno-plt -fno-pie -fno-common -U_FORTIFY_SOURCE -D_REENTRANT -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
Linking: gcc -L. -Wl,-z,relro -Wl,-z,now -flto=auto -ffat-lto-objects -fexceptions -gstack-clash-protection -fasynchronous-unwind-tables -fstack-clash-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fno-stack-protector-strong -fno-semantic-interposition -fno-signed-zeros -fpic -fno-plt -fno-pie -fno-common -U_FORTIFY_SOURCE -D_REENTRANT -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -Wl,–as-needed -o vim -lm -ltinfo -lnsl -lselinux -lncurses -lacl -lattr -lgpm
3.1.2 配置vim编辑器
# cat > ~/.vimrc << 'EOF' " vim配置文件 " 作者:fgedu " 日期:2026-04-02 " 语法高亮 syntax on " 显示行号 set number " 自动缩进 set autoindent set smartindent " Tab键设置 set tabstop=4 set shiftwidth=4 set expandtab " 搜索设置 set ignorecase set smartcase set hlsearch set incsearch " 显示状态行 set laststatus=2 set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")} " 编码设置 set encoding=utf-8 set fileencoding=utf-8 set fileencodings=utf-8 " 备份设置 set backup set backupdir=~/.vim/backup set directory=~/.vim/tmp " 鼠标支持 set mouse=a " 历史记录 set history=1000 " 命令行补全 set wildmenu set wildmode=longest:full,full " 高亮匹配的括号 set showmatch " 高亮当前行 set cursorline " 高亮当前列 set cursorcolumn EOF # 2. 创建vim备份目录 # mkdir -p ~/.vim/backup ~/.vim/tmp # 3. 测试vim配置 # vim ~/.vimrc
3.2 wget下载工具安装与使用
3.2.1 安装wget工具
# dnf install -y wget
Updating Subscription Management repositories.
Last metadata expiration check: 0:30:00 ago on Fri 02 Apr 2026 10:00:00 AM CST.
Dependencies resolved.
================================================================================
Package Architecture Version Repository Size
================================================================================
Installing:
wget x86_64 1.21.3-2.el10 baseos 780 k
Transaction Summary
================================================================================
Install 1 Package
Total download size: 780 k
Installed size: 2.8 M
Downloading Packages:
wget-1.21.3-2.el10.x86_64.rpm 780 kB/s | 780 kB 00:01
——————————————————————————–
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : wget-1.21.3-2.el10.x86_64 1/1
Running scriptlet: wget-1.21.3-2.el10.x86_64 1/1
Verifying : wget-1.21.3-2.el10.x86_64 1/1
Installed:
wget-1.21.3-2.el10.x86_64
Complete!
# 2. 验证wget安装
# wget –version
GNU Wget 1.21.3 built on linux-gnu.
-cares +digest -gpgme +https +ipv6 +iri +large-file -metalink +nls
+ntlm +opie +psl +ssl/gnutls
Wgetrc:
/etc/wgetrc (system)
Locale:
/usr/share/locale
Compile:
gcc -DHAVE_CONFIG_H -DSYSTEM_WGETRC=\”/etc/wgetrc\”
-DLOCALEDIR=\”/usr/share/locale\” -I. -I../lib -I../lib
-DHAVE_LIBGNUTLS -DNDEBUG
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Originally written by Hrvoje Niksic
Please send bug reports and questions to
3.2.2 使用wget下载文件
# wget https://example.com/file.txt
–2026-04-02 10:00:00– https://example.com/file.txt
Resolving example.com (example.com)… 93.184.216.34
Connecting to example.com (example.com)|93.184.216.34|:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 1234 (1.2K) [text/plain]
Saving to: ‘file.txt’
file.txt 100%[==================================================================================>] 1.23K –.-KB/s in 0s
2026-04-02 10:00:00 (12.3 MB/s) – ‘file.txt’ saved [1234/1234]
# 2. 下载文件到指定目录
# wget -P /tmp https://example.com/file.txt
–2026-04-02 10:00:00– https://example.com/file.txt
Resolving example.com (example.com)… 93.184.216.34
Connecting to example.com (example.com)|93.184.216.34|:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 1234 (1.2K) [text/plain]
Saving to: ‘/tmp/file.txt’
/tmp/file.txt 100%[==================================================================================>] 1.23K –.-KB/s in 0s
2026-04-02 10:00:00 (12.3 MB/s) – ‘/tmp/file.txt’ saved [1234/1234]
# 3. 断点续传下载
# wget -c https://example.com/largefile.zip
–2026-04-02 10:00:00– https://example.com/largefile.zip
Resuming at position 12345678
Connecting to example.com (example.com)|93.184.216.34|:443… connected.
HTTP request sent, awaiting response… 206 Partial Content
Length: 987654321 (942M), 975308643 (930M) remaining [application/zip]
Saving to: ‘largefile.zip’
largefile.zip 100%[==================================================================================>] 942.00M 12.3MB/s in 75s
2026-04-02 10:01:15 (12.3 MB/s) – ‘largefile.zip’ saved [987654321/987654321]
# 4. 限速下载
# wget –limit-rate=1M https://example.com/largefile.zip
–2026-04-02 10:00:00– https://example.com/largefile.zip
Resolving example.com (example.com)… 93.184.216.34
Connecting to example.com (example.com)|93.184.216.34|:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 987654321 (942M) [application/zip]
Saving to: ‘largefile.zip’
largefile.zip 0%[=> ] 1.23M 1.00MB/s eta 15m 42s
3.3 curl工具安装与使用
3.3.1 安装curl工具
# dnf install -y curl
Updating Subscription Management repositories.
Last metadata expiration check: 0:30:00 ago on Fri 02 Apr 2026 10:00:00 AM CST.
Dependencies resolved.
================================================================================
Package Architecture Version Repository Size
================================================================================
Installing:
curl x86_64 7.82.0-5.el10 baseos 350 k
Transaction Summary
================================================================================
Install 1 Package
Total download size: 350 k
Installed size: 1.2 M
Downloading Packages:
curl-7.82.0-5.el10.x86_64.rpm 350 kB/s | 350 kB 00:01
——————————————————————————–
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : curl-7.82.0-5.el10.x86_64 1/1
Running scriptlet: curl-7.82.0-5.el10.x86_64 1/1
Verifying : curl-7.82.0-5.el10.x86_64 1/1
Installed:
curl-7.82.0-5.el10.x86_64
Complete!
# 2. 验证curl安装
# curl –version
curl 7.82.0 (x86_64-redhat-linux-gnu) libcurl/7.82.0 OpenSSL/3.0.7 zlib/1.2.11 brotli/1.0.9 libidn2/2.3.3 libpsl/0.21.1 (+libidn2/2.3.3) libssh/0.9.6/openssl/zlib nghttp2/1.46.0
Release-Date: 2023-03-20
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS brotli GSS-API HSTS HTTP2 HTTPS-proxy IPv6 Kerberos Large-file libz NTLM NTLM_WB PSL SPNEGO SSL TLS-SRP UnixSockets
3.3.2 使用curl工具
# curl https://example.com
Example Domain
This domain is for use in illustrative examples in documents. You may use this
domain in literature without prior coordination or asking for permission.
# 2. 下载文件
# curl -O https://example.com/file.txt
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1234 100 1234 0 0 1234 0 0:00:01 –:–:– 1234
# 3. 下载文件并指定文件名
# curl -o myfile.txt https://example.com/file.txt
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1234 100 1234 0 0 1234 0 0:00:01 –:–:– 1234
# 4. 显示HTTP头信息
# curl -I https://example.com
HTTP/2 200
content-type: text/html; charset=UTF-8
content-length: 1256
date: Thu, 02 Apr 2026 02:00:00 GMT
last-modified: Thu, 02 Apr 2026 01:00:00 GMT
etag: “66026400-4e8”
accept-ranges: bytes
server: ECS (dcb/7D8B)
x-cache: HIT from tianjin-7-2-1
age: 123
x-swift-savetime: Thu, 02 Apr 2026 01:00:00 GMT
via: 1.1 varnish, 1.1 varnish
x-served-by: cache-hkg6826-HKG, cache-hkg6828-HKG
x-cache: HIT, HIT
x-cache-hits: 1, 1
x-timer: S1617340800.123456,VS0,VE0
vary: Accept-Encoding
x-cdn: Tencent
# 5. 发送POST请求
# curl -X POST -H “Content-Type: application/json” -d ‘{“name”:”test”,”value”:”123″}’ https://example.com/api
{“status”:”success”,”message”:”Data received”}
Part04-生产案例与实战讲解
4.1 vim高级使用技巧
4.1.1 vim高级编辑技巧
# :%s/old/new/g 替换所有匹配项
# :%s/old/new/gc 替换所有匹配项,每次询问
# :1,10s/old/new/g 替换第1-10行的匹配项
# :s/old/new/g 替换当前行的匹配项
# 2. 删除操作
# dd 删除当前行
# dw 删除当前单词
# d$ 删除到行尾
# d0 删除到行首
# :1,10d 删除第1-10行
# :%d 删除所有内容
# 3. 复制和粘贴
# yy 复制当前行
# yw 复制当前单词
# y$ 复制到行尾
# p 粘贴到光标后
# P 粘贴到光标前
# 4. 撤销和重做
# u 撤销
# Ctrl+r 重做
# 5. 分屏编辑
# :split 水平分屏
# :vsplit 垂直分屏
# Ctrl+w w 切换窗口
# Ctrl+w q 关闭窗口
# 6. 多文件编辑
# :e filename 打开文件
# :bn 下一个文件
# :bp 上一个文件
# :ls 列出所有文件
# 7. 宏录制
# qa 开始录制宏a
# q 结束录制
# @a 执行宏a
# @@ 重复执行宏
4.2 wget高级下载技巧
4.2.1 wget高级下载技巧
# wget -r -np -k https://example.com/
# 2. 指定用户代理
# wget -U “Mozilla/5.0” https://example.com/file.txt
# 3. 使用代理下载
# wget -e “https_proxy=http://proxy.example.com:8080” https://example.com/file.txt
# 4. 下载多个文件
# wget https://example.com/file1.txt https://example.com/file2.txt https://example.com/file3.txt
# 5. 从文件中下载URL
# cat > urls.txt << 'EOF'
https://example.com/file1.txt
https://example.com/file2.txt
https://example.com/file3.txt
EOF
# wget -i urls.txt
# 6. 后台下载
# wget -b https://example.com/largefile.zip
Continuing in background, pid 12345.
Output will be written to 'wget-log'.
# 7. 查看下载进度
# tail -f wget-log
4.3 curl高级使用技巧
4.3.1 curl高级使用技巧
# curl -u username:password https://example.com/api
# 2. 上传文件
# curl -F “file=@/path/to/file.txt” https://example.com/upload
# 3. 设置超时时间
# curl –max-time 30 https://example.com/api
# 4. 使用代理
# curl -x http://proxy.example.com:8080 https://example.com/api
# 5. 保存HTTP头信息
# curl -D headers.txt https://example.com/api
# 6. 只显示HTTP头信息
# curl -I https://example.com/api
# 7. 跟踪重定向
# curl -L https://example.com/redirect
# 8. JSON格式输出
# curl -H “Accept: application/json” https://example.com/api
# 9. 设置请求头
# curl -H “Content-Type: application/json” -H “Authorization: Bearer token” https://example.com/api
# 10. 调试模式
# curl -v https://example.com/api
Part05-风哥经验总结与分享
5.1 工具使用技巧
常用工具使用技巧:
- vim使用:使用vim配置文件提高编辑效率
- wget使用:使用断点续传下载大文件
- curl使用:使用JSON格式处理API响应
- 快捷键:熟练使用快捷键提高操作速度
- 脚本化:将常用操作脚本化
5.2 常见问题排查
常见问题排查:
# 问题1:vim无法启动
# 检查vim配置文件语法
# vim -c “syntax on” ~/.vimrc
# 问题2:wget下载失败
# 检查网络连接
# ping example.com
# 检查DNS解析
# nslookup example.com
# 检查防火墙规则
# firewall-cmd –list-all
# 问题3:curl连接超时
# 增加超时时间
# curl –max-time 60 https://example.com/api
# 使用详细模式调试
# curl -v https://example.com/api
5.3 工具推荐
推荐的常用工具:
- vim:功能强大的文本编辑器
- nano:简单易用的文本编辑器
- wget:命令行下载工具
- curl:多协议数据传输工具
- axel:多线程下载工具
- jq:JSON数据处理工具
本文档介绍了常用工具(vim/wget/curl)的安装与使用,包括vim编辑器、wget下载工具、curl工具的安装、配置和使用技巧。通过合理使用这些工具,可以提高工作效率,简化日常操作。更多学习教程公众号风哥教程itpux_com
本文由风哥教程整理发布,仅用于学习测试使用,转载注明出处:http://www.fgedu.net.cn/10327.html
