Sunday, 6 November 2016

Actionable YUM Commands

Yum is the repository management tool which fetches the appropriate package for your particular version of linux.

Actionable Yum commands:- 
  1. Yum list                      : list all the installed and available packages
  2. yum list installed        :  list all the installed packages
  3. yum list available       : list all the available packages in enabled repos, ready to be installed.
  4. yum repolist/repoinfo : list all the enabled repos
  5. yum info <package_name>  : list information about mentioned package
  6. yumd info <package_name>  : Querying yum database for more detailed information.
  7. yum install mysql*         : install all the mysql related packages
  8. yum provides <package_name> : will list the path where it is installed and other imp details.
  9. yum localinstall <package_name> : to install the package that was already downloaded
  10. yum remove <package_name>  : to remove the package
         
  11. Package groupA package group is a collection of packages that serve a common purpose, for instance System Tools.
    1. yum group list <filter>               : View all the available and Installed group.
    2. yum group info <filter>  : to list all the mandatory and optional package from the group.
    3. yum group install <group_name> : installs the group
    4. yum group remove <group_name> : removes group
  12. Yum Transaction History:  The yum history command enables users to review information about a timeline of yum transactions, the dates and times they occurred, the number of packages affected, whether these transactions succeeded or were aborted, and if the RPM database was changed between transactions. Additionally, this command can be used to undo or redo certain transactions. All history data is stored in the history DB in the /var/lib/yum/history/ directory.
    1. yum history list  : list  last 20 transactions
    2. yum history list all  : list all transactions
    3. yum history list <filter>
    4. yum history info <id>    : Examine any transaction in more detail
    5. Repeating or Undoing transaction using history: Apart from reviewing the transaction history, the yum history command provides means to revert or repeat a selected transaction. 
      1. yum history undo <id>     : it will revert the transaction mentioned by ID
      2. yum history redo <id>     : it will repeat the transaction mentioned by ID
  13. Yum Configuration : 
    1. The configuration information for yum and related utilities is located at /etc/yum.conf
    2. Yum cache and database file are kept by default at : /var/cache/yum/$basearch/$releasever/
    3. Default yum log file : /var/log/yum.log     
  14. Repo Configuration :   All .repo files contain repository information (similar to the [repository] sections of /etc/yum.conf). Yum collects all repository information from .repo files and the [repository] section of the /etc/yum.conf file to create a master list of repositories to use for transactions. If reposdir is not set, yum uses the default directory /etc/yum.repos.d/.  Basic repo configuration in repo.d are as follows, 
    1. name=repository_name
      Here, repository_name is a human-readable string describing the repository.
    2. baseurl=repository_url  : 
      Replace repository_url with a URL to the directory where the repodata directory of a repository is located:
    3. enabled=value : This is a simple way to tell yum to use or ignore a particular repository
      Note: Turning repositories on and off can also be performed by passing either the --enablerepo=repo_name or --disablerepo=repo_name option to yum
  15. Yum variables: You can use and reference the following built-in variables in yum commands and in all yum configuration files (that is, /etc/yum.conf and all .repo files in the /etc/yum.repos.d/ directory):
    1. Default/Build-in Variables: 
      1. $releasever
      2. $arch
      3. $basearch
    2. Custom Variables: To define a custom variable or to override the value of an existing one, create a file with the same name as the variable (without the $ sign) in the /etc/yum/vars/ directory, and add the desired value on its first line.
  16. Adding a yum repository: To define a new repository, you can either add a [repository] section to the /etc/yum.conf file, or to a .repo file in the /etc/yum.repos.d/ directory. All files with the .repo file extension in this directory are read by yum, and it is recommended to define your repositories here instead of in /etc/yum.conf.
  17. To view/modidy global configuration: $yum-config-manager
    1. yum-config-manager —add-repo repository_url : Yum repositories commonly provide their own .repo file. To add such a repository to your system and enable it.
    2. yum-config-manager —enable repository : To enable any repository.
    3. yum-config-manager --enable \* : Enable all the repos
  18. Creating New/Local yum repos:
    1. Install createrepo package yum install createrepo
    2. Copy all packages that you want to have in your repository into one directory, such as /mnt/local_repo/
    3. Change to this directory and run the following command:
      createrepo -database /mnt/local_repo This creates the necessary metadata for your yum repository, as well as the sqlite database for speeding up yum operations.


NOTES-
  • use backslash sign before any regex expression [  /* OR /?]
  • Most, if not all, commands will need root privileges to execute.
  • This blog contains the list of the yum commands that you will gonna use on day to day basis as a Linux developer, however, you will need more depth if you are Linux Admin.


    

No comments:

Post a Comment