Saturday, November 24, 2012

Important yum commands and information you should know

As a linux beginner Yum has irritated me a lot. It hardly works without issues. However some hard work can save you a lot of time in the future.

There are three important things about yum
1. Yum repositories (in the repo directory /etc/yum.repos.d/) e.g fedora.repo
(you can add fedora DVD as a repository when you don't have internet connection to exploit online repositories)
2. Yum proxy settings (refer here)
3. Yum options and capabilities - install packages and rmp file, update, remove, groupinstall, listing the packages, package dependencies etc

Yum finds its packages and their information in the repositories listed in each file in the /etc/yum.repos.d/ directory. There are some very good repositories but the most vital are the two redhat repositories - one is for free software (that comes set default in your system) that hardly meets your appetite, and the other one is a non-free repository. You should add this non-free repository.

Adding a new repository. You have to add a new .repo file in the repositories directory. You can look at the format of this files which is quite simple. To add the non-free repository just copy these files to the /etc/yum.repos.d/ directory:
repos.tar (download this tar file and untar it - add all the files to the repo directory)
Note: When sometimes Yum is not able to download some repository metadata etc.. then try changing the link type from https to http in the repo file of that repository. The links are given in the baseurl and mirrorlist parameter in the repo file.

Yum Commands (most are self-explanatory)
# yum install <package-name> //installs the package but asks you for confirmation - package name could also be a local rpm file.
or
# yum -y install <package-name> //installs the package straightaway
-y will not ask you anything and straight away install the package.
# yum update <package-name>
# yum remove <package-name>
# yum reinstall <package-name>

#yum clean all //cleans up all the yum files left over from previous installations
# yum list available // lists the available package names and descriptions
# yum list installed //lists the installed packages
# yum search <partial package name>
# yum search all <partial package name> // better search results

Group install
# yum grouplist
# yum groupinstall <group-name>
# yum groupremove <group-name>
# yum groupupdate <group-name>
# yum groupinfo <group-name>

Others
# yum deplist <package-name>
# yum info <package-name>
# yum install yumex //gui for yum (idon't use it)
# yum provides <filename> //all packages providing the file (try absolute path)
# rpm -qf <filename> //prints the package to which the files like /bin/bash belong)

No comments:

Post a Comment