Preface: To update the code, the GUI on the server failed, $ patch_delivery_gui, error: patch_delivery_gui:
command not found, the same problem happened last time when editing TA.
Wrote a script: This script will first check whether the ifconfig, firewall-cmd and vim commands are available. If not, try to install the corresponding software package. Then, it displays the network interface information. If an error occurs during installation, the appropriate error message will be displayed and the script will exit.
#!/bin/bash
# Check if ifconfig command is available
if ! command -v ifconfig &> /dev/null; then
echo "ifconfig command not found. Trying to install net-tools package..."
# Install net-tools package
if sudo yum install -y net-tools; then
echo "net-tools package installed successfully."
else
echo "Failed to install net-tools package. Please check your internet connection and try again."
exit 1
fi
fi
# Check if firewall command is available
if ! command -v firewall-cmd &> /dev/null; then
echo "firewall-cmd command not found. Trying to install firewalld package..."
# Install firewalld package
if sudo yum install -y firewalld; then
echo "firewalld package installed successfully."
else
echo "Failed to install firewalld package. Please check your internet connection and try again."
exit 1
fi
fi
# Check if vim command is available
if ! command -v vim &> /dev/null; then
echo "vim command not found. Trying to install vim-enhanced package..."
# Install vim-enhanced package
if sudo yum install -y vim-enhanced; then
echo "vim-enhanced package installed successfully."
else
echo "Failed to install vim-enhanced package. Please check your internet connection and try again."
exit 1
fi
fi
# Display network interface information
echo "Network Interface Information:"
ifconfig
parse
ifconfig
Two solutions:
Install toolkit directly
yum install net-tools
If you want to solve the problem in a more concise way, you can directly install ifconfig using the following command:
yum install -y net-tools
This command will directly install the net-tools package, which contains the ifconfig command. Use
-y
the option to answer all prompts automatically and avoid manual confirmation.
In addition, you can also search for the installation package location of the ifconfig command by executing the following command:
yum search ifconfig
This command will list package information related to ifconfig, including package name and description. You can choose the appropriate package to install based on the search results.
2. Check ifconfig matches the net-tools.x86_64 package and install the net-tools.x86_64 package
3. After the installation is complete, you can use the following command to view the network card information:
ifconfig
After executing this command, detailed information about all available network interfaces on the system will be displayed, including IP addresses, network masks, broadcast addresses, etc. You can view and analyze this information in a terminal window.
firewall
If you want to install the firewalld firewall service, you can use the following command to install it:
yum install -y firewalld
This command will automatically download and install the firewalld package. Use -y
the option to answer all prompts automatically and avoid manual confirmation. Once the installation is complete, you can start configuring and managing firewall rules.
vim
If you execute the command rpm -qa|grep vim
and three results are returned, it means that you have installed the following three Vim-related software packages:
1. vim-minimal-7.0.109-6.el5
2. vim-common-7.0.109-7.2.el5
3. vim-enhanced-7.0.109-7.2.el5
This means that Vim is installed correctly on your system. If one of these records is missing, one or more Vim packages have not been installed.
If you are missing a certain record (such as vim-enhanced), you can install the package separately using the following command:
yum -y install vim-enhanced
If you want to reinstall all Vim related packages, you can use the following command:
yum -y install vim*
This will install all packages starting with "vim", ensuring you have a complete Vim installation.