Mastering Linux! Easily Configure yum and vim with a Single Command

Linux | Red Hat Certified | IT Technology | Operations Engineer

👇 Join our technical exchange QQ group with the note 【Public Account】 for faster approval

Mastering Linux! Easily Configure yum and vim with a Single Command

1. The Powerful Package Manager yum in Linux

1. Background and Software Ecosystem of yum

(1) Evolution of Software Management in Linux

In early Linux systems, software installation required compiling from source: users had to manually download the source package -> configure the compilation environment -> execute make to compile -> resolve dependencies -> and finally install. The entire process was time-consuming and labor-intensive, with dependency management being particularly tricky.

The emergence of yum (Yellowdog Updater Modified) completely changed this situation. As the package management tool for RPM-based distributions (RedHat/CentOS/Fedora), yum built a complete software ecosystem:

  • Software Repository Architecture: Official/third-party maintained software repositories

  • Metadata Index: Daily updated repodata database

  • Dependency Resolution: Automatically handles software package dependency trees

  • Transaction Mechanism: Ensures atomic operations for installations/updates

(2) Components of the yum Software Ecosystem

  • Base Repository: Core system components and basic software

  • Updates Repository: Security patches and version updates

  • Extras Repository: Additional toolsets

  • EPEL Repository: Extra Packages for Enterprise Linux (needs to be added manually)

  • Third-party Repositories: Such as Remi, RPMforge, etc.

2. Comprehensive Guide to Core yum Operations

(1) Three Steps to Install Software

# Search for a package (using nginx as an example)
yum search nginx
# View detailed information
yum info nginx
# Install software (requires root privileges)
sudo yum install nginx

Typical installation process output:

Checking dependencies:
→ libtool-ltdl.x86_64 0:2.4.2-22.el7_3
→ fontconfig.x86_64 0:2.13.0-4.3.el7
15 new packages will be installed
Total download size: 5.6 MB
Is this okay? [y/N] y

(2) Software Updates and Uninstallation

# Check for updatable software
yum check-update
# Update specified software
sudo yum update httpd
# Uninstall a package
sudo yum remove tomcat
# Clear cache (important maintenance operation)
sudo yum clean all

(3) Advanced Maintenance Tips

• View software dependency tree: yum deplist python3

• Query file ownership: yum provides /usr/bin/pip

• View history: yum history list

3. In-depth Analysis of yum Repositories

(1) Repository Configuration File Analysis

The repository configuration files for CentOS systems are stored in the /etc/yum.repos.d/ directory, with a typical configuration file structure:

name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

Key parameter explanations:

• baseurl: Specifies the repository URL

• mirrorlist: Automatically selects from a list of mirrors

• enabled: Whether to enable this repository (1/0)

• gpgcheck: Whether to perform GPG signature verification

(2) Configuration of Domestic Mirror Sources

Recommended steps for configuring Alibaba Cloud mirrors:

# Backup original repository configuration
sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
# Download Alibaba Cloud configuration
sudo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# Generate cache
sudo yum makecache

(3) Adding the EPEL Repository

sudo yum install epel-release
sudo yum-config-manager --enable epel

4. Case Studies

Case 1: rzsz File Transfer Tool

# Install rz/sz tools
sudo yum install -y lrzsz
# Upload files to the server
rz -bye
# Download files from the server
# Enter the filename, a prompt window will pop up
# Prompt to use sz filename

Case 2: Setting Up a Development Environment

# Install development toolchain
sudo yum groupinstall "Development Tools"
# Install additional development libraries
sudo yum install -y openssl-devel zlib-devel readline-devel

2. The God of Editors: vim

1. Analysis of vim’s Mode System

(1) Diagram of Three Mode Transitions

Mastering Linux! Easily Configure yum and vim with a Single Command

(2) Comparison of Mode Characteristics

Mastering Linux! Easily Configure yum and vim with a Single Command

2. Core Operations in Normal Mode

(1) The Art of Cursor Movement

h       Move left       ←
j       Move down       ↓
k       Move up         ↑
l       Move right      →
w       Next word start
e       Current word end
b       Previous word start
0       Beginning of line
^       First non-blank character
$       End of line
gg      First line of file
G       Last line of file
50G     Jump to line 50

(2) Mastering Text Editing

x       Delete current character
dw      Delete word
d$      Delete to end of line
dd      Delete entire line
5dd     Delete 5 lines
yy      Copy current line
yw      Copy word
p       Paste after cursor
P       Paste before cursor
u       Undo operation
Ctrl+r  Redo undo

(3) Efficient Search Techniques

/pattern     Search forward
?pattern     Search backward
n           Next match
N           Previous match
*           Search current word
#           Reverse search current word

3. Advanced Techniques in Insert Mode

(1) Multiple Entry Methods

i       Insert before cursor
a       Insert after cursor
o       Insert new line below
O       Insert new line above
s       Delete current character and insert
S       Delete entire line and insert

(2) Quick Operations in Insert Mode

Ctrl+h  Delete previous character
Ctrl+w  Delete previous word
Ctrl+u  Delete to beginning of line
Ctrl+t  Increase indentation
Ctrl+d  Decrease indentation

4. Advanced Applications in Command Mode

(1) File Operation Commands

:w              Save file
:wq             Save and exit
:q!             Force exit
:e filename     Open new file
:saveas newfile Save as new file

(2) Batch Replacement Magic

:%s/old/new/g      Global replacement
:10,20s/old/new/g  Replace lines 10-20
:%s/^/#/g          Add comment at the beginning of lines

(3) Window Splitting Operations

:sp        Horizontal split
:vsp       Vertical split
Ctrl+ww    Switch windows
:q         Close current window

5. Practical Optimization of vim Configuration

(1) Basic Configuration Template

" ~/.vimrc" Display settings
set number          " Show line numbers
set cursorline      " Highlight current line
set scrolloff=5     " Keep 5 lines in view
" Indentation settings
set tabstop=4       " Tab display length
set shiftwidth=4    " Auto indentation length
set expandtab       " Convert Tab to spaces
" Search settings
set incsearch       " Real-time search
set hlsearch        " Highlight matches
" Syntax highlighting
syntax enable
filetype plugin indent on

(2) Recommended Practical Plugins

  • Vundle: Plugin management tool

  • NERDTree: File browser

  • CtrlP: Fast file search

  • Airline: Status bar beautification

  • YouCompleteMe: Code completion

(3) One-Click vim Configuration Command

If you are a C/C++ developer, executing this command can help you configure vim for C/C++ development environment in one click.

Includes:

  • Code completion

  • Syntax highlighting

  • Automatic bracket matching

  • Header file suggestions, etc.

The command is as follows:

curl -sLf https://gitee.com/HGtz2222/VimForCpp/raw/master/install.sh -o ./install.sh && bash ./install.sh

Simply copy and paste the above command to use.

Conclusion

In the Linux system, yum and vim are the dual champions of efficiency. As the intelligent package manager for RPM-based distributions, yum completely solves the software dependency hell problem. By configuring Alibaba Cloud mirrors and the EPEL repository, developers can quickly set up a LAMP environment, install practical tools like rzsz, and even deploy development environments in bulk using yum groupinstall. Vim, with its multi-mode design, showcases the ultimate form of an editor: precise word deletion with diw in normal mode, global replacement magic with :%s, combined with window splitting operations and the YouCompleteMe intelligent completion plugin, makes coding flow seamlessly. The one-click configuration script for the C++ development environment provided at the end turns vim into a powerful IDE tool. Mastering the repository configuration techniques of yum and the .vimrc optimization of vim will lead to a qualitative leap in your Linux work efficiency.

For course inquiries, add: HCIE666CCIE

↓ Or scan the QR code below ↓

Mastering Linux! Easily Configure yum and vim with a Single Command

What technical points and content would you like to see?

You can leave a message below to let us know!

Leave a Comment