This Blog is to share our knowledge and expertise on Linux System Administration and VMware Administration

Showing posts with label Linux Troubleshooting. Show all posts
Showing posts with label Linux Troubleshooting. Show all posts

Wednesday, August 14, 2019

Yum commands with examples for RPM package Management

Wednesday, August 14, 2019 0
As part of system admin activities, we need to install, remove and update the system packages. Most of the Linux distros have package manager utility.

Here i have listed some linux distros and its package manager.

Redhat/Centos/Oracle linux - yum (Yellow-Dog Updater Modified)
Fedora         - yum / DNF (Dandified YUM)
opensuse         - zypper
ubuntu/debian         - apt / dpkg /synaptic
Arch Linux         - pacman
Gentoo Linux         - Portage

Yum (Yellow-Dog Updater Modified) is default package manager for some of the Linux distros.

Earlier, rpm command is used for managing packages. Yum command knows how to resolve dependencies by sourcing the additional package. But rpm command can alert us the dependencies, it is unable to source the additional packages.

This documents is having some important yum command with example.

1. To check the version of the yum installed on the server.

[root@nsk ~]# yum --version
3.4.3

2. If we want to know the dependency package before installing the package.

Yum deplist will list all the dependencies and what packages provide those dependencies for the given packages. 

[root@nsk ~]# yum deplist tigervnc

 package: tigervnc.x86_64 1.8.0-5.el7
  dependency: /bin/sh
   provider: bash.x86_64 4.2.46-30.el7
  dependency: coreutils
   provider: coreutils.x86_64 8.22-21.el7
  ....
  ..
  .
  dependency: tigervnc-license
   provider: tigervnc-license.noarch 1.8.0-5.el7


3. To install the package. Here -y option will install the vnc package without any prompt. Also all dependency packages also installed.

[root@nsk ~]# yum install vnc -y 

Installed:
  tigervnc.x86_64 0:1.8.0-5.el7

Dependency Installed:
  fltk.x86_64 0:1.3.4-1.el7                mesa-libGLU.x86_64 0:9.0.0-4.el7                tigervnc-icons.noarch 0:1.8.0-5.el7

Complete!
[root@nsk ~]#


4. To uninstall the package. Here dependency packages also removed.

[root@nsk ~]# yum remove vnc

 Erasing    : tigervnc-1.8.0-5.el7.x86_64   1/1
 Verifying  : tigervnc-1.8.0-5.el7.x86_64   1/1

Removed:
  tigervnc.x86_64 0:1.8.0-5.el7

Complete!
[root@nsk ~]#


5. To know the linux machine had any updates that needed to be applied without running it interactively.

[root@nsk ~]# yum check-update

dconf.x86_64                       0.26.0-3.el7_5.1        updates
firefox.x86_64                    60.2.1-1.el7.centos     updates
firewall-config.noarch         0.4.4.4-15.el7_5         updates
firewalld.noarch                   0.4.4.4-15.el7_5        updates
firewalld-filesystem.noarch 0.4.4.4-15.el7_5         updates
flatpak.x86_64                       0.8.8-4.el7_5           updates

Exit value codes
100 - Package available for updates  or  lists the packages
  0 - No package available for update
  1 - Error


6. We can update the existing installed package.

If we have older version package installed in server and we can use yum update packagename to upgrade it to current version.

[root@nsk ~]# yum update ansible.noarch

Resolving Dependencies
--> Running transaction check
---> Package ansible.noarch 0:2.6.3-1.el7 will be updated
---> Package ansible.noarch 0:2.6.5-1.el7 will be an update

7. If we want to update the specific version of package.
Here we need to specify the exact version of the package. It will work like upgrade. 

[root@nsk ~]# yum update-to tigervnc-1.8.0-5.el7.x86_64


8. If you want to downgrade the currently installed package to previous highest version or particular version.

Yum downgrade command is used to downgrade a package from the version currently installed to the previouse highest version or specific version.

Currently installed firefox version

[root@nsk ~]# rpm -qa |  grep -i firefox
firefox-60.1.0-4.el7.centos.x86_64

[root@nsk ~]# yum downgrade firefox

  Installing : firefox-52.8.0-1.el7.centos.x86_64                1/2
  Cleanup  : firefox-60.1.0-4.el7.centos.x86_64                2/2
  Verifying  : firefox-52.8.0-1.el7.centos.x86_64                1/2
  Verifying  : firefox-60.1.0-4.el7.centos.x86_64                2/2

Removed:
  firefox.x86_64 0:60.1.0-4.el7.centos

Installed:
  firefox.x86_64 0:52.8.0-1.el7.centos

Complete!

[root@nsk ~]# rpm -qa | grep -i firefox
firefox-52.8.0-1.el7.centos.x86_64


9. Search the package which needs to be installed

Yum search command is used to search by using keyword.

[root@nsk ~]# yum search vnc

tigervnc.x86_64 : A TigerVNC remote display system
tigervnc-icons.noarch : Icons for TigerVNC viewer
tigervnc-license.noarch : License of TigerVNC suite
tigervnc-server.x86_64 : A TigerVNC server
xorg-x11-server-source.noarch : Xserver source code required to build VNC server (Xvnc)

  Name and summary matches only, use "search all" for everything.
[root@nsk ~]#


10. Display about the information about package

  Once you search the package, Yum info command is used to display some additional information about that package.

[root@nsk ~]# yum info tigervnc.x86_64

Available Packages
Name         : tigervnc
Arch           : x86_64
Version      : 1.8.0
Release     : 5.el7
Size           : 239 k
Repo          : base/7/x86_64
Summary   : A TigerVNC remote display system
URL            : http://www.tigervnc.com
License       : GPLv2+
Description : Virtual Network Computing (VNC) is a remote display system which
            : allows you to view a computing 'desktop' environment not only on the
            : machine where it is running, but from anywhere on the Internet and
            : from a wide variety of machine architectures.  This package contains a
            : client which will allow you to connect to other desktops running a VNC
            : server.

11. View all available packages.

yum list will show all available packages.

[root@nsk ~]# yum list


12. View only the installed packages

[root@nsk ~]# yum list installed


13. Find a package name by using file name.

    Yum provides command is used to findout the package which is related to the file in Linux server.

[root@nsk ~]# yum provides /etc/nsswitch.conf

glibc-2.17-222.el7.i686 : The GNU libc libraries
Repo        : base
Matched from:
Filename    : /etc/nsswitch.conf

glibc-2.17-222.el7.x86_64 : The GNU libc libraries
Repo        : base
Matched from:
Filename    : /etc/nsswitch.conf

glibc-2.17-222.el7.i686 : The GNU libc libraries
Repo        : @base
Matched from:
Filename    : /etc/nsswitch.conf

glibc-2.17-222.el7.x86_64 : The GNU libc libraries
Repo        : @base
Matched from:
Filename    : /etc/nsswitch.conf


14. Find a list of group software packages

In yum, related packages are grouped together with specific name. We can install the group instead of search one by one.

[root@nsk ~]# yum grouplist

Installed Environment Groups:
   GNOME Desktop
Available Environment Groups:
   Minimal Install
   Compute Node
   Infrastructure Server
   File and Print Server
   Cinnamon Desktop
   MATE Desktop
   Basic Web Server
   Virtualization Host
   Server with GUI
   KDE Plasma Workspaces
   Development and Creative Workstation
Available Groups:
   Cinnamon
   Compatibility Libraries
   Console Internet Tools
   Development Tools
   Educational Software
   Electronic Lab
   Fedora Packager
   General Purpose Desktop
   Graphical Administration Tools
   Haskell
   Legacy UNIX Compatibility
   MATE
   Milkymist
   Scientific Support
   Security Tools
   Smart Card Support
   System Administration Tools
   System Management
   TurboGears application framework
   Xfce
Done
[root@nsk ~]#


15. If we want to install particular rpm group, can yum groupinstall

[root@nsk ~]# yum groupinstall 'MATE'


16. Display the available software repositories

Yum is always pointed to some of the software repositories. We can view the same by running below command.

[root@nsk ~]# yum repolist


17. Install from disabled repositories.

Normally all the repositories are enabled. If we need to install packages from disabled repositories, we need to use below command.

[root@nsk ~]# yum --enablerepo=epel install tigervnc.x86_64

Running transaction
  Installing : tigervnc-1.8.0-5.el7.x86_64     1/1
  Verifying  : tigervnc-1.8.0-5.el7.x86_64     1/1

Installed:
  tigervnc.x86_64 0:1.8.0-5.el7

Complete!


18. Yum commands in interactive shell.

we can run yum commands in interactive shell mode.


[root@nsk ~]# yum shell

> updateinfo
epel/x86_64/updateinfo                                                                                                | 948 kB  00:00:00
Updates Information Summary: updates
    3 Bugfix notice(s)
    2 Enhancement notice(s)


By using shell command, we can run multiple commands from a file. First add the command in text file then execute the yum shell command.

[root@nsk nsk]# cat shell_cmd.txt
provides /etc/nsswitch.conf
info tigervnc.x86_64

[root@nsk nsk]# yum shell shell_cmd.txt

glibc-2.17-222.el7.i686 : The GNU libc libraries
Repo        : base
Matched from:
Filename    : /etc/nsswitch.conf

glibc-2.17-222.el7.x86_64 : The GNU libc libraries
Repo        : base
Matched from:
Filename    : /etc/nsswitch.conf

glibc-2.17-222.el7.i686 : The GNU libc libraries
Repo        : @base
Matched from:
Filename    : /etc/nsswitch.conf

glibc-2.17-222.el7.x86_64 : The GNU libc libraries
Repo        : @base
Matched from:
Filename    : /etc/nsswitch.conf

Installed Packages
Name        : tigervnc
Arch          : x86_64
Version      : 1.8.0
Release     : 5.el7
Size           : 680 k
Repo          : installed
From repo  : base
Summary    : A TigerVNC remote display system
URL         : http://www.tigervnc.com
License     : GPLv2+
Description : Virtual Network Computing (VNC) is a remote display system which
            : allows you to view a computing 'desktop' environment not only on the
            : machine where it is running, but from anywhere on the Internet and
            : from a wide variety of machine architectures.  This package contains a
            : client which will allow you to connect to other desktops running a VNC
            : server.


19. If we want to see the status of past yum activities

Yum history command is used to view the past activities of yum. We can use info/list/packages-list/packages-info/summary to view what happened, undo/redo/rollback to act on that information and new to start a new history file.

Here, 
info/list/summary         - use transaction id or package
packages-list/packages-info - use package
undo/redo/rollback         - use single transaction id or the keyword and an offset from the last transaction
undo/redo         - use specified transaction id


[root@nsk ~]# yum history  list
Loaded plugins: fastestmirror, langpacks
ID     | Command line                     | Date and time      | Action(s)          | Altered
-------------------------------------------------------------------------------
    50 | update firefox                     | 2018-10-10 15:31 | Update             |    1
    49 | downgrade firefox              | 2018-10-10 15:20 | Downgrade      |    1
    48 | remove tigervnc-1.8.0-5.    | 2018-10-09 18:19 | Erase               |    1
    47 | --enablerepo=epel instal    | 2018-10-09 17:29 | Install               |    1
    46 | remove vnc                        | 2018-10-09 15:12 | Erase               |    1
    45 | install vnc                           | 2018-10-09 15:10 | Install               |    4
    44 | install nmon                       | 2018-10-08 15:33 | Install                |    1
    43 | install pwgen                      | 2018-09-18 16:04 | Install               |    1
    42 | install php-* --skip-bro       | 2018-09-13 20:06 | Install                |  638 ss
    41 | install mysql-*                    | 2018-09-13 19:52 | Install                |   87
    40 | install ipython                     | 2018-09-13 18:41 | Install               |   35
    39 | install phpmy*                    | 2018-09-07 18:35 | Install                |    2
    38 | install mariadb-*                 | 2018-09-07 13:20 | Install                |    9
    37 | erase mariadb-*                 | 2018-09-07 13:20 | Erase                |    9
    36 | install mariadb-*                 | 2018-09-07 13:19 | Install                |    9
    35 | remove mariadb-*              | 2018-09-07 13:18 | Erase                |    9
    34 | install mariadb-*                 | 2018-09-07 12:10 | Install                |   19
    33 | remove mariadb-*              | 2018-09-07 11:55 | Erase                 |    8 EE
    32 | install phpmyadmin            | 2018-08-31 14:00 | Install                 |    7  <
    31 | install php-pgsql                 | 2018-08-31 13:22 | Install                |    2 >
history list

Here,

> - The rpmdb was changed, outside yum, after the transaction.
        < - The rpmdb was changed, outside yum, before the transaction.
        * - The transaction aborted before completion.
        # - The transaction completed, but with a non-zero status.
        E - The transaction completed fine, but had warning/error output during the transaction.
        P - The transaction completed fine, but problems already existed in the rpmdb.
        s - The transaction completed fine, but --skip-broken was enabled and had to skip some packages.

[root@nsk ~]# yum history list all
Loaded plugins: product-id, rhnplugin, search-disabled-repos, security, subscription-manager
This system is receiving updates from RHN Classic or RHN Satellite.
ID     | Login user                           | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
    38 | Shahapuri ... <a251761>  | 2018-08-03 17:45 | I, O, U        |  145 EE
    37 | Shahapuri ... <a251761>  | 2018-08-03 17:43 | Update       |    5
    36 | System <unset>                | 2018-05-11 11:27 | Erase         |    2 EE
    35 | T ... <a262237>                 | 2018-03-01 10:46 | E, I, U        |   80 EE
    34 | System <unset>                | 2017-12-01 13:47 | Update       |    1 EE
    33 | Kukkala ... <a253740>      | 2017-11-24 10:42 | E, I, U         |  246 EE
    32 | Kukkala ... <a253740>      | 2017-11-24 10:38 | Update       |    3
    31 | System <unset>                | 2017-11-21 14:50 | I, U             |    4
    30 | System <unset>                | 2017-06-16 09:57 | Update       |    2
    29 | Govindu ... <a055637>     | 2017-02-20 13:17 | E, I, U         |   42 EE
    28 | Shukla ... <a222788>        | 2016-11-04 10:01 | E, I, U         |   31 EE
    27 | Shukla ... <a222788>        | 2016-11-04 10:00 | Update       |    1
    26 | S ... <a210111>                 | 2016-08-18 15:34 | E, I, O, U    |  261 EE
    25 | S ... <a210111>                 | 2016-08-18 15:24 | Update       |    3 EE
    24 | System <unset>                | 2016-08-05 14:42 | Install         |    4
    23 | Bennurmth ... <a215476> | 2016-06-30 14:17 | Update       |    1
    22 | S ... <a034124>                | 2016-06-01 09:16 | E, I, U         |    5
    21 | Govindu ... <a055637>     | 2016-02-24 12:42 | E, I, U         |   267 EE
    20 | Govindu ... <a055637>     | 2016-02-24 12:40 | Update       |    3
    19 | Honappa ... <a175300>    | 2016-02-04 11:52 | Install         |    1
    18 | Honappa ... <a175300>    | 2016-02-04 11:52 | I, U             |   29
    17 | Lindström ... <a209141>   | 2015-12-02 08:15 | Install         |    4  <
    16 | Lindström ... <a209141>   | 2015-11-06 10:07 | I, U             |    6 >
    15 | Lindström ... <a209141>   | 2015-11-06 10:07 | Install         |    6
    14 | Lindström ... <a209141>   | 2015-11-06 10:06 | Update       |    1
    13 | Lindström ... <a209141>   | 2015-11-06 10:06 | Update       |    5
    12 | Meijer ... <a044156>         | 2015-03-25 18:03 | Install         |   16
    11 | Meijer ... <a044156>         | 2015-03-25 15:54 | Install         |    5
    10 | Palakurthi ... <tin1926>     | 2015-01-28 19:08 | I, U             |  262 EE
     9 | Muniraj ... <a028981>        | 2014-12-24 14:44 | Update       |    2
     8 | System <unset>                 | 2014-09-26 10:04 | Update       |    1
     7 | System <unset>                 | 2014-09-25 16:10 | Update       |    1
     6 | System <unset>                 | 2014-09-15 11:45 | Install          |  1 EE
     5 | System <unset>                 | 2014-09-15 11:44 | Erase          |    1
     4 | System <unset>                 | 2014-09-15 11:41 | Install          |   15
     3 | System <unset>                 | 2014-09-15 11:37 | I, U              |   94 EE
     2 | System <unset>                 | 2014-09-15 11:36 | Install          |   35
     1 | System <unset>                 | 2014-09-15 11:29 | Install          |  573
history list


20. If we want to know the last transactions details from history list. We can specifically give the transaction ID to know about it.

[root@nsk ~]# yum history info
Loaded plugins: fastestmirror, langpacks
Transaction ID : 50
Begin time       : Wed Oct 10 15:31:55 2018
Begin rpmdb    : 2356:97f14b883648310fc9cf9ed660ba4f5f7b52c615
End time          :            15:32:09 2018 (14 seconds)
End rpmdb       : 2356:efedc71553518d49ee1e9feb83d17272b3fde07a
User                 : root <root>
Return-Code    : Success
Command Line   : update firefox
Transaction performed with:
    Installed     rpm-4.11.3-32.el7.x86_64                        @base
    Installed     yum-3.4.3-158.el7.centos.noarch                 @base
    Installed     yum-metadata-parser-1.1.4-10.el7.x86_64         @anaconda
    Installed     yum-plugin-fastestmirror-1.1.31-46.el7_5.noarch @updates
Packages Altered:
    Updated firefox-52.8.0-1.el7.centos.x86_64 @updates
    Update          60.2.1-1.el7.centos.x86_64 @updates
history info


[root@nsk ~]# yum history info 43
Loaded plugins: fastestmirror, langpacks
Transaction ID : 43
Begin time       : Tue Sep 18 16:04:53 2018
Begin rpmdb    : 2351:7203da1b9738104d8a8aa568e21412033e0bd122
End time          :                           (0 seconds)
End rpmdb       : 2352:020dc0b21e7c31b8452fea1a659a87d426f0370a
User                 : root <root>
Return-Code    : Success
Command Line   : install pwgen
Transaction performed with:
    Installed     rpm-4.11.3-32.el7.x86_64                        @base
    Installed     yum-3.4.3-158.el7.centos.noarch                 @base
    Installed     yum-metadata-parser-1.1.4-10.el7.x86_64         @anaconda
    Installed     yum-plugin-fastestmirror-1.1.31-46.el7_5.noarch @updates
Packages Altered:
    Install pwgen-2.08-1.el7.x86_64 @epel
history info

21. Package-info is used to know when the package is installed. If it is transacted more than one time also listed.

[root@nsk ~]# yum history package-info php
Loaded plugins: fastestmirror, langpacks
Transaction ID : 24
Begin time     : Thu Aug 30 13:59:58 2018
Package        : php-5.4.16-45.el7.x86_64
State              : Install
Size               : 4,591,806
Build host      : x86-01.bsys.centos.org
Build time      : Fri Apr 13 00:42:53 2018
Packager       : CentOS BuildSystem <http://bugs.centos.org>
Vendor           : CentOS
License          : PHP and Zend and BSD
URL                : http://www.php.net/
Source RPM   : php-5.4.16-45.el7.src.rpm
Commit Time  : Tue Jan 23 17:30:00 2018
Committer      : Remi Collet <rcollet@redhat.com>
Reason          : user
Command Line   : install php
From repo      : base
Installed by   : root <root>
history package-info
[root@nsk ~]#

22. Package-list will show the transaction id and respective action.

[root@nsk ~]# yum history package-list firefox
Loaded plugins: fastestmirror, langpacks
ID     | Action(s)      | Package
-------------------------------------------------------------------------------
    50 | Updated        | firefox-52.8.0-1.el7.centos.x86_64
    50 | Update          |  60.2.1-1.el7.centos.x86_64
    49 | Downgrade   | firefox-52.8.0-1.el7.centos.x86_64
    49 | Downgraded |   60.1.0-4.el7.centos.x86_64
    29 | Install            | firefox-60.1.0-4.el7.centos.x86_64                 EE
history package-list


23. Download a package without installation

Don't update, just download it. This action will be done in background, so yum lock is release for other action. We can mention the download directory

[root@nsk ~]# yum install --downloadonly --downloaddir=/download/dir  package


24. Skip Packages With Broken Dependencies during update.

It will resolve depsolve problems by removing packages that are causing problems from the transaction.

[root@nsk ~]# yum update --skip-broken


25. Exclude kernel or other packages from getting updated


[root@nsk ~]# yum update --exclude=PACKAGENAME

Wednesday, June 5, 2019

Yum failed with Errno 256 No more mirrors to try - Solved

Wednesday, June 05, 2019 0
Situation:
Yum is  failed with Errno 256, No more mirrors to try.

root@testserver# yum list available | grep erna
https://rhn.test.com/pulp/repos/shared/lce-lcs_6month_rhel7/ccv-lcs_6month_rhel7/content/dist/rhel/server/7/7Server/x86_64/extras/os/repodata/repomd. 

       xml: [Errno 14] curl#58 - "SSL peer rejected your certificate as expired."
Trying other mirror.


One of the configured repositories failed (Red Hat Enterprise Linux 7 Server - Extras (RPMs)),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

....
...
..

    yum-config-manager --save --setopt=rhel-7-server-extras-rpms.skip_if_unavailable=true

failure: repodata/repomd.xml from rhel-7-server-extras-rpms: [Errno 256] No more mirrors to try.
https://rhn.test.com/pulp/repos/shared/lce-lcs_6month_rhel7/ccv-lcs_6month_rhel7/content/dist/rhel/server/7/7Server/x86_64/extras/os/repodata/repomd. 

       xml: [Errno 14] curl#58 - "SSL peer rejected your certificate as expired."


Solution:
Becasue of corrupted yum cache, getting this error.  So refresh the subscription-manager clean the old cache & run the yum command

root@testserver# subscription-manager refresh
All local data refreshed
root@testserver# yum clean all
root@testserver#
root@testserver# yum list available | grep erna
AdaptermFernablesung_15_hq.noarch
DatentauschInternational_hq.noarch
Fernablesung_2.37_hq.noarch 2.0.0.RELEASE-8 tec-x86_64-server-software-release-7
Fernablesung_Application_hq.noarch
Fernablesung_Comm_3.42_hq.noarch 5.4.1.RELEASE-92 tec-x86_64-server-software-release-7
Fernablesung_Helper_hq.noarch 7.1.5.RELEASE-126 tec-x86_64-server-software-release-7
Fernablesung_IF_3.08_hq.noarch 2.1.0.RELEASE-4 tec-x86_64-server-software-release-7
Fernablesung_IF_3.10_hq.noarch 6.1.1.RELEASE-45 tec-x86_64-server-software-release-7
Fernablesung_Tss3_hq.noarch 1.1.1.RELEASE-315 tec-x86_64-server-software-release-7
ems-AdaptermFernablesung_15_hq.noarch
ems-Fernablesung_hq.noarch 5.2.0.RELEASE-28 tec-x86_64-server-software-release-7
gnome-shell-extension-alternate-tab.noarch
gnome-shell-extension-alternative-status-menu.noarch
root@testserver#

Wednesday, October 3, 2018

How to rebuild the GRUB configuration file in RHEL7

Wednesday, October 03, 2018 0
Rebuilding the GRUB configuration file in RHEL7

Situation : Whenever there is inconsistency in the GRUB file, empty grub configuration or of the grub file got removed accidentally, follow the below steps to fix the grub issue.







Solution:

STEP 1 : List the partitions by using “ ls “ command
grub > ls
(proc) (hd0) (hd0,msdos3) (hd0,msdos2) (hd0,msdos1) (fd0)

STEP 2: Findout the root partitions by using command ls < partition name >. Run ls command to all above listed available  partitions.










STEP 3: Set the root partition. In our case its present in (hd0,msdos1)
grub> set root=(hd0,msdos1)
grub>

STEP 4: Type Linux and specify the kernel or Press tab for listing the available kernel. Once choosing it, we have to specify the root volume (In our example its /dev/sda1).






grub> linux /vmlinuz-3.10.0-229.el7.x86_64 ro root=/dev/sda1

STEP 5: Specify the initramfs image press tab for listing it. Choose the initramfs image with the same kernel version.







grub> initrd /initramfs-3.10.0-229.el7.x86_64.img

Execute 'boot' command to boot the server with above configuration.

Once the server is up, use grub2-mkconfig command to rebuild the grub.conf file. 

[root@nsk /]grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-229.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-229.el7.x86_64.img
...
.
done

Finally verify the grub file under /boot/grub2/
[root@nsk /]# cd /boot/grub2/
[root@nsk grub2]# ls
device.map  fonts  grub.cfg  grubenv  i386-pc  locale

Reboot the server and verify one more time.

Wednesday, February 28, 2018

How to kill the IDLE pts/tty session in Linux Server?

Wednesday, February 28, 2018 0
 Kill the IDLE pts/tty session in Linux Server

Situation:
    Sometime script command may not be completed properly or sometime improperly closed ssh session makes the idle pts/tty session.
           
[root@dbserver ~]# w
 14:18:28 up 31 days,  4:18,  4 users,  load average: 3.35, 3.42, 3.41
USER     TTY      FROM  LOGIN@   IDLE     JCPU   PCPU  WHAT
root        pts/2    -            27Jan18   31days  0.00s  0.00s   script -a /os_backup_fs/patches/DB_Server/logs/dbserver_Postwork-1.log


Solution:
Here, sometime ps -ft command will not respond

[root@dbserver ~]# ps -ft pts/2
UID         PID   PPID  C STIME TTY          TIME CMD

So, search with process and kill the process id.

[root@dbserver ~]# ps -ef | grep -i /os_backup_fs/patches/DB_Server/logs/dbserver_Postwork-1.log
root     202948 185999  0 14:18 pts/4    00:00:00 grep -i /os_backup_fs/patches/DB_Server/logs/dbserver_Postwork-1.log
root     271243 113886  0 Jan27 pts/1    00:00:00 script -a /os_backup_fs/patches/DB_Server/logs/dbserver_Postwork-1.log
root     271245 271243  0 Jan27 pts/1    00:00:00 script -a /os_backup_fs/patches/DB_Server/logs/dbserver_Postwork-1.log
[root@dbserver ~]# kill -9 271243

Hope it helps.

Thursday, January 11, 2018

Display the timestamping capabilities of particular interface of Linux Server.

Thursday, January 11, 2018 0
Many NICs support software timestamping, but to query your own interface, use the below command, which will display the timestamping capabilities of particular interface

NAME
       ethtool - query or control network driver and hardware settings

[root@nsk ~]# ethtool -T enp0s3
Time stamping parameters for enp0s3:
Capabilities:
        software-transmit     (SOF_TIMESTAMPING_TX_SOFTWARE)
        software-receive      (SOF_TIMESTAMPING_RX_SOFTWARE)
        software-system-clock (SOF_TIMESTAMPING_SOFTWARE)
PTP Hardware Clock: none
Hardware Transmit Timestamp Modes: none
Hardware Receive Filter Modes: none
[root@nsk ~]#

Wednesday, December 27, 2017

Monitoring services using journalctl in RHEL7

Wednesday, December 27, 2017 0

Monitoring services using journalctl in RHEL7


Monitoring services using journalctl in RHEL7

Systemd's journal has the added advantage that its controls allow you to easily narrow down on messages generated by specific services.

1. First, display all the messages generated by your system.
This will show all the messages generated on the system; run the following commands:

[root@nsk ~]# journalctl
-- Logs begin at Tue 2017-12-26 07:31:23 IST, end at Tue 2017-12-26 08:32:09 IST. --
Dec 26 07:31:23 nsk systemd-journal[89]: Runtime journal is using 8.0M (max allowed 91.9M, trying to leave 137.9M free of 911.6M available → current limit 91.
Dec 26 07:31:23 nsk kernel: Initializing cgroup subsys cpuset
Dec 26 07:31:23 nsk kernel: Initializing cgroup subsys cpu
Dec 26 07:31:23 nsk kernel: Initializing cgroup subsys cpuacct
Dec 26 07:31:23 nsk kernel: Linux version 3.10.0-693.5.2.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) ) #
Dec 26 07:31:23 nsk kernel: Command line: BOOT_IMAGE=/vmlinuz-3.10.0-693.5.2.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root
Dec 26 07:31:23 nsk kernel: e820: BIOS-provided physical RAM map:
Dec 26 07:31:23 nsk kernel: BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable
Dec 26 07:31:23 nsk kernel: BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved…...
…………..
~]#
2. Now, display all system-related messages.
This command shows all the messages related to the system and not its users:
[root@nsk ~]# journalctl –-system

3. Display all the current user messages.
This command shows all messages related to the user that you are logged on with:
[root@nsk ~]# journalctl –-user

4. Next, display all messages generated by a particular service using the following command line:
journalctl --unit=<service>

[root@nsk ~]# journalctl --unit=sshd
-- Logs begin at Tue 2017-12-26 07:31:23 IST, end at Tue 2017-12-26 08:33:14 IST. --
Dec 26 07:31:29 nsk systemd[1]: Starting OpenSSH server daemon...
Dec 26 07:31:29 nsk sshd[944]: Server listening on 0.0.0.0 port 22.
Dec 26 07:31:29 nsk sshd[944]: Server listening on :: port 22.
Dec 26 07:31:29 nsk systemd[1]: Started OpenSSH server daemon.
Dec 26 07:33:37 nsk sshd[1238]: Accepted password for root from 10.0.2.2 port 60698 ssh2
Dec 26 07:34:11 nsk sshd[1261]: Accepted password for root from 10.0.2.2 port 60702 ssh2
Dec 26 08:30:19 nsk systemd[1]: Stopping OpenSSH server daemon...
……..

6. Now, display messages by priority.

Priorities can be specified by a keyword or number, such as debug (7), info (6), notice (5), warning (4), err (3), crit (2), alert (1), and emerg (0). When specifying a priority, this includes all the lower priorities as well. For example, err implies that crit, alert, and emerg are also shown. Take a look at the following command line:
journalctl -p <priority>

[root@nsk ~]# journalctl -p err
-- Logs begin at Tue 2017-12-26 07:31:23 IST, end at Tue 2017-12-26 08:33:14 IST. --
Dec 26 08:26:15 nsk rsyslogd[613]: imjournal: journal reloaded... [v8.24.0 try http://www.rsyslog.com/e/0 ]
Dec 26 08:30:21 nsk lvmetad[483]: Failed to accept connection errno 11.

7. Next, display messages by time.
You can show all messages from the current boot through the following commands:

[root@nsk ~]# journalctl -b
-- Logs begin at Tue 2017-12-26 07:31:23 IST, end at Tue 2017-12-26 08:33:14 IST. --
Dec 26 08:30:45 nsk systemd-journal[86]: Runtime journal is using 8.0M (max allowed 91.9M, trying to leave 137.9M free of 911.6M available → current limit 91.
Dec 26 08:30:45 nsk kernel: Initializing cgroup subsys cpuset
Dec 26 08:30:45 nsk kernel: Initializing cgroup subsys cpu
Dec 26 08:30:45 nsk kernel: Initializing cgroup subsys cpuacct
Dec 26 08:30:45 nsk kernel: Linux version 3.10.0-693.5.2.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) ) #
Dec 26 08:30:45 nsk kernel: Command line: BOOT_IMAGE=/vmlinuz-3.10.0-693.5.2.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root
Dec 26 08:30:45 nsk kernel: e820: BIOS-provided physical RAM map:
You can even show all the messages within a specific time range by running the following:
[root@nsk ~]# journalctl --since="2017-12-26 08:30:00" --until="2017-12-26 09:00:00"
-- Logs begin at Tue 2017-12-26 07:31:23 IST, end at Tue 2017-12-26 08:33:14 IST. --
Dec 26 08:30:19 nsk polkitd[619]: Registered Authentication Agent for unix-process:1587:353648 (system bus name :1.40 [/usr/bin/pkttyagent --notify-fd 5 --fal
Dec 26 08:30:19 nsk ntpd[1551]: ntpd exiting on signal 15
Dec 26 08:30:19 nsk systemd[1]: Stopped target Network is Online.
Dec 26 08:30:19 nsk sshd[944]: Received signal 15; terminating.
Dec 26 08:30:19 nsk systemd[1]: Stopping Network is Online.
Dec 26 08:30:19 nsk crond[628]: (CRON) INFO (Shutting down)
…….

For instance, if you want to show all the error messages between 8:30 and 9:00 on 2017-12-26, your command would be the following:

[root@nsk ~]# journalctl -p err --since="2017-12-26 08:30:00" --until="2017-12-26 09:00:00"
-- Logs begin at Tue 2017-12-26 07:31:23 IST, end at Tue 2017-12-26 08:33:14 IST. --
Dec 26 08:30:21 nsk lvmetad[483]: Failed to accept connection errno 11.
[root@nsk ~]#

The journalctl binary is an executable one, so it is impossible to use the traditional "following" techniques such as tail –f or using less and pressing CTRL + F. Simply add -f or --follow as an argument to the journalctl command.

[root@nsk ~]# journalctl -f
-- Logs begin at Tue 2017-12-26 07:31:23 IST. --
Dec 26 08:30:53 nsk systemd[1]: Started Crash recovery kernel arming.
Dec 26 08:30:53 nsk systemd[1]: Startup finished in 392ms (kernel) + 1.702s (initrd) + 6.681s (userspace) = 8.777s.
Dec 26 08:32:08 nsk sshd[1259]: Accepted password for root from 10.0.2.2 port 63824 ssh2
Dec 26 08:32:09 nsk systemd[1]: Created slice User Slice of root.
Dec 26 08:32:09 nsk systemd[1]: Starting User Slice of root.
Although most environments are used to create syslog messages to troubleshoot, the journal does provide the added value of being able to create simple filters that allow you to monitor their messages live.

Wednesday, December 20, 2017

ssh_exchange_identification: Connection closed by remote host - Password less authentication setup

Wednesday, December 20, 2017 0

ssh_exchange_identification: Connection closed by remote host - Password less authentication setup 


Situation:
While setup passwordless authentication from testserver2 (192.181.166.55) to testserver1 (192.181.130.55)  server, getting  error "ssh_exchange_identification: Connection closed by remote host"

[kanachim@testserver2 .ssh]$ ssh -vv testserver1
OpenSSH_5.3p1-hpn13v7, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to 192.181.166.55 [192.181.166.55] port 22.
debug1: Connection established.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug2: key_type_from_name: unknown key type '-----END'
debug1: identity file /home/kanachim/.ssh/id_rsa type 1
debug1: identity file /home/kanachim/.ssh/id_dsa type -1
ssh_exchange_identification: Connection closed by remote host

Solution:
Check /etc/hosts.deny on server testserver1

root@host testserver1# grep sshd /etc/hosts.deny 
# DenyHosts: Mon Dec 18 22:10:38 2017 | sshd: 192.181.166.55
sshd: 192.181.166.55

Remove the sshd entry from hosts.deny on testserver1

Login to testserver2 Switch to user kanachim & create new key

-bash-3.2$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/kanachim/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/kanachim/.ssh/id_rsa.
Your public key has been saved in/home/kanachim/.ssh/id_rsa.pub.
The key fingerprint is:
37:6a:69:c1:a4:01:4b:c5:34:be:32:42:90:0b:20:a0 kanachim@192.181.166.55
The key's randomart image is:
+--[ RSA 2048]----+
|B.  o++          |
|=. . +..         |
|E.. . o .        |
|..     *         |
|  . o o S o      |
|   . o   = .     |
|        =        |
|       o         |
|                 |
+-----------------+
-bash-3.2$
-bash-3.2$ ssh-copy-id kanachim@192.181.130.55
Password:
Now try logging into the machine, with "ssh 'kanachim@192.181.130.55'", and check in:
  .ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.

Now login from testserver2 to testserver1

-bash-3.2$ ssh 192.181.130.55
Last login: Thu Feb 27 00:30:38 2014 from 10.217.230.145
-bash-3.2$ hostname
testserver1