2024-10-30
The most basic function of Yum is installing packages. The syntax is simple:
sudo yum install <package_name>
Replace <package_name>
with the name of the package you want to install. For example, to install the httpd
(Apache web server) package:
sudo yum install httpd
You’ll be prompted for confirmation. Type ‘y’ and press Enter to proceed. Yum will download and install the package and its dependencies automatically.
To install multiple packages at once, simply list them separated by spaces:
sudo yum install httpd vim git
Keeping your system’s software up-to-date is important for security and stability. Yum simplifies this process:
sudo yum update
This command updates all installed packages to their latest versions. It will download and install updates for any packages with newer versions available in the repositories.
You can also update a specific package:
sudo yum update <package_name>
For instance, to update only the httpd
package:
sudo yum update httpd
Removing unwanted packages is just as easy:
sudo yum remove <package_name>
This command removes the specified package. For example, to remove the vim
package:
sudo yum remove vim
To remove a package and its dependencies that are no longer needed by other installed packages:
sudo yum remove <package_name> -y
The -y
flag automatically answers ‘yes’ to all prompts, useful for scripting. Use caution with this flag.
To see a list of all installed packages:
yum list installed
This command displays a detailed list, including package names, versions, and architectures. You can also search for specific packages:
yum list installed | grep <search_term>
For instance, to search for packages related to “httpd”:
yum list installed | grep httpd
To find packages that match a specific keyword:
yum search <search_term>
For example, to search for packages related to “database”:
yum search database
This will return a list of available packages matching your search term.
Yum uses repositories to locate software packages. You can list your enabled repositories with:
yum repolist
To enable or disable repositories (requires root privileges and knowledge of your repository configuration): This is typically managed through configuration files rather than direct yum commands, but the yum-config-manager
tool often interacts with them. Refer to your distribution’s documentation for details on managing repositories.
To view detailed information about a specific package:
yum info <package_name>
For example, to view information about the httpd
package:
yum info httpd
This provides information like version, size, description, and dependencies.
Over time, Yum can accumulate old packages and cache files. You can clean these up with:
sudo yum clean all
This command removes downloaded packages, cache files, and metadata. Be cautious when using this command, particularly yum clean all
. You can selectively remove only the cache with sudo yum clean cache
.
This guide provides a solid foundation for using Yum. Further exploration of its capabilities will improve your Linux system administration skills. Remember to always use sudo
before Yum commands that modify the system.