Sometimes the CentOS7 system that has just been installed finds that it cannot be updated using the yum command. An error will occur during the update. We can solve it through the following steps.
How to solve the problem that the yum command cannot be used in CentOS
1. Set the network card to start automatically at boot
To solve this problem, you must first confirm whether the network card has been started. When CentOS7 is first installed, the network card may be turned off and you need to turn it on yourself.
1. Enter the command "cd /etc/sysconfig/network-scripts" and use the command "ls -a" to view all files in the directory.
2. Modify the network card configuration file of ifcfg-ens33. Enter the command "vi ifcfg-ens33" to enter the vi editor, and press the "i" or "insert" key to enter editing mode.
3. Change the value of "ONBOOT" to "yes", then press esc to exit the edit mode, enter ":wq" to save and exit
4. Restart the network card and enter the command "service network restart".
Recommended learning: Linux video tutorial
2. Set up domestic dns server
If the network card has been turned on, the problem still exists If you have a problem, you can try configuring domestic DNS.
1. Enter the command "vi /etc/resolv.conf"
2. Add "nameserver 114.114.114.114"
3. Restart the network card and enter the command "service network restart".
3. Modify the address in CentOS-Base.repo
If the above method still fails, you can try modifying the address in CentOS-Base.repo
1. Enter "/etc/yum.repos.d".
2. Edit "vi CentOS-Base.repo".
3. Comment out all "mirrorlist" and uncomment all "baseurl".
4. Restart the system.
This article comes from the PHP Chinese website, CentOS usage tutorial column, please pay attention to this column for more related tutorials!
The above is the detailed content of How to solve the problem that the yum command cannot be used in CentOS. For more information, please follow other related articles on the PHP Chinese website!