Note: yum
is the default package manager for Red Hat-based Linux distributions (e.g., CentOS, Fedora, RHEL). Ubuntu uses apt
(Advanced Package Tool) as its primary package manager, and installing yum
on Ubuntu is not recommended as it may cause system instability due to conflicts with apt
. For Ubuntu, always use apt
commands (e.g., sudo apt install package_name
, sudo apt update
). Below is a summary of yum
commands for reference only.
Basic Package Management
- Install a Package: Installs the specified package and resolves dependencies automatically.
sudo yum install package_name
- Update Packages: Updates all installed packages to their latest versions. Omit
package_name
to update everything.
sudo yum update
or sudo yum update package_name
- Remove a Package: Deletes the specified package and its dependencies.
sudo yum remove package_name
- Reinstall a Package: Reinstalls the specified package (useful for fixing corrupted installations).
sudo yum reinstall package_name
Package Search and Information
- Search for Packages: Finds packages matching a keyword in their name or description.
yum search keyword
- List Available Packages: Displays all packages available in enabled repositories (both installed and uninstalled).
yum list
- List Installed Packages: Shows only packages that are currently installed.
yum list installed
- List Updatable Packages: Lists packages with available updates.
yum list updates
- Show Package Details: Displays detailed information about a package (version, dependencies, description).
yum info package_name
- Find Which Package Provides a File: Identifies the package that owns a specific file on the system.
yum provides file_path
(e.g., yum provides /usr/bin/git
)
Cache Management
- Clean All Cache: Removes downloaded package files and metadata to free disk space.
sudo yum clean all
- Clean Package Cache: Deletes only the cached package files (not metadata).
sudo yum clean packages
- Clean Old Metadata: Clears outdated repository metadata to ensure accurate package information.
sudo yum clean oldheaders
- Make Cache: Downloads and stores repository metadata locally to speed up future operations.
sudo yum makecache
Repository Management
- List Enabled Repositories: Shows all repositories currently enabled on the system.
yum repolist
- View Repository Configuration: Displays the configuration file for a specific repository (e.g.,
base
, epel
).
yum repoinfo repository_id
Advanced Commands
- Check for System Updates: Scans the system for available updates without installing them.
yum check-update
- View YUM History: Lists all past YUM operations (install, update, remove) with transaction IDs.
yum history
- Undo a Transaction: Reverts a specific YUM operation (e.g., undoes an accidental package removal). Use
yum history list
to find the transaction ID.
sudo yum history undo transaction_id
- Check Package Dependencies: Displays the dependency tree for a package (shows what it depends on and what depends on it).
yum deplist package_name
- Group Install Software: Installs a group of related packages (e.g., “Development Tools”) from the repository.
sudo yum groupinstall 'group_name'
(e.g., sudo yum groupinstall 'Development Tools'
)
- Group Remove Software: Removes a group of packages.
sudo yum groupremove 'group_name'
- Version Lock: Prevents a package from being automatically updated by locking its version.
sudo yum versionlock add package_name
- Clear Version Locks: Removes all version locks on packages.
sudo yum versionlock clear
Options for Command Customization
-y
: Automatically answers “yes” to all prompts (avoids manual confirmation for each step).
Example: sudo yum -y install package_name
-q
: Runs YUM in quiet mode (suppresses output, useful for scripting).
Example: yum -q list installed
-h
: Displays help information for the command.
Example: yum -h