dnf (Dandified YUM) and rpm to complete these tasks, helping you efficiently manage the entire lifecycle of software packages.dnf by default, while TencentOS Server 3 supports both yum and dnf.[BaseOS] and [AppStream], provides core system components and application packages, and is configured by default.[BaseOS] and [AppStream] are enabled. To use other sources such as debuginfo or source, set enabled to 1 in the corresponding configuration section.cat /etc/yum.repos.d/TencentOS.repo
[BaseOS]name=BaseOS $releasever - $basearchbaseurl=https://mirrors.tencent.com/tlinux/$releasever/BaseOS/$basearch/os/Packages/gpgcheck=1enabled=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-TencentOS[AppStream]name=AppStream $releasever - $basearchbaseurl=https://mirrors.tencent.com/tlinux/$releasever/AppStream/$basearch/os/Packages/gpgcheck=1enabled=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-TencentOS[BaseOS-debuginfo]name=BaseOS-debuginfo $releasever - $basearchbaseurl=https://mirrors.tencent.com/tlinux/$releasever/BaseOS/$basearch/debug/gpgcheck=1enabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-TencentOS[AppStream-debuginfo]name=AppStream-debuginfo $releasever - $basearchbaseurl=https://mirrors.tencent.com/tlinux/$releasever/AppStream/$basearch/debug/gpgcheck=1enabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-TencentOS[BaseOS-source]name=BaseOS-source $releaseverbaseurl=https://mirrors.tencent.com/tlinux/$releasever/BaseOS/source/gpgcheck=1enabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-TencentOS[AppStream-source]name=AppStream-source $releaseverbaseurl=https://mirrors.tencent.com/tlinux/$releasever/AppStream/source/gpgcheck=1enabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-TencentOS
dnf install -y epol-release
mkdir -p /mnt/myiso # Create a directory for the iso. You can customize the directory. Ensure that there is sufficient storage space.mkdir -p /mnt/my_yum # Create a directory for mounting the iso. You can customize the directory. Ensure that there is sufficient storage space.
cd /mnt/myisowget https://mirrors.tencent.com/tlinux/4.0/isos/x86_64/TencentOS-Server-4.0-everything-x86_64.iso
mount -o loop /mnt/myiso/TencentOS-Server-4.0-everything-x86_64.iso /mnt/my_yum/
vim /etc/fstab, and add the following content.echo "/mnt/myiso/TencentOS-Server-4.0-everything-x86_64.iso /mnt/my_yum iso9660 loop,ro 0 0" >> /etc/fstab
/mnt/my_yum directory:cd /mnt/my_yum/tree -L 2 .
.├── AppStream│ ├── Packages│ └── repodata├── BaseOS│ ├── Packages│ └── repodata├── boot│ └── grub2├── EFI│ └── BOOT└── images├── efiboot.img├── eltorito.img├── install.img└── pxeboot12 directories, 3 files
# View the repo file: cat /etc/yum.repos.d/local.repo[AppStream]name=AppStreambaseurl=file:///mnt/my_yum/AppStreampriority=1enabled=1[BaseOS]name=BaseOSbaseurl=file:///mnt/my_yum/BaseOSpriority=1enabled=1
mkdir -p /mnt/local_repo/x86_64/Packages # Customize the directory location. Ensure that there is sufficient storage space.
dnf install -y createrepo
cp *.rpm /mnt/local_repo/x86_64/Packages
createrepo /mnt/local_repo/x86_64
/mnt/local_repo/x86_64 directory.[local]name=localbaseurl=file:///mnt/local_repo/x86_64priority=1enabled=1
cat /etc/dnf/dnf.conf[main]gpgcheck=1installonly_limit=3clean_requirements_on_remove=Truebest=Trueskip_if_unavailable=Falsezchunk=False
dnf configuration yourself. For a complete description of parameters, run man dnf.conf.Parameter | Value Type | Default Value | Description |
name | string | None | Name of the repo source |
baseurl | list | None | List of URLs for the repo source |
priority | integer | None | Priority of the repo source, ranging from 0 - 99, with a smaller value indicating a higher priority. |
gpgcheck | boolean | 1 | Whether to perform GPG verification |
gpgkey | string | None | URL or local path of the GPG public key, used with gpgcheck |
installonly_limit | integer | 3 | Number of software packages that can be installed in parallel |
clean_requirements_on_remove | boolean | True | Whether to remove dependencies that are not used by other software packages when removing a software package |
best | boolean | True | Whether to install the highest version when installing a software package, and fail if it cannot be installed. |
skip_if_unavailable | boolean | False | When set to True, unavailable sources are skipped. When set to False (default), an error is reported upon encountering an unavailable source. |
zchunk | boolean | False | Whether to compress repo metadata in zchunk format. |
# List all enabled software sourcesdnf repolist# List all software sources (including disabled ones)dnf repolist all# View detailed information about a software sourcednf repoinfo <repo-name>
dnf repolist all:repo id repo name statusAppStream TencentOS-4 - AppStream enabledBaseOS TencentOS-4 - BaseOS enabledextras TencentOS-4 - Extras enabled
# Temporarily disable a source (effective only for this command)dnf install <package-name> --disablerepo=<repo-id># Permanently enable a sourcednf config-manager --enable <repo-id># Permanently disable a sourcednf config-manager --disable <repo-id>
# Add a software source by URLdnf config-manager --add-repo <repo-url># Manually create a .repo filevi /etc/yum.repos.d/<name>.repo
[myrepo]name=My Custom Repositorybaseurl=https://example.com/repo/enabled=1gpgcheck=1gpgkey=https://example.com/RPM-GPG-KEY
# List all installed software packages in the current environmentdnf list installed# List all installed software packages (via rpm)rpm -qa
rpm -qa lists all packages installed on the system and is typically used with the grep command.# Search for software packages that contain a keyworddnf search <package-name># Search in package names and summaries (more precise)dnf search --all <package-name>
# View detailed information about a software packagednf info <package-name># Query software package information (via rpm)rpm -qi <package-name># View the file list of a software packagerpm -ql <package-name># Find which software package a file belongs todnf provides /etc/<package-name>/<package-name>.confdnf provides "*.so.1"# Find which software package a file belongs to (via rpm)rpm -qf /etc/<package-name>/<package-name>.conf
# List all installable software packages (show only those not installed)dnf list available# List all available versions of a specific software packagednf list <package-name> --showduplicates
# Find which packages depend on a specific software packagednf repoquery --whatrequires <package-name># Query dependencies of a specific software packagednf repoquery --requires <package-name>
# Install software packages from a repositorydnf install -y <package-name># Install multiple software packagesdnf install -y <package-name1> <package-name2> <package-name3># Install a specific versiondnf install <package-name-1.2.1># Install a user-compiled rpm package filednf localinstall -y <package-name>.rpmdnf install /path/to/<package-name>.rpm# Install a software package groupdnf groupinstall "package-group-name"# View available software package groupsdnf grouplist
# Check available updates (without installing them)dnf check-update# Update all software packages (automatically confirm)dnf update -y# Update a specific software packagednf update <package-name># Upgrade installed rpm packagesdnf upgrade <package-name># Update a software package groupdnf groupupdate "package-group-name"
dnf update --downloadonly to pre-download packages or use dnf history to keep a record for rollback.# Downgrade installed rpm packagesdnf downgrade <package-name>
# Uninstall a software package (keep dependencies)dnf remove <package-name># Uninstall a software package and its dependencies that are not used by other packagesdnf autoremove <package-name># Remove dependency packages that are no longer neededdnf autoremove
dnf repoquery --whatrequires <package name> to check the impact scope.# Download rpm packages from the source (without installing)dnf download <package-name>
# View dnf operation historydnf history# View details of an operationdnf history info <id># Roll back an operationdnf history undo <id>
rpm command can directly operate on RPM packages without connecting to a software source:# Check whether a software package is installedrpm -q <package-name># Query all installed software packagesrpm -qa# Query the installation files of a software packagerpm -ql <package-name># Find which software package a file belongs torpm -qf /etc/<package-name>/<package-name>.conf# View detailed information about a software packagerpm -qi <package-name># Query the version of a software packagerpm -q --qf "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\\n" <package-name># Install RPM packages (without resolving dependencies, suitable for offline scenarios)rpm -ivh <package-name>.rpm# Force install (ignore dependency checks)rpm -ivh --force --nodeps <package-name>.rpm# Uninstallrpm -e <package-name>
# View available modulesdnf module list# View information about a specific modulednf module info python3# Enable a specific version streamdnf module enable python3:3.8# Install modulesdnf module install python3:3.8/default# Reset module (restore default stream)dnf module reset python3
# Clean up software package cachednf clean packages# Clear all cachesdnf clean all# Regenerate metadata cachednf makecache
# Verify that the software package is installeddnf list installed | grep <package-name># Verify software package integrityrpm -V <package-name># View dnf logscat /var/log/dnf.log | tail -50
You have enabled checking of packages via GPG keys. This is a good thing.However, you do not have any GPG public keys installed. You need to downloadthe keys for packages you wish to install and install them.You can do that by running the command:rpm --import public.gpg.key
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-TencentOS-*
error: cannot open Packages database in /var/lib/rpm
rm -f /var/lib/rpm/__db.*
rpm --rebuilddbdnf clean all
No match for argument error is reported when a software package is installed, which is usually caused by an expired cache or an incorrect package name.# Clear the cache and retrydnf clean alldnf makecachednf install <package-name># Confirm that the software source is enableddnf repolist# Try searching for the correct package namednf search <keyword>
# Method 1: Import the GPG keyrpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-TencentOS-*# Method 2: Temporarily skip the GPG check (not recommended for production environments)dnf install <package-name> --nogpgcheck
dnf update is run.# Confirm that a mirror source is useddnf repolist -v | grep Repo-baseurl# Change the software source (edit /etc/yum.repos.d/*.repo to modify baseurl)
dnf and rpm are inconsistent.# Rebuild the RPM databaserpm --rebuilddbdnf clean all
フィードバック