


How to manage packages on CentOS RHEL yum dnf
CentOS or RHEL systems are recommended to use yum and dnf management packages. 1. It is recommended to update the cache first during installation, the commands are sudo yum install and sudo dnf install respectively; 2. Update yum update or dnf upgrade, and you can view the list to be updated; 3. Remove yum remove or dnf remove, dnf can automatically clean up useless dependencies; 4. Query to view the installation status through rpm -qa and rpm -q, and yum info/dnf info to obtain detailed information. Mastering these operations can help to efficiently maintain the system.
To manage software packages on CentOS or RHEL systems, mainly using yum
and dnf
tools. They are responsible for installing, updating, deleting and querying packages in the system. Although yum
is an older tool, it is still used in many environments; while dnf
is a new generation of package managers with better performance and is recommended in versions that support it.
Here are some common operations and practical suggestions to help you manage packages for these systems more efficiently.
Installing the package: Basic but critical
Whether it is yum
or dnf
, installing software packages is one of the most commonly used operations. The command structure is also very simple:
-
Using
yum
:sudo yum install package_name
Using
dnf
:sudo dnf install package_name
Tip : It is best to update the local cache before installation to ensure that you get the latest version information:
sudo yum makecache fast # If you use yum sudo dnf makecache # If using dnf
Also, sometimes you may not know the exact package name. You can use the search function at this time:
yum search keyword dnf search keyword
Updates and upgrades: Keep the system safe and stable
It is very important to update system packages regularly, especially security patch updates.
Single package update:
sudo yum update package_name sudo dnf upgrade package_name
Update all (make caution):
sudo yum update sudo dnf upgrade
Note: Upgrading the entire system may introduce compatibility issues, especially in production environments. It is recommended to view the content to be updated first and then decide whether to execute it.
If you only want to see which packages are updated, you can check it like this:
yum list updates dnf list updates
Delete and clean up: free up space and reduce redundancy
When a software is no longer needed, timely uninstallation can save resources and reduce potential security risks.
- Delete the package:
sudo yum remove package_name sudo dnf remove package_name
In addition to uninstalling the package itself, you can also consider cleaning up old caches and useless dependencies:
Clean the cache:
sudo yum clean all sudo dnf clean all
Remove dependencies that are no longer needed (dnf attribute):
sudo dnf autoremove
This feature does not have direct equivalent commands in yum
, but you can manually check if there are orphaned dependencies.
View installed packages and information: The first step to troubleshooting problems
Sometimes you want to know if a package is installed, or you want to see what version it is.
List all installed packages:
rpm -qa
Check if a package is installed:
rpm -q package_name
Show package details:
yum info package_name dnf info package_name
If you encounter problems, such as the service startup fails, you can first confirm whether the corresponding software package is installed correctly and whether the version meets expectations.
Basically that's it. By mastering these basic commands, you can meet the needs of daily maintenance. Although it doesn't seem complicated, paying attention to details in actual use, such as cleaning caches and viewing updated content, can avoid a lot of trouble.
The above is the detailed content of How to manage packages on CentOS RHEL yum dnf. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

If you want to know the network connection on your current computer, you can view it through the command line tool; use netstat-ano on Windows to view all connections and PIDs, use ss-tulnp and lsof-i-P to obtain detailed information, and can also be monitored in real time through graphical interface tools such as resource monitor, nethogs, etc.

When you encounter a problem with slow network connection, traceroute can help you locate the bottleneck. It is a command line tool that displays the path through which the data packets pass from your computer to the target server by sending probe packets and recording the response time of each step. How to use it is tracertexample.com under Windows and tracerouteexample.com under macOS/Linux/Unix. In the output result, each line represents an intermediate node, including the number of hops, three round trip times and the corresponding IP or host name; if all hops are *, it may be firewall blocking or network failure. Check the jump with delay burst to determine the location of the problem; combined with multiple domain name tests, you can distinguish between general

To create an LVM volume group, you must first prepare a physical volume (PV) and then create a VG. 1. Use pvcreate to initialize the hard disk or partition into PV, such as pvcreate/dev/sdb1; 2. Use the vgcreate command to combine one or more PVs into VG, such as vgcreatemy_volume_group/dev/sdb1/dev/sdc1; 3. You can customize the PE size through the -s parameter and use vgdisplay to view information; 4. You can dynamically expand VG in the future and add a new PV using vgextend; 5. Before deleting VG, you must confirm that there is no LV and delete it with vgremove.

Linux monitoring involves a variety of tools, system performance monitoring tools include top/htop real-time viewing of resource usage, vmstat displays virtual memory status, iostat detects disk IO bottlenecks, and sar records historical performance data. The log monitoring tool includes journalctl filtering service logs, dmesg debugging kernel issues, logrotate management log life cycle, and rsyslog/syslog-ng centralized forwarding logs. In terms of network monitoring, SS/NNSTAT checks the connection status, NMap scans open ports, TCPDump captures traffic analysis, and iftop monitors bandwidth usage. Remote monitoring solutions such as Nagios implement deep custom alarms, Zab

The key to managing environment variables is to use .env files to centrally manage, distinguish different environment configurations, inject variables during deployment, and avoid hard-coded sensitive information. Specific practices include: 1. Use .env files to store variables and distinguish them by environment, such as .env.development and .env.production, and add .gitignore; 2. Use NODE_ENV and other identifiers to determine the corresponding configuration of the current environment to automatically load; 3. Inject variables at the system level when deploying servers, Docker or cloud platforms to improve security; 4. All sensitive information must be obtained from environment variables, the naming must be clear, and can be managed in combination with encryption means or special tools.

The method of changing the system hostname varies from operating system to operating system, but the overall process is simple and clear. First, check the current host name, which can be viewed through the hostname or hostnamectl command; second, the hostname can be temporarily changed, Linux uses sudohostnamenew-hostname, and macOS uses sudoscutil-setHostNamenew-hostname; if you need to change it permanently, Linux needs to edit the /etc/hostname file and update the old hostname in /etc/hosts to the new name, and then run sudohostname-F/etc/hostname or restart to apply the changes; macO

To troubleshoot VLAN problems, you should first confirm whether the configuration is correct, and then check the interface status, cross-device communication path, and STP and ACL impacts in turn. 1. Use showvlanbrief to confirm whether the VLAN exists and the port is correct, and whether the Trunk port allows the corresponding VLAN to pass; 2. Use showinterfacesstatus and showrunning-configinterface to check whether the interface status is up and mode configuration; 3. Verify whether the connection between switches is Trunk and allows the same VLAN, and whether the configuration of the subinterface of the layer three device is accurate; 4. Check whether the STP status of the port is blocked, and check whether the ACL or private VLAN limits traffic. Click this logic

To successfully restore Linux system from backup, you must first clarify the backup type and follow the steps. 1. Confirm the backup type, such as complete system image, file-level backup or package list plus configuration files, and select the corresponding recovery method according to the type, such as decompressing data with rsync or tar. 2. Enter the recovery environment through LiveUSB, mount the root partition and backup location, and use the command to copy data. 3. When restoring user data and configuration, check permissions, ownership and hidden files, and reinstall GRUB if necessary. 4. Pay attention to details such as excluding special directories, version compatibility, and non-obvious configuration storage locations. Testing and preparation in advance is the key to ensuring a smooth recovery.
