Category Archives: Howto

How to upgrade kernel in RHEL, Suse, Ubuntu Linux

Step by step procedure to upgrade kernel in RHEL, Suse, and Ubuntu Linux along with sample outputs of all the commands.

Upgrade kernel in RHEL, Suse, and Ubuntu Linux

How to check current kernel & patch level in Linux

You can confirm current kernel version & patch level using uname -r and uname -v command.

root@kerneltlks # uname -v
#1 SMP Sun Jul 27 15:55:46 EDT 2014
root@kerneltalks # uname -r
2.6.32-431.29.2.el6.x86_64

-r switch gives you your current kernel version. -v gives you your current patch level. You can see in the above output our RHEL6 system has 2014 (almost 4 years old) patched kernel. We will patch it to the latest one in this article.

How to upgrade the kernel in RHEL

Patching kernel is Linux is the same as upgrading to the latest kernel. Make sure you have yum configured properly to receive the latest packages from trusted repositories. If you do not have/want yum configurations, you can download the latest kernel and its dependencies from the Red Hat portal and keep it ready on the server for installation.

Never replace the existing kernel by updating the package. Always install a new kernel package so that your old kernel still resides on the server and you can boot it if your server/application is not behaving well with the new kernel.

To install the latest kernel, use rpm -ivh <rpm names> or yum install kernel command.

root@kerneltalks # yum install kernel
Loaded plugins: amazon-id, rhui-lb, security
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package kernel.x86_64 0:2.6.32-696.20.1.el6 will be installed
--> Processing Dependency: dracut-kernel >= 004-408.el6 for package: kernel-2.6.32-696.20.1.el6.x86_64
--> Processing Dependency: kernel-firmware >= 2.6.32-696.20.1.el6 for package: kernel-2.6.32-696.20.1.el6.x86_64
--> Running transaction check
---> Package dracut-kernel.noarch 0:004-336.el6_5.2 will be updated
---> Package dracut-kernel.noarch 0:004-409.el6_8.2 will be an update
--> Processing Dependency: dracut = 004-409.el6_8.2 for package: dracut-kernel-004-409.el6_8.2.noarch
---> Package kernel-firmware.noarch 0:2.6.32-431.29.2.el6 will be updated
---> Package kernel-firmware.noarch 0:2.6.32-696.20.1.el6 will be an update
--> Running transaction check
---> Package dracut.noarch 0:004-336.el6_5.2 will be updated
---> Package dracut.noarch 0:004-409.el6_8.2 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================
 Package                              Arch                        Version                                   Repository                                             Size
========================================================================================================================================================================
Installing:
 kernel                               x86_64                      2.6.32-696.20.1.el6                       rhui-REGION-rhel-server-releases                       32 M
Updating for dependencies:
 dracut                               noarch                      004-409.el6_8.2                           rhui-REGION-rhel-server-releases                      127 k
 dracut-kernel                        noarch                      004-409.el6_8.2                           rhui-REGION-rhel-server-releases                       28 k
 kernel-firmware                      noarch                      2.6.32-696.20.1.el6                       rhui-REGION-rhel-server-releases                       29 M

Transaction Summary
========================================================================================================================================================================
Install       1 Package(s)
Upgrade       3 Package(s)

Total download size: 61 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): dracut-004-409.el6_8.2.noarch.rpm                                                                                                         | 127 kB     00:00
(2/4): dracut-kernel-004-409.el6_8.2.noarch.rpm                                                                                                  |  28 kB     00:00
(3/4): kernel-2.6.32-696.20.1.el6.x86_64.rpm                                                                                                     |  32 MB     00:00
(4/4): kernel-firmware-2.6.32-696.20.1.el6.noarch.rpm                                                                                            |  29 MB     00:00
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                    45 MB/s |  61 MB     00:01
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : dracut-004-409.el6_8.2.noarch                                                                                                                        1/7
  Updating   : dracut-kernel-004-409.el6_8.2.noarch                                                                                                                 2/7
  Updating   : kernel-firmware-2.6.32-696.20.1.el6.noarch                                                                                                           3/7
  Installing : kernel-2.6.32-696.20.1.el6.x86_64                                                                                                                    4/7
  Cleanup    : dracut-kernel-004-336.el6_5.2.noarch                                                                                                                 5/7
  Cleanup    : dracut-004-336.el6_5.2.noarch                                                                                                                        6/7
  Cleanup    : kernel-firmware-2.6.32-431.29.2.el6.noarch                                                                                                           7/7
  Verifying  : kernel-firmware-2.6.32-696.20.1.el6.noarch                                                                                                           1/7
  Verifying  : kernel-2.6.32-696.20.1.el6.x86_64                                                                                                                    2/7
  Verifying  : dracut-kernel-004-409.el6_8.2.noarch                                                                                                                 3/7
  Verifying  : dracut-004-409.el6_8.2.noarch                                                                                                                        4/7
  Verifying  : dracut-004-336.el6_5.2.noarch                                                                                                                        5/7
  Verifying  : kernel-firmware-2.6.32-431.29.2.el6.noarch                                                                                                           6/7
  Verifying  : dracut-kernel-004-336.el6_5.2.noarch                                                                                                                 7/7

Installed:
  kernel.x86_64 0:2.6.32-696.20.1.el6

Dependency Updated:
  dracut.noarch 0:004-409.el6_8.2                  dracut-kernel.noarch 0:004-409.el6_8.2                  kernel-firmware.noarch 0:2.6.32-696.20.1.el6

Complete!

If you are on a test system and don’t mind wiping out old kernel then you can directly use yum update kernel or rpm -Uvh <rpms> command and update kernel.

If you observe, yum resolved dependencies too. If you are opting to install from rpm you need to download all dependencies as well. Here is the list of dependencies depending on your RHEL version :

RHEL4 kernel package upgrade dependencies:kernel-smp, kernel-largesmp, kernel-hugemem
RHEL5 kernel package upgrade dependencies:kernel-PAE, kernel-xen
RHEL6 kernel package upgrade dependencies: kernel-firmware
RHEL7 kernel package upgrade dependencies:dracut, dracut-network, dracut-config-rescue

Now, if you observe,/boot/grub/grub.conf your newly installed kernel entry is added before your old kernel entry. This gives new kernel priority to boot when you reboot the system. parameter default=0 says the system needs to be booted from the very first kernel defined below. Kernel entries numbering starts from 0. Make sure this parameter value points to your newly installed kernel and reboot the system.

# cat /boot/grub/grub.conf
default=0
timeout=1
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.32-696.20.1.el6.x86_64)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.32-696.20.1.el6.x86_64 console=ttyS0 ro root=UUID=9996863e-b964-47d3-a33b-3920974fdbd9 rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=us LANG=en_US.UTF-8 xen_blkfront.sda_is_xvda=1 console=ttyS0,115200n8 console=tty0 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_NO_LVM rd_NO_DM
        initrd /boot/initramfs-2.6.32-696.20.1.el6.x86_64.img
title Red Hat Enterprise Linux (2.6.32-431.29.2.el6.x86_64)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.32-431.29.2.el6.x86_64 console=ttyS0 ro root=UUID=9996863e-b964-47d3-a33b-3920974fdbd9 rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=us LANG=en_US.UTF-8 xen_blkfront.sda_is_xvda=1 console=ttyS0,115200n8 console=tty0 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_NO_LVM rd_NO_DM
        initrd /boot/initramfs-2.6.32-431.29.2.el6.x86_64.img

After rebooting, you can see your system is running with a new updated kernel!

root@kerneltalks # reboot

Broadcast message from root@kerneltalks
        (/dev/pts/0) at 2:14 ...

The system is going down for reboot NOW!

root@kerneltalks # uname -r
2.6.32-696.20.1.el6.x86_64
root@kerneltalks # uname -v
#1 SMP Fri Jan 12 15:07:59 EST 2018

You can see kernel is upgraded from 2.6.32-431.29.2.el6.x86_64 to 2.6.32-696.20.1.el6.x86_64. And patch level from July 2014 to Jan 2018.

How to upgrade the kernel in Suse Linux

Let’s start with checking current kernel version and patch info.

root@kerneltalks # uname -r
3.0.101-108.21-default
root@kerneltalks # uname -v
#1 SMP Fri Dec 29 10:25:37 UTC 2017 (5f5299b)

Perform kernel upgrade with zypper or if you have kernel rpm package with you, you can use rpm -ivh <kernel_rpm_path> to perform the multi-kernel install (not update)

You have an option to perform distribution upgrade using zypper dup as well which includes updating all packages to available updates. But most of the cases it’s not recommended.

# zypper up kernel-default
Refreshing service 'cloud_update'.
Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following packages are going to be upgraded:
  kernel-default kernel-default-base

2 packages to upgrade.
Overall download size: 40.2 MiB. After the operation, additional 1.2 MiB will be used.
Continue? [y/n/? shows all options] (y): y
Retrieving package kernel-default-base-3.0.101-108.35.1.x86_64 (1/2), 15.7 MiB (23.2 MiB unpacked)
Retrieving: kernel-default-base-3.0.101-108.35.1.x86_64.rpm [done]
Retrieving package kernel-default-3.0.101-108.35.1.x86_64 (2/2), 24.5 MiB (86.1 MiB unpacked)
Retrieving: kernel-default-3.0.101-108.35.1.x86_64.rpm [done]
Installing: kernel-default-base-3.0.101-108.35.1 [done]
Additional rpm output:

Kernel image:   /boot/vmlinuz-3.0.101-108.35-default
Initrd image:   /boot/initrd-3.0.101-108.35-default
Root device:    /dev/hda1 (mounted on / as ext3)
Kernel Modules: xen-platform-pci xen-vbd-upstream xen-vbd xen-balloon xen-vnif scsi_mod libata ata_piix jbd mbcache ext3 edd usb-common usbcore ehci-hcd ohci-hcd uhci-hcd xhci-hcd crc-t10dif sd_mod
Features:       acpi fv_guest block resume.userspace resume.kernel
32723 blocks


Installing: kernel-default-3.0.101-108.35.1 [done]
Additional rpm output:

Kernel image:   /boot/vmlinuz-3.0.101-108.35-default
Initrd image:   /boot/initrd-3.0.101-108.35-default
Root device:    /dev/hda1 (mounted on / as ext3)
Kernel Modules: hwmon thermal_sys thermal processor fan xen-platform-pci xen-vbd-upstream xen-vbd xen-balloon xen-vnif scsi_mod libata ata_piix ata_generic jbd mbcache ext3 edd usb-common usbcore ehci-hcd ohci-hcd uhci-hcd xhci-hcd hid usbhid crc-t10dif sd_mod
Features:       acpi fv_guest block usb resume.userspace resume.kernel
33630 blocks

# reboot
Broadcast message from root (pts/0) (Sat Mar  3 04:47:12 2018):

The system is going down for reboot NOW!

Reboot the system and then check new kernel version.

# uname -r
3.0.101-108.35-default
# uname -v
#1 SMP Mon Feb 19 21:13:08 UTC 2018 (251ec24)

You can see the kernel is upgraded from 3.0.101-108.21-default to 3.0.101-108.35-default. And patch date from Dec 2017 to Feb 2018!

How to upgrade the kernel in Ubuntu Linux

Start with checking your current kernel version and patching date

# uname -v
#16-Ubuntu SMP Fri Jan 20 15:31:12 UTC 2017
# uname -r
4.9.0-15-generic

Now visit the Ubuntu Kernel page and download the kernel of your choice which is matching with your server arch using wget. We chose to upgrade to 4.10 kernel. Since we have generic kernel we downloaded generic kernel files from 4.10 directory.

root@kerneltalks # wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.1/linux-headers-4.10.1-041001-generic_4.10.1-041001.201702260735_amd64.deb
--2018-03-03 05:03:15--  http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.1/linux-headers-4.10.1-041001-generic_4.10.1-041001.201702260735_amd64.deb
Resolving kernel.ubuntu.com (kernel.ubuntu.com)... 91.189.94.216
Connecting to kernel.ubuntu.com (kernel.ubuntu.com)|91.189.94.216|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 659514 (644K) [application/x-debian-package]
Saving to: ‘linux-headers-4.10.1-041001-generic_4.10.1-041001.201702260735_amd64.deb’

linux-headers-4.10.1-041001-generic_4.10. 100%[=====================================================================================>] 644.06K  1.32MB/s    in 0.5s

2018-03-03 05:03:16 (1.32 MB/s) - ‘linux-headers-4.10.1-041001-generic_4.10.1-041001.201702260735_amd64.deb’ saved [659514/659514]

root@kerneltalks # wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.1/linux-image-4.10.1-041001-generic_4.10.1-041001.201702260735_amd64.deb
--2018-03-03 05:03:24--  http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.1/linux-image-4.10.1-041001-generic_4.10.1-041001.201702260735_amd64.deb
Resolving kernel.ubuntu.com (kernel.ubuntu.com)... 91.189.94.216
Connecting to kernel.ubuntu.com (kernel.ubuntu.com)|91.189.94.216|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 59573112 (57M) [application/x-debian-package]
Saving to: ‘linux-image-4.10.1-041001-generic_4.10.1-041001.201702260735_amd64.deb’

linux-image-4.10.1-041001-generic_4.10.1- 100%[=====================================================================================>]  56.81M   744KB/s    in 2m 40s

2018-03-03 05:06:05 (363 KB/s) - ‘linux-image-4.10.1-041001-generic_4.10.1-041001.201702260735_amd64.deb’ saved [59573112/59573112]

root@kerneltalks # wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.1/linux-headers-4.10.1-041001_4.10.1-041001.201702260735_all.deb
--2018-03-03 05:06:10--  http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.1/linux-headers-4.10.1-041001_4.10.1-041001.201702260735_all.deb
Resolving kernel.ubuntu.com (kernel.ubuntu.com)... 91.189.94.216
Connecting to kernel.ubuntu.com (kernel.ubuntu.com)|91.189.94.216|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 10345532 (9.9M) [application/x-debian-package]
Saving to: ‘linux-headers-4.10.1-041001_4.10.1-041001.201702260735_all.deb’

linux-headers-4.10.1-041001_4.10.1-041001 100%[=====================================================================================>]   9.87M   932KB/s    in 14s

2018-03-03 05:06:24 (739 KB/s) - ‘linux-headers-4.10.1-041001_4.10.1-041001.201702260735_all.deb’ saved [10345532/10345532]

Now install these kernel packages using dpkg command with -i switch.

root@kerneltalks # dpkg -i *.deb
Selecting previously unselected package linux-headers-4.10.1-041001.
(Reading database ... 56103 files and directories currently installed.)
Preparing to unpack linux-headers-4.10.1-041001_4.10.1-041001.201702260735_all.deb ...
Unpacking linux-headers-4.10.1-041001 (4.10.1-041001.201702260735) ...
Selecting previously unselected package linux-headers-4.10.1-041001-generic.
Preparing to unpack linux-headers-4.10.1-041001-generic_4.10.1-041001.201702260735_amd64.deb ...
Unpacking linux-headers-4.10.1-041001-generic (4.10.1-041001.201702260735) ...
Selecting previously unselected package linux-image-4.10.1-041001-generic.
Preparing to unpack linux-image-4.10.1-041001-generic_4.10.1-041001.201702260735_amd64.deb ...
Done.
Unpacking linux-image-4.10.1-041001-generic (4.10.1-041001.201702260735) ...
Setting up linux-headers-4.10.1-041001 (4.10.1-041001.201702260735) ...
Setting up linux-headers-4.10.1-041001-generic (4.10.1-041001.201702260735) ...
Setting up linux-image-4.10.1-041001-generic (4.10.1-041001.201702260735) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.10.1-041001-generic /boot/vmlinuz-4.10.1-041001-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.10.1-041001-generic /boot/vmlinuz-4.10.1-041001-generic
update-initramfs: Generating /boot/initrd.img-4.10.1-041001-generic
W: mdadm: /etc/mdadm/mdadm.conf defines no arrays.
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.10.1-041001-generic /boot/vmlinuz-4.10.1-041001-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 4.10.1-041001-generic /boot/vmlinuz-4.10.1-041001-generic
run-parts: executing /etc/kernel/postinst.d/x-grub-legacy-ec2 4.10.1-041001-generic /boot/vmlinuz-4.10.1-041001-generic
Searching for GRUB installation directory ... found: /boot/grub
Searching for default file ... found: /boot/grub/default
Testing for an existing GRUB menu.lst file ... found: /boot/grub/menu.lst
Searching for splash image ... none found, skipping ...
Found kernel: /boot/vmlinuz-4.9.0-15-generic
Found kernel: /boot/vmlinuz-4.10.1-041001-generic
Found kernel: /boot/vmlinuz-4.9.0-15-generic
Replacing config file /run/grub/menu.lst with new version
Updating /boot/grub/menu.lst ... done

run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.10.1-041001-generic /boot/vmlinuz-4.10.1-041001-generic
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.10.1-041001-generic
Found initrd image: /boot/initrd.img-4.10.1-041001-generic
Found linux image: /boot/vmlinuz-4.9.0-15-generic
Found initrd image: /boot/initrd.img-4.9.0-15-generic
done

After a successful install, reboot the system and check new kernel version.

root@kerneltalks # reboot

root@kerneltalks # uname -v
#201702260735 SMP Sun Feb 26 12:36:48 UTC 2017
root@kerneltalks # uname -r
4.10.1-041001-generic

You can see kernel is upgraded to 4.10.1-041001-generic from 4.9.0-15-generic. And patch date from Jan 2017 to Feb 2017.

How to enable repository using subscription-manager in RHEL

Learn how to enable repository using subscription-manager in RHEL. The article also includes steps to register system with Red Hat, attach subscription and errors along with resolutions.

Enable repository using subscription-manager

In this article, we will walk you through step by step process to enable Red Hat repository in RHEL fresh installed server.

The repository can be enabled using subscription-managercommand like below –

root@kerneltalks # subscription-manager repos --enable rhel-6-server-rhv-4-agent-beta-debug-rpms
Error: 'rhel-6-server-rhv-4-agent-beta-debug-rpms' does not match a valid repository ID. Use "subscription-manager repos --list" to see valid repositories.

You will see the above error when your subscription is not in place. Let’s go through step by step procedure to enable repositories via subscription-manager

Step 1 : Register your system with Red Hat

We are considering you have a freshly installed system and it’s not yet registered with Red Hat. If you have a registered system already then you can ignore this step.

You can check if your system is registered with Red Hat for the subscription using below command –

# subscription-manager version
server type: This system is currently not registered.
subscription management server: Unknown
subscription management rules: Unknown
subscription-manager: 1.18.10-1.el6
python-rhsm: 1.18.6-1.el6

Here, in the first line of output, you can see the system is not registered. So, let’s start with the registering system. You need to use the subscription-managercommand with register switch. You need to use your Red Hat account credentials here.

root@kerneltalks # subscription-manager register
Registering to: subscription.rhsm.redhat.com:443/subscription
Username: admin@kerneltalks.com
Password:
Network error, unable to connect to server. Please see /var/log/rhsm/rhsm.log for more information.

If you are getting above error then your server is not able to reach RedHat. Check internet connection & if you are able to resolve site names. Sometimes even if you are able to ping the subscription server, you will see this error. This might be because you have the proxy server in your environment. In such a case, you need to add its details in file /etc/rhsm/rhsm.conf. Below proxy details should be populated :

# an http proxy server to use
 proxy_hostname =

# port for http proxy server
 proxy_port =

# user name for authenticating to an http proxy, if needed
 proxy_user =

# password for basic http proxy auth, if needed
 proxy_password =

Once you are done, recheck if subscription-manager taken up new proxy details by using below command –

root@kerneltalks # subscription-manager config
[server]
 hostname = [subscription.rhsm.redhat.com]
 insecure = [0]
 port = [443]
 prefix = [/subscription]
 proxy_hostname = [kerneltalksproxy.abc.com]
 proxy_password = [asdf]
 proxy_port = [3456]
 proxy_user = [user2]
 server_timeout = [180]
 ssl_verify_depth = [3]

[rhsm]
 baseurl = [https://cdn.redhat.com]
 ca_cert_dir = [/etc/rhsm/ca/]
 consumercertdir = [/etc/pki/consumer]
 entitlementcertdir = [/etc/pki/entitlement]
 full_refresh_on_yum = [0]
 manage_repos = [1]
 pluginconfdir = [/etc/rhsm/pluginconf.d]
 plugindir = [/usr/share/rhsm-plugins]
 productcertdir = [/etc/pki/product]
 repo_ca_cert = /etc/rhsm/ca/redhat-uep.pem
 report_package_profile = [1]

[rhsmcertd]
 autoattachinterval = [1440]
 certcheckinterval = [240]

[logging]
 default_log_level = [INFO]

[] - Default value in use

Now, try registering your system again.

root@kerneltalks # subscription-manager register
Registering to: subscription.rhsm.redhat.com:443/subscription
Username: admin@kerneltalks.com
Password:
You must first accept Red Hat's Terms and conditions. Please visit https://www.redhat.com/wapps/tnc/termsack?event[]=signIn . You may have to log out of and back into the Customer Portal in order to see the terms.

You will see the above error if you are adding the server to your Red Hat account for the first time. Go to the URL and accept the terms. Come back to the terminal and try again.

root@kerneltalks # subscription-manager register
Registering to: subscription.rhsm.redhat.com:443/subscription
Username: admin@kerneltalks.com
Password:
The system has been registered with ID: xxxxb2-xxxx-xxxx-xxxx-xx8e199xxx

Bingo! The system is registered with Red Hat now. You can again verify it with version switch.

root@kerneltalks # subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 2.0.43-1
subscription management rules: 5.26
subscription-manager: 1.18.10-1.el6
python-rhsm: 1.18.6-1.el6

Step 2: Attach subscription to your server

First, try to list repositories. You won’t be able to list any since we haven’t attached any subscription to our server yet.

root@kerneltalks # subscription-manager repos --list
This system has no repositories available through subscriptions.

As you can see subscription-manager couldn’t found any repositories, you need to attach subscriptions to your server. Once the subscription is attached, subscription-manager will be able to list repositories under it.

To attach subscription, check all available subscriptions for your server with below command –

root@kerneltalks # subscription-manager list --available
+-------------------------------------------+
Available Subscriptions
+-------------------------------------------+
Subscription Name: Red Hat Enterprise Linux for Virtual Datacenters, Standard
Provides: Red Hat Beta
Red Hat Software Collections (for RHEL Server)
Red Hat Enterprise Linux Atomic Host Beta
Oracle Java (for RHEL Server)
Red Hat Enterprise Linux Server
dotNET on RHEL (for RHEL Server)
Red Hat Enterprise Linux Atomic Host
Red Hat Software Collections Beta (for RHEL Server)
Red Hat Developer Tools Beta (for RHEL Server)
Red Hat Developer Toolset (for RHEL Server)
Red Hat Developer Tools (for RHEL Server)
SKU: RH00050
Contract: xxxxxxxx
Pool ID: 8a85f98c6011059f0160110a2ae6000f
Provides Management: Yes
Available: Unlimited
Suggested: 0
Service Level: Standard
Service Type: L1-L3
Subscription Type: Stackable (Temporary)
Ends: 12/01/2018
System Type: Virtual

You will get the list of such subscriptions available for your server. You need to read through what it provides and note down Pool ID of subscriptions that are useful/required for you.

Now, attach subscriptions to your server by using pool ID.

root@kerneltalks # subscription-manager attach --pool=8a85f98c6011059f0160110a2ae6000f
Successfully attached a subscription for: Red Hat Enterprise Linux for Virtual Datacenters, Standard

If you are not sure which one to pick, you can simply attach subscriptions automatically which are best suited for your server with below command –

root@kerneltalks # subscription-manager attach --auto
Installed Product Current Status:
Product Name: Red Hat Enterprise Linux Server
Status: Subscribed

Move on to the final step to enable repository.

Step 3: Enable repository

Now you will enable repository which is available under your attached subscription.

root@kerneltalks # subscription-manager repos --enable rhel-6-server-rhv-4-agent-beta-debug-rpms
Repository 'rhel-6-server-rhv-4-agent-beta-debug-rpms' is enabled for this system.

That’s it. You are done. You can list repositories with yum command and confirm.

How to boot SPYRUS WorkSafe Pro Linux2Go drive

Learn how to boot SPYRUS WorkSafe PRO Linux2Go drive along with Video Demo.

how to boot Linux from Linux2Go drive

In this article, we will be walking you through steps to first boot your SPYRUS WorkSafe Pro Linux2Go drive and use it. More details about the SPYRUS WorkSafe Pro Linux2Go device. We will be covering more about the device in another article.

Step 1 :

Set your host machine which might be a laptop or desktop on which you are attaching SPYRUS Linux2Go drive in USB port to boot from USB. For altering boot sequences and priority you need to enter BIOS settings of your laptop or desktop.

The process to enter into BIOS changes from hardware to hardware and also the base Operating System you use. In most of the cases pressing orF2F8 or DEL key, while the system is booting, takes you to BIOS. You can search your hardware vendor support manual or website to find the process to get into BIOS.

Once you are in BIOS, you need to change the boot sequence. Normally its Optical drive, Hard Disk, and network/external. Means machine will search for the attached optical drive CD or DVD ROM for the operating system to boot. If not found then it will search attached hard disks. If it doesn’t found OS there it will proceed to check network boot or peripherals devices that have OS to boot.

In our case, we want to boot from USB change the sequence to the external boot method before the internal hard disk. So, the system will check peripheral i.e. USB i.e. our Linux2Go device to boot before internal hard disk which already has OS. This way we are booting from the Linux2Go device rather than the host computer’s hard disk.

Save the settings and reboot the system. Its usually can be done by pressing F10 key and then answering yes to prompt saying ‘save settings and reboot’. But again this might be little different depending on your hardware manufacturer standards.

Step 2:

Connect Linux2Go device to the USB port and reboot the system. Now your system will boot from the SPYRUS Linux2Go device and it will display a bootloader security screen which is known as Toughboot as below.

Toughboot in linux2go drive

You need to enter the Toughboot password here to actually begin booting of OS installed on the Linux2Go device. This password can be found on paper you receive along with your Linux2Go drive. This is additional security by SPYRUS implemented on the drive.

That’s it! after successful password authentication, you will be booted into OS installed on your drive. I have Ubuntu 16.04 LTS installed on my drive. So I booted into it.

Here is a small video of booting SPYRUS WorkSafe Pro Linux2go drive!

How to add Cloundfront CDN in WordPress blog with SSL

Step by step procedure to add Cloundfront CDN in WordPress blog with SSL certificate. Screenshot included for better understanding.

Add Cloundfront CDN in WordPress blog with SSL

In this article, we will walk you through steps where we gonna configure AWS CloudFront CDN for WordPress blog under W3TC (W3 Total Cache) plugin. We will be using basic setup under AWS CloudFront so we won’t be using IAM authentication and accesses in our configuration.

See Cloudfront content delivery network pricing here.

We assume below pre-requisites are completed before moving on with this tutorial.

  1. You have logged in WordPress console of your blog with Admin login
  2. You have W3TC plugin installed in WordPress blog
  3. You have logged in AWS account
  4. You have access to change zone files for your domain (required to have fancy CDN CNAMEs)

Without further delay lets jump in to step by step procedure to add Cloudfront CDN in WordPress blog with screenshots.

AWS certificate manager

You can skip this step if your blog is not https enabled.

In this step, we will import your SSL certificate in AWS which needs to be used with Cloudfront distributions in case you are using fancy URL (like c1.kerneltalks.com) for distributions instead of default system generated XXXXXX.cloudfront.net

You can skip this step if you want to buy an SSL certificate from Amazon and don’t want to use your own. If you are ok to use system-generated distributions name like askdhue.kerneltalks.com and don’t want custom CNAME like c1.kerneltalks.com then also you can skip this step.

You can buy an SSL certificate from many authorized bodies or you can get open source Lets Encrypt SSL certificate for free.

Log in to the AWS certificate manager console. Make sure you use region US East (N. Virginia).  Since only certificates stored in this region are available to select while creating Cloudfront distributions. Click on Get Started and in the next screen click Import a certificate. You will be presented with the below screen.

Import certificate in aws

Fill in your certificate details in the fields above. Certificate body will have your SSL certificate content, then private key, and finally certificate chain (if any). Click Review and import.

These filled in details will be verified and information fetched from it will be shown on screen for your review like below.

Review certificate in AWS certificate manager

If everything looks good click Import. Your certificate will be imported and details will be shown to you in the dashboard.

Now, we have our SSL certificate ready in AWS to be used with Cloudfront distributions custom URLs like c1.kerneltalks.com. Let’s move on to creating distributions.

AWS Cloudfront configuration

Login to AWS Cloudfront console using your Amazon account. On left hand side menu bar make sure you have Distributions selected. Click Create Distribution button. Now, you will be presented with wizard step 1. Select the delivery method.

Click Get Started under the Web delivery method. You will see below screen where you need to fill in details –

cloudfront web distribution

Below are few fields you need to select/fill.

  1. Origin Domain Name: Enter your blog’s naked domain name e.g. kerneltalks.com
  2. Origin ID: If you like autogenerated value keep it or you can name it anything.
  3. Origin protocol policy: Select HTTPS only.
  4. Viewer Protocol Policy: Redirect HTTP to HTTPS
  5. Alternate Domain Names: Enter fancy CDN name you want like c1.kerneltalks.com
  6. SSL certificate -> Custom SSL certificate: You should see your imported certificate from the previous step here.

There are many other options which you can toggle based on your requirement. The above listed are the most basic and needed for normal CDN to work. Once done, click Create Distribution.

You will be redirected back to distributions dashboard where you can see your created distribution and its status as In progress. This means now AWS is fetching all content files like media, CSS, JS from your domain hosting server to their edge servers. In other words, you can say your CDN zone is being deployed. Once all sync completes, its state will be changed to Deployed . This process will take time depending on how big your blog is.

Meanwhile, your distribution is being deployed you can head back to your zone file editor (probably in cPanel) and add entries for CNAME you mentioned in distribution setting (e.g. c1.kerneltalks.com)

CNAME entry

You can skip this step if you are not using custom CNAME for your Cloudfront distribution

Goto zone file editor for your domain and add CNAME entry for the custom name you used above (here c1.kerneltalks.com) and point it to the Cloudfront URL of your distribution.

Cloudfront URL of your distribution can be found under Domain Name in above distributions dashboard screenshot. It’s generally in format XXXXXXX.cloudfront.net

This will take a few mins to hours to propagate change through the internet web. You can check if it’s live on the internet by pinging your custom domain name. You should receive pingback from cloudfront.net

ping custom domain name

That’s it. You are done with your AWS configurations. Now, you need to add this custom CNAME or cloudfront.net name in W3TC settings in your WordPress admins panel.

W3TC settings

Login to the WordPress admin panel. Goto W3TC General Settings and enable CDN as per the below screenshot.

W3TC General settings CDN portion

Goto W3TC CDN settings.

Scroll down to Configuration: Objects . Select SSL support as Enabled and add your CNAME in below Replace site's hostname with:

Once done click on Test Mirror and you should see it passed. Check the below screenshot for better understanding.

W3TC CDN mirror check

If your test is not being passed, wait for some time. Make sure you can ping that CNAME as explained above and your Cloudfront distribution is deployed completely.

Check blog for Cloudfront CDN

That’s it. Your blog is serving files from Cloudfront CDN now! You can open the website in a new browser after clearing cookies. View website’s source code and look for URLs with your custom domain name (here c1.kerneltalks.com) and you will see your CSS, JS, and media files URL are not of your naked domain (here kerneltalks.com) but from CDN (i.e. c1.kerneltalks.com)!

To server files parallelly you can create more than 1 (ideally 4) distributions in the same way and add their CNAMEs in W3TC settings.

Enjoy lightning fast web pages of your blog!

How to remount filesystem in the read-write mode under Linux

Learn how to remount the file system in the read-write mode under Linux. The article also explains how to check if the file system is read-only and how to clean the file system

Re-mount filesystem as read-write

Most of the time on newly created file systems of NFS filesystems we see an error like below :

root@kerneltalks # touch file1
touch: cannot touch ‘file1’: Read-only file system

This is because the file system is mounted as read-only. In such a scenario you have to mount it in read-write mode. Before that, we will see how to check if the file system is mounted in read-only mode and then we will get to how to remount it as a read-write filesystem.

How to check if file system is read only

To confirm file system is mounted in read only mode use below command –

# cat /proc/mounts | grep datastore
/dev/xvdf /datastore ext3 ro,seclabel,relatime,data=ordered 0 0

Grep your mount point in cat /proc/mounts and observer third column which shows all options which are used in the mounted file system. Here ro denotes file system is mounted read-only.

You can also get these details using mount -v command

root@kerneltalks # mount -v |grep datastore
/dev/xvdf on /datastore type ext3 (ro,relatime,seclabel,data=ordered)

In this output. file system options are listed in braces at last column.

Re-mount file system in read-write mode

To remount file system in read-write mode use below command –

root@kerneltalks # mount -o remount,rw /datastore

root@kerneltalks # mount -v |grep datastore
/dev/xvdf on /datastore type ext3 (rw,relatime,seclabel,data=ordered)

Observe after re-mounting option ro changed to rw. Now, the file system is mounted as read-write and now you can write files in it.

Note : It is recommended to fsck file system before re mounting it.

You can check file system by running fsck on its volume.

root@kerneltalks # df -h /datastore
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda2       10G  881M  9.2G   9% /

root@kerneltalks # fsck /dev/xvdf
fsck from util-linux 2.23.2
e2fsck 1.42.9 (28-Dec-2013)
/dev/xvdf: clean, 12/655360 files, 79696/2621440 blocks

Sometimes there are some corrections that need to be made on a file system that needs a reboot to make sure there are no processes are accessing the file system.

How to list YUM repositories in RHEL / CentOS

Learn how to list YUM repositories in RHEL / CentOS. This how-to guide includes various commands along with examples to check details about repositories and their packages in Red Hat systems.

Listing YUM repo in Red Hat systems

YUM (Yellow dog Updater Modified) is a package management tool in Red Hat Linux and its variants like CentOS. In this article, we will walk you through several commands which will be useful for you to get details of YUM repositories in RHEL.

Related read :

Without any further delay, let’s see a list of commands and their example outputs.


List YUM repositories

Run command yum repolist and it will show you all repositories configured under YUM and enabled for use on that server. To view, disabled repositories or all repositories refer below section in this article.

[root@kerneltalks ~]# yum repolist
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
repo id                                                                  repo name                                                                                status
*epel/x86_64                                                             Extra Packages for Enterprise Linux 6 - x86_64                                           12,448
rhui-REGION-client-config-server-7/x86_64                                Red Hat Update Infrastructure 2.0 Client Configuration Server 7                               2
rhui-REGION-rhel-server-releases/7Server/x86_64                          Red Hat Enterprise Linux Server 7 (RPMs)                                                 17,881
rhui-REGION-rhel-server-rh-common/7Server/x86_64                         Red Hat Enterprise Linux Server 7 RH Common (RPMs)                                          231
rsawaroha                                                                rsaw aroha rpms for Fedora/RHEL6+                                                            19
repolist: 30,581

In the above output, you can see the repo list with repo id, repo name, and status. You can see we have EPEL repo configured (repo id epel/x86_64) on the server. Also, last repo rsawaroha we added for installation of xsos tool used to read sosreport.

What is the status column in yum repolist ?

Last column of yum repolist output is status which has numbers in it. You might be wondering, what is the meaning of status numbers in yum repolist?

They are a number of packages included in the respective repository! If you see a number like XXXX+N i.e. followed by + sign and another number then it means that the repository has XXXX number of packages available for installation and N number of packages are excluded.

List details of YUM repositories

Each repositories details like name, id, number of packages available, total size, link details, timestamps, etc can be viewed by using verbose mode. Use -v switch with yum repolist to view repositories details.

[root@kerneltalks ~]# yum -v repolist
Not loading "rhnplugin" plugin, as it is disabled
Loading "amazon-id" plugin
Not loading "product-id" plugin, as it is disabled
Loading "rhui-lb" plugin
Loading "search-disabled-repos" plugin
Not loading "subscription-manager" plugin, as it is disabled
Config time: 0.048
Yum version: 3.4.3
mirrorlist: https://rhui2-cds01.ap-south-1.aws.ce.redhat.com/pulp/mirror/content/dist/rhel/rhui/server/7/7Server/x86_64/supplementary/os
mirrorlist: https://rhui2-cds01.ap-south-1.aws.ce.redhat.com/pulp/mirror/content/dist/rhel/rhui/server/7/7Server/x86_64/extras/os
mirrorlist: https://rhui2-cds01.ap-south-1.aws.ce.redhat.com/pulp/mirror/content/dist/rhel/rhui/server/7/7Server/x86_64/rh-common/debug
mirrorlist: https://rhui2-cds01.ap-south-1.aws.ce.redhat.com/pulp/mirror/content/dist/rhel/rhui/server/7/7Server/x86_64/supplementary/debug
mirrorlist: https://rhui2-cds01.ap-south-1.aws.ce.redhat.com/pulp/mirror/content/dist/rhel/rhui/server/7/7Server/x86_64/rhscl/1/debug
mirrorlist: https://rhui2-cds01.ap-south-1.aws.ce.redhat.com/pulp/mirror/rhui-client-config/rhel/server/7/x86_64/os
mirrorlist: https://rhui2-cds01.ap-south-1.aws.ce.redhat.com/pulp/mirror/content/dist/rhel/rhui/server/7/7Server/x86_64/rhscl/1/source/SRPMS
mirrorlist: https://rhui2-cds01.ap-south-1.aws.ce.redhat.com/pulp/mirror/content/dist/rhel/rhui/server/7/7Server/x86_64/rhscl/1/os
mirrorlist: https://rhui2-cds01.ap-south-1.aws.ce.redhat.com/pulp/mirror/content/dist/rhel/rhui/server/7/7Server/x86_64/source/SRPMS
mirrorlist: https://rhui2-cds01.ap-south-1.aws.ce.redhat.com/pulp/mirror/content/dist/rhel/rhui/server/7/7Server/x86_64/extras/debug
mirrorlist: https://rhui2-cds01.ap-south-1.aws.ce.redhat.com/pulp/mirror/content/dist/rhel/rhui/server/7/7Server/x86_64/optional/source/SRPMS
mirrorlist: https://rhui2-cds01.ap-south-1.aws.ce.redhat.com/pulp/mirror/content/dist/rhel/rhui/server/7/7Server/x86_64/optional/debug
mirrorlist: https://rhui2-cds01.ap-south-1.aws.ce.redhat.com/pulp/mirror/content/dist/rhel/rhui/server/7/7Server/x86_64/supplementary/source/SRPMS
mirrorlist: https://rhui2-cds01.ap-south-1.aws.ce.redhat.com/pulp/mirror/content/dist/rhel/rhui/server/7/7Server/x86_64/debug
mirrorlist: https://rhui2-cds01.ap-south-1.aws.ce.redhat.com/pulp/mirror/content/dist/rhel/rhui/server/7/7Server/x86_64/optional/os
mirrorlist: https://rhui2-cds01.ap-south-1.aws.ce.redhat.com/pulp/mirror/content/dist/rhel/rhui/server/7/7Server/x86_64/extras/source/SRPMS
mirrorlist: https://rhui2-cds01.ap-south-1.aws.ce.redhat.com/pulp/mirror/content/dist/rhel/rhui/server/7/7Server/x86_64/rh-common/os
mirrorlist: https://rhui2-cds01.ap-south-1.aws.ce.redhat.com/pulp/mirror/content/dist/rhel/rhui/server/7/7Server/x86_64/rh-common/source/SRPMS
mirrorlist: https://rhui2-cds01.ap-south-1.aws.ce.redhat.com/pulp/mirror/content/dist/rhel/rhui/server/7/7Server/x86_64/os
Setting up Package Sacks
pkgsack time: 0.009
Repo-id      : epel/x86_64
Repo-name    : Extra Packages for Enterprise Linux 6 - x86_64
Repo-revision: 1515267354
Repo-updated : Sat Jan  6 19:58:06 2018
Repo-pkgs    : 12,448
Repo-size    : 11 G
Repo-metalink: https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=x86_64
  Updated    : Mon Jan  8 15:45:02 2018
Repo-baseurl : http://mirror.sjc02.svwh.net/fedora-epel/6/x86_64/ (43 more)
Repo-expire  : 21,600 second(s) (last: Mon Jan  8 19:23:12 2018)
  Filter     : read-only:present
Repo-filename: /etc/yum.repos.d/epel.repo

Repo-id      : rhui-REGION-client-config-server-7/x86_64
Repo-name    : Red Hat Update Infrastructure 2.0 Client Configuration Server 7
Repo-revision: 1509723523
Repo-updated : Fri Nov  3 15:38:43 2017
Repo-pkgs    : 2
Repo-size    : 106 k
Repo-mirrors : https://rhui2-cds01.ap-south-1.aws.ce.redhat.com/pulp/mirror/rhui-client-config/rhel/server/7/x86_64/os
Repo-baseurl : https://rhui2-cds02.ap-south-1.aws.ce.redhat.com/pulp/repos//rhui-client-config/rhel/server/7/x86_64/os/ (1 more)
Repo-expire  : 21,600 second(s) (last: Mon Jan  8 19:23:13 2018)
  Filter     : read-only:present
Repo-filename: /etc/yum.repos.d/redhat-rhui-client-config.repo

Repo-id      : rhui-REGION-rhel-server-releases/7Server/x86_64
Repo-name    : Red Hat Enterprise Linux Server 7 (RPMs)
Repo-revision: 1515106250
Repo-updated : Thu Jan  4 22:50:49 2018
Repo-pkgs    : 17,881
Repo-size    : 24 G
Repo-mirrors : https://rhui2-cds01.ap-south-1.aws.ce.redhat.com/pulp/mirror/content/dist/rhel/rhui/server/7/7Server/x86_64/os
Repo-baseurl : https://rhui2-cds01.ap-south-1.aws.ce.redhat.com/pulp/repos//content/dist/rhel/rhui/server/7/7Server/x86_64/os/ (1 more)
Repo-expire  : 21,600 second(s) (last: Mon Jan  8 19:23:13 2018)
  Filter     : read-only:present
Repo-filename: /etc/yum.repos.d/redhat-rhui.repo

Repo-id      : rhui-REGION-rhel-server-rh-common/7Server/x86_64
Repo-name    : Red Hat Enterprise Linux Server 7 RH Common (RPMs)
Repo-revision: 1513002956
Repo-updated : Mon Dec 11 14:35:56 2017
Repo-pkgs    : 231
Repo-size    : 4.5 G
Repo-mirrors : https://rhui2-cds01.ap-south-1.aws.ce.redhat.com/pulp/mirror/content/dist/rhel/rhui/server/7/7Server/x86_64/rh-common/os
Repo-baseurl : https://rhui2-cds02.ap-south-1.aws.ce.redhat.com/pulp/repos//content/dist/rhel/rhui/server/7/7Server/x86_64/rh-common/os/ (1 more)
Repo-expire  : 21,600 second(s) (last: Mon Jan  8 19:23:13 2018)
  Filter     : read-only:present
Repo-filename: /etc/yum.repos.d/redhat-rhui.repo

Repo-id      : rsawaroha
Repo-name    : rsaw aroha rpms for Fedora/RHEL6+
Repo-revision: 1507778106
Repo-updated : Thu Oct 12 03:15:06 2017
Repo-pkgs    : 19
Repo-size    : 1.4 M
Repo-baseurl : http://people.redhat.com/rsawhill/rpms
Repo-expire  : 21,600 second(s) (last: Mon Jan  8 18:02:10 2018)
  Filter     : read-only:present
Repo-filename: /etc/yum.repos.d/rsawaroha.repo

repolist: 30,581

List enabled YUM repositories

Under YUM you have the choice to enable or disable repositories. During yum operations like installation of packages only enabled repositories are scanned/contacted to perform operations.

To view only enabled repositories in YUM, use yum repolist enabled

[root@kerneltalks ~]# yum repolist enabled
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
repo id                                                                  repo name                                                                                status
*epel/x86_64                                                             Extra Packages for Enterprise Linux 6 - x86_64                                           12,448
rhui-REGION-client-config-server-7/x86_64                                Red Hat Update Infrastructure 2.0 Client Configuration Server 7                               2
rhui-REGION-rhel-server-releases/7Server/x86_64                          Red Hat Enterprise Linux Server 7 (RPMs)                                                 17,881
rhui-REGION-rhel-server-rh-common/7Server/x86_64                         Red Hat Enterprise Linux Server 7 RH Common (RPMs)                                          231
rsawaroha                                                                rsaw aroha rpms for Fedora/RHEL6+                                                            19
repolist: 30,581

List disabled YUM repositories

Similarly, you can list only disabled yum repositories as well. Use yum repolist disabled

[root@kerneltalks ~]# yum repolist disabled
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
repo id                                                                          repo name
epel-debuginfo/x86_64                                                            Extra Packages for Enterprise Linux 6 - x86_64 - Debug
epel-source/x86_64                                                               Extra Packages for Enterprise Linux 6 - x86_64 - Source
epel-testing/x86_64                                                              Extra Packages for Enterprise Linux 6 - Testing - x86_64
epel-testing-debuginfo/x86_64                                                    Extra Packages for Enterprise Linux 6 - Testing - x86_64 - Debug
epel-testing-source/x86_64                                                       Extra Packages for Enterprise Linux 6 - Testing - x86_64 - Source
rhui-REGION-rhel-server-debug-extras/7Server/x86_64                              Red Hat Enterprise Linux Server 7 Extra Debug (Debug RPMs)
rhui-REGION-rhel-server-debug-optional/7Server/x86_64                            Red Hat Enterprise Linux Server 7 Optional Debug (Debug RPMs)
rhui-REGION-rhel-server-debug-rh-common/7Server/x86_64                           Red Hat Enterprise Linux Server 7 RH Common Debug (Debug RPMs)
rhui-REGION-rhel-server-debug-rhscl/7Server/x86_64                               Red Hat Enterprise Linux Server 7 RHSCL Debug (Debug RPMs)
rhui-REGION-rhel-server-debug-supplementary/7Server/x86_64                       Red Hat Enterprise Linux Server 7 Supplementary Debug (Debug RPMs)
rhui-REGION-rhel-server-extras/7Server/x86_64                                    Red Hat Enterprise Linux Server 7 Extra(RPMs)
rhui-REGION-rhel-server-optional/7Server/x86_64                                  Red Hat Enterprise Linux Server 7 Optional (RPMs)
rhui-REGION-rhel-server-releases-debug/7Server/x86_64                            Red Hat Enterprise Linux Server 7 Debug (Debug RPMs)
rhui-REGION-rhel-server-releases-source/7Server/x86_64                           Red Hat Enterprise Linux Server 7 (SRPMs)
rhui-REGION-rhel-server-rhscl/7Server/x86_64                                     Red Hat Enterprise Linux Server 7 RHSCL (RPMs)
rhui-REGION-rhel-server-source-extras/7Server/x86_64                             Red Hat Enterprise Linux Server 7 Extra (SRPMs)
rhui-REGION-rhel-server-source-optional/7Server/x86_64                           Red Hat Enterprise Linux Server 7 Optional (SRPMs)
rhui-REGION-rhel-server-source-rh-common/7Server/x86_64                          Red Hat Enterprise Linux Server 7 RH Common (SRPMs)
rhui-REGION-rhel-server-source-rhscl/7Server/x86_64                              Red Hat Enterprise Linux Server 7 RHSCL (SRPMs)
rhui-REGION-rhel-server-source-supplementary/7Server/x86_64                      Red Hat Enterprise Linux Server 7 Supplementary (SRPMs)
rhui-REGION-rhel-server-supplementary/7Server/x86_64                             Red Hat Enterprise Linux Server 7 Supplementary (RPMs)
repolist: 0

List all configured YUM repositories

List all YUM repositories available on server.

[root@kerneltalks ~]# yum repolist all
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
repo id                                                                  repo name                                                                       status
*epel/x86_64                                                             Extra Packages for Enterprise Linux 6 - x86_64                                  enabled: 12,448
epel-debuginfo/x86_64                                                    Extra Packages for Enterprise Linux 6 - x86_64 - Debug                          disabled
epel-source/x86_64                                                       Extra Packages for Enterprise Linux 6 - x86_64 - Source                         disabled
epel-testing/x86_64                                                      Extra Packages for Enterprise Linux 6 - Testing - x86_64                        disabled
epel-testing-debuginfo/x86_64                                            Extra Packages for Enterprise Linux 6 - Testing - x86_64 - Debug                disabled
epel-testing-source/x86_64                                               Extra Packages for Enterprise Linux 6 - Testing - x86_64 - Source               disabled
rhui-REGION-client-config-server-7/x86_64                                Red Hat Update Infrastructure 2.0 Client Configuration Server 7                 enabled:      2
rhui-REGION-rhel-server-debug-extras/7Server/x86_64                      Red Hat Enterprise Linux Server 7 Extra Debug (Debug RPMs)                      disabled
rhui-REGION-rhel-server-debug-optional/7Server/x86_64                    Red Hat Enterprise Linux Server 7 Optional Debug (Debug RPMs)                   disabled
rhui-REGION-rhel-server-debug-rh-common/7Server/x86_64                   Red Hat Enterprise Linux Server 7 RH Common Debug (Debug RPMs)                  disabled
rhui-REGION-rhel-server-debug-rhscl/7Server/x86_64                       Red Hat Enterprise Linux Server 7 RHSCL Debug (Debug RPMs)                      disabled
rhui-REGION-rhel-server-debug-supplementary/7Server/x86_64               Red Hat Enterprise Linux Server 7 Supplementary Debug (Debug RPMs)              disabled
rhui-REGION-rhel-server-extras/7Server/x86_64                            Red Hat Enterprise Linux Server 7 Extra(RPMs)                                   disabled
rhui-REGION-rhel-server-optional/7Server/x86_64                          Red Hat Enterprise Linux Server 7 Optional (RPMs)                               disabled
rhui-REGION-rhel-server-releases/7Server/x86_64                          Red Hat Enterprise Linux Server 7 (RPMs)                                        enabled: 17,881
rhui-REGION-rhel-server-releases-debug/7Server/x86_64                    Red Hat Enterprise Linux Server 7 Debug (Debug RPMs)                            disabled
rhui-REGION-rhel-server-releases-source/7Server/x86_64                   Red Hat Enterprise Linux Server 7 (SRPMs)                                       disabled
rhui-REGION-rhel-server-rh-common/7Server/x86_64                         Red Hat Enterprise Linux Server 7 RH Common (RPMs)                              enabled:    231
rhui-REGION-rhel-server-rhscl/7Server/x86_64                             Red Hat Enterprise Linux Server 7 RHSCL (RPMs)                                  disabled
rhui-REGION-rhel-server-source-extras/7Server/x86_64                     Red Hat Enterprise Linux Server 7 Extra (SRPMs)                                 disabled
rhui-REGION-rhel-server-source-optional/7Server/x86_64                   Red Hat Enterprise Linux Server 7 Optional (SRPMs)                              disabled
rhui-REGION-rhel-server-source-rh-common/7Server/x86_64                  Red Hat Enterprise Linux Server 7 RH Common (SRPMs)                             disabled
rhui-REGION-rhel-server-source-rhscl/7Server/x86_64                      Red Hat Enterprise Linux Server 7 RHSCL (SRPMs)                                 disabled
rhui-REGION-rhel-server-source-supplementary/7Server/x86_64              Red Hat Enterprise Linux Server 7 Supplementary (SRPMs)                         disabled
rhui-REGION-rhel-server-supplementary/7Server/x86_64                     Red Hat Enterprise Linux Server 7 Supplementary (RPMs)                          disabled
rsawaroha                                                                rsaw aroha rpms for Fedora/RHEL6+                                               enabled:     19
repolist: 30,581

List all available packages in repositories

To list all available packages for installation from all repositories use below command –

[root@kerneltalks ~]# yum list available |more
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
Available Packages
2048-cli.x86_64                0.9.1-1.el6      epel
2048-cli-nocurses.x86_64       0.9.1-1.el6      epel
2ping.noarch                   3.2.1-2.el6      epel
389-admin.i686                 1.1.35-1.el6     epel
389-admin.x86_64               1.1.35-1.el6     epel
389-admin-console.noarch       1.1.8-1.el6      epel
389-admin-console-doc.noarch   1.1.8-1.el6      epel
389-adminutil.i686             1.1.19-1.el6     epel
389-adminutil.x86_64           1.1.19-1.el6     epel
389-adminutil-devel.i686       1.1.19-1.el6     epel
389-adminutil-devel.x86_64     1.1.19-1.el6     epel
389-console.noarch             1.1.7-1.el6      epel
389-ds.noarch                  1.2.2-1.el6      epel
389-ds-base.x86_64             1.3.6.1-24.el7_4 rhui-REGION-rhel-server-releases
389-ds-base-libs.x86_64        1.3.6.1-24.el7_4 rhui-REGION-rhel-server-releases
389-ds-console.noarch          1.2.6-1.el6      epel
389-ds-console-doc.noarch      1.2.6-1.el6      epel
389-dsgw.x86_64                1.1.11-1.el6     epel

List packages from the particular repository

yum list available command is useful to list all available packages. If you want to list packages from the particular repository then use below switches –

disablerepo="*" which will exclude all repos from scanning

enablerepo="<repo>" which will include only your desired repo to scan for packages.

[root@kerneltalks ~]# yum --disablerepo="*" --enablerepo="rsawaroha" list available
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
Available Packages
Rebooty-inspector.noarch                                                               0.3.0-1                                                                 rsawaroha
pyrite.noarch                                                                          1.0.2-1                                                                 rsawaroha
ravshello.x86_64                                                                       1.35.0-1                                                                rsawaroha
reboot-guard.x86_64                                                                    1.0.1-1                                                                 rsawaroha
rhsecapi.x86_64                                                                        1.0.1-1                                                                 rsawaroha
rhv-manage-hosts.noarch                                                                0.5-1                                                                   rsawaroha
rsar.noarch                                                                            0.1.1-1                                                                 rsawaroha
upvm.x86_64                                                                            0.10.8-1                                                                rsawaroha
valine.noarch                                                                          0.7.4-1                                                                 rsawaroha

In the above command, we listed all packages available under repo name rsawaroha

How to change timezone in Linux server (RedHat, CentOS, Ubuntu)

Learn how to change timezone in the Linux server. Understand timezone files location, configuration files, and way to change timezone using them.

Timezone configuration

This article is a beginner’s guide to change the timezone of the Linux server. Timezone is crucial for the server since the server’s native time is displayed according to timezone.

Server’s current timezone can be checked using simple date command

root@kerneltalks # date
Tue Nov  7 17:23:54 UTC 2017

In the above output, UTC (Coordinated Universal Time) is your server’s timezone. If you want to change it to match your region or application’s user’s timezone there are three ways you can do it.

If you want to change the timezone without much hassle and without messing around system files directly jump to datetimectl command option below.

How to change timezone in Linux using /etc/localtime file

/etc/localtime is the file used by the kernel to determine the timezone. If you check your current file, its a soft link to respective timezone file in /usr/share/zoneinfo directory.

root@kerneltalks # ll /etc/localtime
lrwxrwxrwx. 1 root root 25 Jul 11 16:06 /etc/localtime -> ../usr/share/zoneinfo/UTC

root@kerneltalks # ls -lrt /usr/share/zoneinfo/
total 284
-rw-r--r--.  1 root root 17722 Dec  5  2016 zone1970.tab
-rw-r--r--.  1 root root 19153 Feb 10  2017 zone.tab
-rw-r--r--.  1 root root  4445 Feb 28  2017 iso3166.tab
-rw-r--r--.  6 root root   118 Mar 21  2017 Zulu
-rw-r--r--.  2 root root  1518 Mar 21  2017 W-SU
-rw-r--r--.  1 root root  1873 Mar 21  2017 WET
-rw-r--r--.  6 root root   118 Mar 21  2017 UTC
-rw-r--r--.  6 root root   118 Mar 21  2017 Universal
-rw-r--r--.  2 root root   118 Mar 21  2017 UCT
-rw-r--r--.  3 root root  2126 Mar 21  2017 Turkey
-rw-r--r--.  2 root root   384 Mar 21  2017 Singapore
-rw-r--r--.  2 root root   517 Mar 21  2017 ROK
-rw-r--r--.  2 root root   764 Mar 21  2017 ROC
-rw-r--r--.  1 root root  2294 Mar 21  2017 PST8PDT
-rw-r--r--.  5 root root   388 Mar 21  2017 PRC
-rw-r--r--.  3 root root  3519 Mar 21  2017 posixrules
-rw-r--r--.  2 root root  3439 Mar 21  2017 Portugal
-rw-r--r--.  2 root root  2679 Mar 21  2017 Poland
-rw-r--r--.  2 root root  2047 Mar 21  2017 NZ-CHAT
-rw-r--r--.  4 root root  2434 Mar 21  2017 NZ
-rw-r--r--.  4 root root  2427 Mar 21  2017 Navajo
-rw-r--r--.  1 root root  2294 Mar 21  2017 MST7MDT
-rw-r--r--.  1 root root   118 Mar 21  2017 MST
-rw-r--r--.  1 root root  2102 Mar 21  2017 MET
-rw-r--r--.  2 root root   641 Mar 21  2017 Libya
-rw-r--r--.  2 root root   219 Mar 21  2017 Kwajalein
-rw-r--r--.  2 root root   292 Mar 21  2017 Japan
-rw-r--r--.  2 root root   481 Mar 21  2017 Jamaica
-rw-r--r--.  3 root root  8981 Mar 21  2017 Israel
-rw-r--r--.  2 root root  1690 Mar 21  2017 Iran
-rw-r--r--.  2 root root  1174 Mar 21  2017 Iceland
-rw-r--r--.  1 root root   119 Mar 21  2017 HST
-rw-r--r--.  2 root root  1175 Mar 21  2017 Hongkong
-rw-r--r--. 10 root root   118 Mar 21  2017 Greenwich
-rw-r--r--. 10 root root   118 Mar 21  2017 GMT+0
-rw-r--r--. 10 root root   118 Mar 21  2017 GMT-0
-rw-r--r--. 10 root root   118 Mar 21  2017 GMT0
-rw-r--r--. 10 root root   118 Mar 21  2017 GMT
-rw-r--r--.  7 root root  3661 Mar 21  2017 GB-Eire
-rw-r--r--.  7 root root  3661 Mar 21  2017 GB
-rw-r--r--.  1 root root  2294 Mar 21  2017 EST5EDT
-rw-r--r--.  1 root root   118 Mar 21  2017 EST
-rw-r--r--.  2 root root  3533 Mar 21  2017 Eire
-rw-r--r--.  2 root root  1946 Mar 21  2017 Egypt
-rw-r--r--.  1 root root  1876 Mar 21  2017 EET
-rw-r--r--.  2 root root  2411 Mar 21  2017 Cuba
-rw-r--r--.  1 root root  2294 Mar 21  2017 CST6CDT
-rw-r--r--.  1 root root  2102 Mar 21  2017 CET
drwxr-xr-x.  2 root root   176 Jul 11 15:57 Indian
drwxr-xr-x.  2 root root  4096 Jul 11 15:57 Africa
drwxr-xr-x.  2 root root    53 Jul 11 15:57 Mexico
drwxr-xr-x.  2 root root    59 Jul 11 15:57 Brazil
drwxr-xr-x.  6 root root  8192 Jul 11 15:57 America
drwxr-xr-x.  2 root root   161 Jul 11 15:57 Canada
drwxr-xr-x.  2 root root   187 Jul 11 15:57 Antarctica
drwxr-xr-x.  2 root root    26 Jul 11 15:57 Arctic
drwxr-xr-x.  2 root root  4096 Jul 11 15:57 Asia
drwxr-xr-x.  2 root root   196 Jul 11 15:57 Atlantic
drwxr-xr-x.  2 root root  4096 Jul 11 15:57 Australia
drwxr-xr-x.  2 root root    45 Jul 11 15:57 Chile
drwxr-xr-x.  2 root root  4096 Jul 11 15:57 Etc
drwxr-xr-x.  2 root root  4096 Jul 11 15:57 Europe
drwxr-xr-x.  2 root root   216 Jul 11 15:57 US
drwxr-xr-x.  2 root root  4096 Jul 11 15:57 Pacific
drwxr-xr-x. 18 root root  4096 Jul 11 15:57 posix
drwxr-xr-x. 18 root root  4096 Jul 11 15:57 right

Since our test server’s timezone is UTC, you can see /etc/localtime is a soft link to /usr/share/zoneinfo/UTC. To change the timezone delete existing /etc/localtime file and create a new one with a link to the desired timezone file.

root@kerneltalks #  rm /etc/localtime
rm: remove symbolic link ‘/etc/localtime’? y

root@kerneltalks # ln -s /usr/share/zoneinfo/US/Eastern /etc/localtime

root@kerneltalks # date
Tue Nov  7 12:32:19 EST 2017

You can see we have changed timezone to EST by linking new localtime file to appropriate zone file under /usr/share/zoneinfo

How to change timezone using shell variable TZ

Another way to change the timezone is to use shell variable TZ. You can do it with single line command as below :

root@kerneltalks # export TZ=Asia/Singapore

root@kerneltalks # date
Wed Nov  8 01:36:15 +08 2017

I exported the timezone variable TZ for Singapore timezone. Check the date command output. Timezone has been set to +08 which means UTC+08:00 i.e. SGT (Singapore Timezone)

But remember, this timezone setting will be available for current shell only from where you are exporting this TZ variable.

How to change timezone using /etc/timezone file

The third way to change timezone is through the use of /etc/timezone file. This is available in some distro like Ubuntu. The content of the file will be the timezone name you want to set.

root@kerneltalks # cat /etc/timezone
Etc/UTC

root@kerneltalks # date
Tue Nov  7 17:50:50 UTC 2017

You have to export the timezone variable TZ as well along with a change in /etc/timezone file. And then you can see timezone change in effect.

Change timezone using timedatectl command

You can use timedatectl command to safely change timezone when you don’t want to deal with system files and fear of messing them up.

timedatectl command used to display current timezone, list available timezones, and change timezone on the server. We have this dedicated article on timedatectl to learn this command in detail.

To change timezone of server, use timedatectl with set-timezone argument and its value.

root@kerneltalks # timedatectl set-timezone Africa/Malabo
root@kerneltalks # date
Wed Nov 15 16:59:23 WAT 2017

In the output, you can see we have changed the timezone of the server to the WAT timezone.

How to setup domain name in Linux server

Learn how to setup domain names in RedHat, Ubuntu, CentOS, Fedora like Linux servers. Also, see how to verify domain name in Linux and FQDN setup in Linux

Domain name in Linux

Many companies have an internal domain for their IT infrastructure. This needs its servers to be configured with a domain name. This will ensure all servers will have FQDN (Fully Qualified Domain Name). For example, server12 is hostname and server12.kerneltalks.com is its FQDN. In such setup, many tools, monitoring requires servers to be identified by FQDN only.

For such a scenario you have to configure the domain name for your Linux server. We will walk you through steps that need to be taken to the setup domain name on your Linux server.

First of all, check if your server is having domain name already set up or not using below command :

root@server12 # dnsdomainname
kerneltalks.com

If you get output like above then your server is configured with the domain name. If your output is blank then you have to the setup domain name for your server.

Without further delay lets jump into steps to configure domain name.

Step 1.

How to setup FQDN in Linux?

First thing to be done is add FQDN to your hostname in /etc/hosts file.

root@server12 # cat /etc/hosts
10.10.2.32    server12.kerneltalks.com server12

To confirm your FQDN, run below command :

root@server12 # hostname -f
server12.kerneltalks.com

Output should be hostname.domain name

Step 2.

Configure domain name in Red Hat RHEL, Fedora and CentOS

Add below line in /etc/sysconfig/network

DOMAINNAME=<domainname>

Add below parameter in /etc/sysctl.conf

kernel.domainname = <domainname>

Configure domain name in Ubuntu

Edit your hostname (not FQDN) in /etc/hostname file. and restart hostname service. If you see below error :

# service hostname restart
Failed to restart hostname.service: Unit hostname.service is masked.

you can set hostname using :

# hostnamectl set-hostname server12

Once done, confirm normal hostname (using hostname) and FQDN (using hostname -f)

Step 3.

Add domain in /etc/resolv.conf. This file used for setting nameservers as well.

root@server12 # cat /etc/resolv.conf
search kerneltalks.com

This addition makes sure that you can resolves hostnames within your domain.

Step 4.

Confirm that changes are working perfectly. Question is how to check the domain name of the Linux server?

Below are the commands to check hostname, FQDN, and domain name of your server.

root@server12 # hostname
server12

root@server12 # hostname -f
server12.kerneltalks.com

root@server12 #dnsdomainname
kerneltalks.com

hostname command shows your server’s hostname. hostname -f shows your FQDN. dnsdomainname command shows your domain name of the server!


How to configure nameserver in Linux

Beginners guide on how to configure nameserver in Red Hat, CentOs, Fedora, Debian, Ubuntu or Suse Linux to resolve DNS queries.

Configure nameserver in Linux

Nameserver is the DNS server to which your machine query for name resolutions.  This is pretty much important on servers facing the Internet or having an active internet connection or if your system is part of an organization where the internal domain name system is implemented for IT Infra. In this article, we will walk you through how to set up nameserver in your Linux machine

What is nameserver?

Its server which response to the queries normally domain name resolution. It’s like a phone directory, where you query name and you get phone number. Nameserver receives hostname or domain name in the query and responds back with IP address.

How to setup nameserver in Red Hat?

You  need to open file /etc/resolv.conf in a text editor like vi or nano and add your name server IP in the below format.

nameserver X.X.X.X

For example :

root@kerneltalks # cat /etc/reolv.conf
nameserver 10.10.2.56

You can use the same above same method to configure nameserver in CentOS, Debian, Fedora.

How to setup nameserver in Ubuntu?

Addition to /etc/resolv.conf file, in ubuntu, you can edit file /etc/network/interfaces with the same above said information. The format remains the same.

root@kerneltalks # cat /etc/network/interfaces
nameserver 10.10.2.56

How to configure nameserver in Suse Linux?

If you have access to Suse desktop environment i.e. GUI then you can go to YaST network settings. Navigate to ‘Hostname/DNS‘. Like below :

Suse DNS settings

Here you will be able to add name servers and click Ok to save.

Alternatively, /etc/resolv.conf is way out from command line.

5 ways to check swap on Linux

Learn 5 different ways to check swap space utilization on Linux server using free, swapon, /proc/swaps, top and vmstat/sar commands.

Check swap on linux

This is a short, handy post explaining how to check swap space on the Linux server with different commands. We already discussed about swap in few of old posts listed below :

In this post we will be seeing 5 ways to check swap space and utilization in the Linux server.

Using free command

Most of the users know this command. Using free you can check memory and swap utilization on the server in a few lines. By default, without any switch it shows numbers in kilobytes.

# free
             total       used       free     shared    buffers     cached
Mem:       1018308     191664     826644        144      13832      72652
-/+ buffers/cache:     105180     913128
Swap:         8188          0       8188

Using -h (human-readable) switch shows output values in the nearest possible (three-digit) representation.

# free -h
             total       used       free     shared    buffers     cached
Mem:          994M       191M       802M       144K        13M        74M
-/+ buffers/cache:       103M       890M
Swap:         8.0M         0B       8.0M

In the above output you can see the last row shows swap values, total, used, and free! Here swap value you see is a total of all swap devices on the system. You cant get device wise separated swap summery with this command. To view device wise summery you can use the next commands.

Using swapon command

Generally, swapon command is used to turn on swap on partition, logical volume or file. But using -s switch (summery) you can get current swap information.

# swapon -s
Filename                                Type            Size    Used    Priority
/myswapfile                             file            8188    0       -1

This command provides you output size in kilobytes. It also shows you device wise swap so that you can see device name (partition, logical volume or file), its type and how much swap it contributing to the system.

Using /proc/swaps file

Another way is to view the content of the process file /proc/swaps for the current swap config. This outputs the same content as we saw in previous command swapon -s. In fact swapon reads this file to print a summary.

# cat /proc/swaps
Filename                                Type            Size    Used    Priority
/myswapfile                             file            8188    0       -1

Output explanation is already covered above in swapon -s.

Using top command

Another popular well-known monitoring tool top can be used to view swap information. In the top output you can see the header section includes swap details.

# top
top - 02:41:33 up 13 min,  1 user,  load average: 0.00, 0.00, 0.00
Tasks:  88 total,   1 running,  87 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.6%us,  0.9%sy,  0.0%ni, 97.8%id,  0.2%wa,  0.0%hi,  0.0%si,  0.5%st
Mem:   1018308k total,   197260k used,   821048k free,    14548k buffers
Swap:     8188k total,        0k used,     8188k free,    76504k cached

Values in a row for the swap are in kilobytes. This information is also available in other advanced iterations or top alike tools like atophtop or glance.

Using vmstat or sar command

In vmstat you can see the utilization of swap like swap in and swap out but not the devices or total values of swap like we saw in previous commands.

# vmstat
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0      0 821064  14564  76500    0    0    91    17   25   31  0  1 98  0  0

It’s more of swap monitoring. You can generate reports for certain iteration with particular time intervals like sar reporting.

# sar -S 2 3
Linux 2.6.39-200.24.1.el6uek.x86_64 (testsrv2)         12/21/2016      _x86_64_        (4 CPU)

01:01:45 AM kbswpfree kbswpused  %swpused  kbswpcad   %swpcad
01:01:47 AM   8388604         0      0.00         0      0.00
01:01:49 AM   8388604         0      0.00         0      0.00
01:01:51 AM   8388604         0      0.00         0      0.00
Average:      8388604         0      0.00         0      0.00

These are 5 ways to get swap information out of your system. If you know any other methods do let us know in comments!