• VMware

    Learn about VMware virtualization for its products like vsphere ESX and ESXi, vCenter Server, VMware View, VMware P2V and many more

  • Linux

    Step by step configuration tutorials for many of the Linux services like DNS, DHCP, FTP, Samba4 etc including many tips and tricks in Red Hat Linux.

  • Database

    Learn installation and configuration of databases like Oracle, My SQL, Postgresql, etc including many other related tutorials in Linux.

  • Did you find what you needed?
    Show your support and gratitude by making a contribution!!
    Life always offers you a second chance ... Its called tomorrow !!!

    Tuesday, July 11, 2017

    How to make IO disk scheduler change reboot persistent in Linux

    I/O scheduling controls how input/output operations will be submitted to storage. There are various algorithms which can be used depending upon the end user requirement.These algorithms can help to reduce seek operations and can prioritise I/O requests.

    Choosing the best suited I/O scheduler and algorithm not only depends on the workload, but on the hardware, too. Single ATA disk systems, SSDs, RAID arrays, or network storage systems, for example, each require different tuning strategies.

    The default Io scheduling option can be validated using below file
    # cat /sys/block/sda/queue/scheduler
    noop deadline [
    cfq]

    As what I have observed on SLES the default IO scheduler is 'cfq' while for Red Hat Enterprise Linux 7 it is [deadline]. The steps of this article is validated on SLES 11 and RHEL 7

    In this article I won't convey the usage of each scheduler and algorithm, so assuming you know which scheduler serves your purpose and you want the same change to be persistent across reboot.

    By default the changes what you perform for the algorithms are only for the current session.

    Saturday, July 08, 2017

    How to find out on which core a process is running on in Linux

    There are many processes in Linux which run on single core while many will switch between different core depending upon the availability.

    With below two methods you can find if a process is continuously running on single core or if it is switching between all the available cores based on the availability.

    Method 1
    Below command can be used
    # ps -o pid,psr,time,comm -p $(pgrep -x fio)
      PID PSR     TIME COMMAND
     8453   4 00:00:00 fio
     8455   8 00:00:01 fio

    Here 'psr' column shows the last used core by the process. I have used pgrep to grep the pid of the process running by the name of 'fio'. Everytime I hit the same command I observe the processor to be changing
    # ps -o pid,psr,time,comm -p $(pgrep -x fio)
      PID
    PSR     TIME COMMAND
     8453   4 00:00:00 fio
     8455   8 00:00:03 fio


    # ps -o pid,psr,time,comm -p $(pgrep -x fio)
      PID
    PSR     TIME COMMAND
     8453  
    9 00:00:00 fio
     8455   8 00:00:03 fio

    So to monitor this for a while I can run it in a while loop, here I have used a sleep of 5 seconds which you can increase based on the requirement
    # while true; do echo -ne "`ps -o pid,psr,time,comm -p $(pgrep -x fio) `\t"; date;sleep 5;done
      PID PSR     TIME COMMAND
     8453   4 00:00:00 fio
     8455   9 00:00:07 fio  Fri Jul  7 18:47:13 IST 2017
      PID PSR     TIME COMMAND
     8453   4 00:00:00 fio
     8455   9 00:00:07 fio  Fri Jul  7 18:47:18 IST 2017
      PID PSR     TIME COMMAND
     8453   4 00:00:00 fio
     8455   9 00:00:07 fio  Fri Jul  7 18:47:23 IST 2017
      PID PSR     TIME COMMAND
     8453   4 00:00:00 fio
     8455   9 00:00:07 fio  Fri Jul  7 18:47:28 IST 2017
      PID PSR     TIME COMMAND
     8453   4 00:00:00 fio
     8455   9 00:00:07 fio  Fri Jul  7 18:47:33 IST 2017
      PID PSR     TIME COMMAND
     8453   5 00:00:00 fio
     8455   9 00:00:07 fio  Fri Jul  7 18:47:38 IST 2017

    Method 2
    'top' is a nice tool which can also give you this information.

    Execute 'top' from your terminal

    Press "f" to enter the field menu as below

    Press "J" as the menu shows which will display the last used CPU
    Hit "Enter"

    Now you should see a new column in your top command output


    I hope the article was useful.

    Related Articles:
    Understanding Load Average in Linux and when to be worried about it?
    How to run a process in background or bring to foreground in Linux
    10 examples to help you understand top command usage in Unix/Linux


    Follow the below links for more tutorials

    How to find the path of any command in Linux
    How to configure a Clustered Samba share using ctdb in Red Hat Cluster
    How to delete an iscsi-target from openfiler and Linux
    How to perform a local ssh port forwarding in Linux
    How to use yum locally without internet connection using cache?
    What is umask and how to change the default value permanently?
    Understanding Partition Scheme MBR vs GPT
    How does a successful or failed login process works in Linux
    How to find all the process accessing a file in Linux
    How to exclude multiple directories from du command in Linux
    How to configure autofs in Linux and what are its advantages?
    How to resize software raid partition in Linux
    How to configure Software RAID 1 mirroring in Linux
    How to prevent a command from getting stored in history in Linux

    Monday, July 03, 2017

    How to fix "Software selection (Source changed - please verify)"

    This is one of the most common error you will face if you are working on unattended Red Hat Linux installation where you have a customised list of Packages.



    Error:


    Solution:
    This error basically means that the list of rpms you planned on installation has one or many dependency issues hence the installation is halted unless you fix the dependency in your parent repository.

    How do we find out which dependency is giving this nightmare?
    • Connect to the GUI console of the node which is failing, for me it is VMware so I am connected to the "console"
    • Clock inside the console
    • Press "Alt+F2" to switch the console and get the shell prompt
    NOTE: Here F2 or any higher button can be used to switch between different terminals. Your installation was running on first terminal so to switch back to the installation console anytime you can press "Alt + F1"

    • Navigate to /tmp directory as it contains your anaconda logs which will help you troubleshoot the problem 
    NOTE: Once the installation succeeds these installation logs will be copied from "/tmp" to "/var/log/anaconda"

    • Open the "packaging.log" which will contain your rpm dependency check related logs
    # less packaging.log
    scroll to the last line (Press shift + G)




    As you can see there was dependency check fail for nscd rpm, now you can go back and fix this on your parent repository and restart the installation.

    I will just give some briefs on how to fix this
    • Go to your server which has the repository which is used for this installation
    # cd /export/home/iserver/linux/install/Linux/rhel7_64/ExtraPackages/
    • Copy the needed dependency glibc with the specified version inside the repo
    • Re-create the repodate using 
    # createrepo /export/home/iserver/linux/install/Linux/rhel7_64/ExtraPackages/
    Spawning worker 0 with 30 pkgs
    Workers Finished
    Saving Primary metadata
    Saving file lists metadata
    Saving other metadata
    Generating sqlite DBs
    Sqlite DBs complete

    Next restart the installation of the respective target node, things should be fine unless you have more dependency failures.

    I hope the article was helpful.


    Related Articles:
    How to save %pre installation log file after installation in Red Hat 7
    How to perform interactive kickstart installation on Red Hat

    Follow the below links for more tutorials

    Step by Step Red Hat Linux 7.0 installation (64 bit) with screenshots
    How to keep a process running after putty or terminal is closed
    How to change the MAC Address of Ethernet device in Linux?
    Step by Step CentOS 7 (64 bit) Installation Guide with Screenshots
    What is nice and how to change the priority of any process in Linux?
    How to save %pre installation log file after installation in Red Hat 7
    How to perform interactive kickstart installation on Red Hat
    How to forcefully stop and kill a process in Linux
    How to create customized bootable ISO image in RHEL/CentOS 7
    How to load modules from kernel during boot in Linux
    How to monitor network bandwidth in Linux using netperf
    How to preserve symbolic link while copying a file in Linux
    15 practical examples of rpm command usage in Linux
    Why is sudo command asking for root password in Linux
    What is umask and how to change the default value permanently?
    Understanding Partition Scheme MBR vs GPT


    Saturday, July 01, 2017

    How to reduce LVM size in Linux step by step (online without reboot)

    Do you have a node where there is a lot of free space available on some logical volume which is unused while there is a different partition which you are using is going out of space?




    In such cases you need not add extra disk to extend your volume group and your logical volume, why not we take some free space from this large lvm and extend our partition, which can be performed on the same session without reboot.

    IMPORTANT NOTE: The article shows the steps to reduce logical volume online but it is recommended to do these steps in runlevel one as there your partitions will not be used by any process, in any other run level there is a high risk that partition will be in used so you won't be able to perform these LVM operations.

    Reducing your LVM may risk in loosing the data stored in the partition so perform these steps at your own risk.
    In this article I will show you the steps to perform a LVM shrinking and using the shrinked space to extend another partition.


    If you are looking for steps to extend logical volume by adding extra disk to your node I would recommend you to follow below tutorial
    How to extend/resize Logical Volume and Volume Group in Linux

    These steps are validated on Red Hat Enterprise Linux 7

    Sunday, June 25, 2017

    How to configure yum server repository using iso dvd

    If you are not already aware of "YUM" (Yellowdog Updater, Modified) is used for installing rpms.
    Yum allows automatic updates, package and dependency management, on RPM-based distributions. Ideally yum is used to get direct updates from Red Hat Satellite Network but we can also configure it to use RHEL DVD as the source to install the rpms.

    Below steps are validated on Red Hat Enterprise Linux 7

    Mount the RHEL 7 installation dvd on a mount point
    # mount -o loop /tmp/rhel-server-7.3-x86_64-dvd.iso /mnt
    mount: /dev/loop0 is write-protected, mounting read-only

    If the DVD is mounted over virtual media
    # /mount /dev/sr0 /mnt
    Here "0" in sr0 is a variable and can vary if there is another USB/DVD mounted to the same node.

    Create a new file under /etc/yum.repos.d
    # vim /etc/yum.repos.d/rhel.repo
    [InstallMedia]
    name=Red Hat Enterprise Linux 7.3
    baseurl=file:///mnt
    gpgcheck=1
    enabled=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

    Add the above content and save the file

    You can also disable the gpgcheck by using the below config
    [InstallMedia]
    name=Red Hat Enterprise Linux 7.3
    baseurl=file:///mnt
    gpgcheck=0
    enabled=1

    Clear the related caches
    # yum clean all
    Loaded plugins: product-id, search-disabled-repos, subscription-manager
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Cleaning repos: InstallMedia
    Cleaning up everything

    List the repositories which are enabled
    # yum repolist all
    Loaded plugins: product-id, search-disabled-repos, subscription-manager
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    InstallMedia                                             | 4.1 kB  00:00:00
    (1/2): InstallMedia/group_gz                             | 136 kB  00:00:00
    (2/2): InstallMedia/primary_db                           | 3.9 MB  00:00:00
    repo id                     repo name                              status
    InstallMedia                Red Hat Enterprise Linux 7.3           enabled: 4,751
    repolist: 4,751

    Now you can start using 'yum'

    # yum install <package_name>

    Follow the below links for more tutorials

    Step by Step Red Hat Linux 7.0 installation (64 bit) with screenshots
    How to keep a process running after putty or terminal is closed
    How to change the MAC Address of Ethernet device in Linux?
    Step by Step CentOS 7 (64 bit) Installation Guide with Screenshots
    What is nice and how to change the priority of any process in Linux?
    How to save %pre installation log file after installation in Red Hat 7
    How to perform interactive kickstart installation on Red Hat
    How to forcefully stop and kill a process in Linux
    How to create customized bootable ISO image in RHEL/CentOS 7
    How to load modules from kernel during boot in Linux
    How to monitor network bandwidth in Linux using netperf
    How to preserve symbolic link while copying a file in Linux
    15 practical examples of rpm command usage in Linux
    Why is sudo command asking for root password in Linux
    What is umask and how to change the default value permanently?
    Understanding Partition Scheme MBR vs GPT

    sed: remove all leading and ending blank whitespace from a file

    Here our requirement is to remove all the whitespace from the leading and ending space per line of a file.



    Our sample file /tmp/file
       This is line one
      This is line two
             This is line three
            This is line four

    Remove all leading whitespace

    To remove all tab whitespace (This will not remove empty space)
    # sed 's/^[ ]*//g' /tmp/file
    This is line one
    This is line two
    This is line three
            This is line four

    As you see the "tab" space is still there

    To remove all leading whitespaces (including tabs)
    # sed 's/^[\t ]*//g' /tmp/file
    This is line one
    This is line two
    This is line three
    This is line four

    Remove all trailing whitespace

    To remove all trailing whitespaces (including tabs)
    # sed -i 's/[\t ]*$//g' /tmp/file

    Remove both leading and trailing whitespaces

    # sed  's/^[\t ]*//g;s/[\t ]*$//g' /tmp/file

    This is line one
    This is line two
    This is line three
    This is line four

    Here I have combined both the commands with ";"

    Follow the below links for more tutorials

    Configure Red Hat Cluster using VMware, Quorum Disk, GFS2, Openfiler
    Tutorial for Monitoring Tools SAR and KSAR with examples in Linux
    How to configure Samba 4 Secondary Domain Controller
    How to secure Apache web server in Linux using password (.htaccess)
    How to register Red Hat Linux with RHN (Red Hat Network )
    Red hat Enterprise Linux 5.5 Installation Guide (Screenshots)
    15 tips to enhance security of your Linux machine
    Why is Linux more secure than windows and any other OS
    What is the difference between "su" and "su -" in Linux?
    What is kernel-PAE in Linux?
    What is swappiness and how do we change its value?
    How to log iptables messages in different log file
    What are the s and k scripts in the etc rcx.d directories
    What is virtual memory, paging and swap space?
    10 examples to help you understand top command usage in Unix/Linux

    sed: Insert multiple lines before or after pattern match

    Our requirement is to add multiple lines after a pattern is matched in a newline which can be before or after the match based upon the requirement



    Below is our sample file /tmp/file
    This is line one
    This is line two
    This is line three
    This is line four

    Here in we have to put below content
    your text 1
    your text 2
    your text 3

    as per below requirement
    1. one line before the string is matched
    2. one line after the string is matched

    Example 1
    Here we will add our content one line before the string is matched

    Solution
    # sed '/This is line two/i\your text 1\nyour text 2\nyour text 3' /tmp/file

    This is line one
    your text 1
    your text 2
    your text 3

    This is line two
    This is line three
    This is line four

    To do in place replacement
    # sed -i '/This is line two/i\your text 1\nyour text 2\nyour text 3' /tmp/file
    Example 2
    Here we will add our content one line after the string is matched

    Solution
    # sed '/This is line two/a\your text 1\nyour text 2\nyour text 3' /tmp/file

    This is line one
    This is line two
    your text 1
    your text 2
    your text 3

    This is line three
    This is line four

    To do in place replacement
    # sed -i '/This is line two/a\your text 1\nyour text 2\nyour text 3' /tmp/file
    Example 3
    You can add your content to a file for eg create a file /tmp/mydata with our content i.e.
    your text 1
    your text 2
    your text 3

    Now you can use below 'sed' command to append the content of "mydata" to /tmp/file"
    # sed '/This is line two/r /tmp/mydata' /tmp/file

    This is line one
    This is line two
    your text 1
    your text 2
    your text 3

    This is line three
    This is line four

    To do in place replacement
    # sed -i '/This is line two/r /tmp/mydata' /tmp/file
    IMPORTANT NOTE: Do not use this unless you are very sure the command will not impact anything else, it is always recommended to take a backup of such file where you plan to do in place replacement

    Follow the below links for more tutorials

    How to find the path of any command in Linux
    How to configure a Clustered Samba share using ctdb in Red Hat Cluster
    How to delete an iscsi-target from openfiler and Linux
    How to perform a local ssh port forwarding in Linux
    How to use yum locally without internet connection using cache?
    What is umask and how to change the default value permanently?
    Understanding Partition Scheme MBR vs GPT
    How does a successful or failed login process works in Linux
    How to find all the process accessing a file in Linux
    How to exclude multiple directories from du command in Linux
    How to configure autofs in Linux and what are its advantages?
    How to resize software raid partition in Linux
    How to configure Software RAID 1 mirroring in Linux
    How to prevent a command from getting stored in history in Linux