• 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.

  • Life always offers you a second chance ... Its called tomorrow !!!

    Monday, October 26, 2015

    How to get the hardware model information in Linux

    The below commands are executed in SuSE Enterprise Linux so some of them might not work on other flavors of Linux.

    Run the below command and scroll a few lines where you should be able to see your machine's hardware model as shown below
    # dmesg | less
    (Scroll few lines and you should be able to find the hardware model)
    [    0.000000] DMI: HP ProLiant BL460c Gen9, BIOS I36 07/11/2014

    or you can execute the below command
    # dmesg | grep -i DMI
    [    0.000000] DMI 2.8 present.
    [    0.000000] DMI: HP ProLiant BL460c Gen9, BIOS I36 07/11/2014

    The below command will give you more information about your hardware including the model details
    # dmidecode -t system
    # dmidecode 2.12
    SMBIOS 2.8 present.

    Handle 0x0009, DMI type 1, 27 bytes
    System Information
            Manufacturer: HP
            Product Name: ProLiant BL460c Gen9
            Version: Not Specified
            Serial Number: SGH451XFL8
            UUID: 37373633-3230-5347-4834-353158464C38
            Wake-up Type: Power Switch
            SKU Number: 776320-B21
            Family: ProLiant

    Handle 0x008B, DMI type 32, 11 bytes
    System Boot Information
            Status: No errors detected

    You can alternatively also use 'hwinfo' command but the execution might take a while as it will collect all the information with regards to your hardware and then will dump the requested detail to STDOUT
    # hwinfo | egrep   "system.hardware.vendor|system.hardware.product"
      system.hardware.vendor = 'HP'
      system.hardware.product = 'ProLiant BL460c Gen9'


    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

    Sunday, October 25, 2015

    15 practical examples of rpm command usage in Linux

    I have written a blog explaining different fields of an rpm. To understand a rpm and all its fields follow the below link
    Understanding RPM package

    Here I have tried to summarize a list of rpm commands which can be helpful.

    1. Install a new package

    # rpm -ivh gcc-4.3-62.198.x86_64.rpm
    Preparing...                ########################################### [100%]
       1:gcc                    ########################################### [100%]

    2. Forcefully install a package

    # rpm -ivh gcc-4.3-62.198.x86_64.rpm
    Preparing...                ########################################### [100%]
            package gcc-4.3-62.198.x86_64 is already installed

    As you see since gcc rpm is already installed the installation does not completes so for such situations use should use --force switch as seen below
    # rpm -ivh gcc-4.3-62.198.x86_64.rpm --force
    Preparing...                ########################################### [100%]
       1:gcc                    ########################################### [100%]

    3. Upgrade a package

    # rpm -Uvh gcc-4.3-62.200.2.x86_64.rpm
    Preparing...                ########################################### [100%]
       1:gcc                    ########################################### [100%]

    4. Un-install a package

    To uninstall an rpm you need the exact name of the rpm which has to be installed. For eg if you have to uninstall gcc43-c++ then in case you run the below command to remove this
    # rpm -e gcc43-c
    error: package gcc43-c is not installed

    As you see you should provide complete name # rpm -e gcc-c++
    # echo $?
    0

    5. Install/Un-install a package without dependencies

    Make sure you are fully aware before you use this option since there is a probability that the package won't function properly if the dependencies are not installed. Although you can skip the same using --nodeps
    # rpm -ivh kiwi-instsource-5.05.25-616.1.x86_64.rpm
    warning: kiwi-instsource-5.05.25-616.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID d3668a00
    error: Failed dependencies:
            build is needed by kiwi-instsource-5.05.25-616.1.x86_64

    # rpm -ivh kiwi-instsource-5.05.25-616.1.x86_64.rpm --nodeps
    warning: kiwi-instsource-5.05.25-616.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID d3668a00
    Preparing...                ########################################### [100%]
       1:kiwi-instsource        ########################################### [100%]

    To remove a package you can use the same option

    # rpm -e kiwi-tools-5.05.25-616.1
    error: Failed dependencies:
            kiwi-tools >= 5.05.25 is needed by (installed) kiwi-5.05.25-616.1.x86_64

    # rpm -e kiwi-tools-5.05.25-616.1 --nodeps

    Alternatively you can also use --force along with --nodeps

    6. Display the Package's File List

    Adding -l to rpm -q tells RPM to display the list of files that are installed by the specified package or packages.
    # rpm -ql gcc
    /usr/bin/cc
    /usr/bin/gcc
    /usr/bin/gcov
    /usr/share/man/man1/cc.1.gz
    /usr/share/man/man1/gcc.1.gz
    /usr/share/man/man1/gcov.1.gz

    7. Display the Package's File List for non-installed rpm

    To check this make sure you have access to the rpm of which the content has to be checked
    # rpm -qlp squashfs-4.0-2.1.x86_64.rpm
    warning: squashfs-4.0-2.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 29b4acdd
    /usr/bin/mksquashfs
    /usr/bin/unsquashfs
    /usr/share/doc/packages/squashfs
    /usr/share/doc/packages/squashfs/CHANGES
    /usr/share/doc/packages/squashfs/PERFORMANCE.README
    /usr/share/doc/packages/squashfs/README
    /usr/share/doc/packages/squashfs/README-4.0

    8. Display Package's File List with Additional Information

    # rpm -qlv gcc
    lrwxrwxrwx 1 root root 7 Feb 21 2009 /usr/bin/cc -> gcc-4.3
    lrwxrwxrwx 1 root root 7 Feb 21 2009 /usr/bin/gcc -> gcc-4.3
    lrwxrwxrwx 1 root root 8 Feb 21 2009 /usr/bin/gcov -> gcov-4.3
    lrwxrwxrwx 1 root root 12 Feb 21 2009 /usr/share/man/man1/cc.1.gz -> gcc-4.3.1.gz
    lrwxrwxrwx 1 root root 12 Feb 21 2009 /usr/share/man/man1/gcc.1.gz -> gcc-4.3.1.gz
    lrwxrwxrwx 1 root root 13 Feb 21 2009 /usr/share/man/man1/gcov.1.gz -> gcov-4.3.1.gz

    9. Query the Package Owning <file>

    There might be a case when you know a file like /usr/bin/sudo but you are not sure which rpm is responsible for installing this file. Use -qf along with rpm command for such cases.

    NOTE: The below command is only useful if the file you are querying for is present in your machine
    # rpm -qf /usr/bin/sudo
    sudo-1.7.6p2-0.17.5

    10. Display a List of the Package's Documentation

    When -d is added to a query, we get a list of all files containing documentation for the named package or packages. This is a great way to get up to speed when you're having problems with unfamiliar software. As with -c and -l, you'll see either a simple list of filenames, or (if you've added -v) a more comprehensive list.
    # rpm -qd gawk
    /usr/share/doc/packages/gawk/AUTHORS
    /usr/share/doc/packages/gawk/COPYING
    /usr/share/doc/packages/gawk/FUTURES
    /usr/share/doc/packages/gawk/LIMITATIONS
    /usr/share/doc/packages/gawk/NEWS
    /usr/share/doc/packages/gawk/POSIX.STD
    /usr/share/doc/packages/gawk/PROBLEMS
    /usr/share/doc/packages/gawk/README
    /usr/share/info/gawk.info.gz
    /usr/share/info/gawkinet.info.gz
    /usr/share/man/man1/awk.1.gz
    /usr/share/man/man1/gawk.1.gz
    /usr/share/man/man1/igawk.1.gz
    /usr/share/man/man1/pgawk.1.gz

    11. Display the Package's List of Configuration Files

    When -c is added to an rpm -q command, RPM will display the configuration files that are part of the specified package or packages.
    # rpm -qc netcfg
    /etc/HOSTNAME
    /etc/aliases
    /etc/defaultdomain
    /etc/ethers
    /etc/exports
    /etc/ftpusers
    /etc/host.conf
    /etc/hosts
    /etc/hosts.allow
    /etc/hosts.deny
    /etc/hosts.equiv

    12. Query the Packages That Provide Capability

    RPM provides extensive support for dependencies between packages. The basic mechanism used is that a package may require what another package provides.
    # rpm -q --whatprovides gcc
    gcc-4.3-62.198

    13. Display Package Information

    # rpm -qi kernel-default-base
    Name        : kernel-default-base          Relocations: (not relocatable)
    Version     : 3.0.101                           Vendor: SUSE LINUX Products GmbH, Nuernberg, Germany
    Release     : 0.46.1                        Build Date: Wed Dec 17 09:19:54 2014
    Install Date: Fri Jun 12 05:31:11 2015         Build Host: sheep03
    Group       : System/Kernel                 Source RPM: kernel-default-3.0.101-0.46.1.nosrc.rpm
    Size        : 23896685                         License: GPL v2 only
    Signature   : RSA/8, Wed Dec 17 09:22:49 2014, Key ID e3a5c360307e3d54
    Packager    : http://bugs.opensuse.org
    URL         : http://www.kernel.org/
    Summary     : The Standard Kernel - base modules
    Description :
    The standard kernel for both uniprocessor and multiprocessor systems.

    This package contains only the base modules, required in all installs.

    Source Timestamp: 2014-12-17 12:04:10 +0100
    GIT Revision: 8356111faa769f649b6d7c8b5bcbb34fb17120aa
    GIT Branch: SLE11-SP3-CVE-2014-9322
    Distribution: SUSE Linux Enterprise 11

    14. Display Capabilities Provided by the Package

    By adding --provides to a query command, we can see the capabilities provided by one or more packages. If the package doesn't provide any capabilities, the --provides option produces no output:

    # rpm -q gcc --provides
    c_compiler
    gcc = 4.3-62.198

    15. Query All Installed Packages

    Using the -a option, you can query every package installed on your system. For example:
    # rpm -qa | grep kernel
    kernel-default-devel-3.0.76-0.11.1
    kernel-firmware-20110923-0.42.49
    kernel-source-3.0.76-0.11.1
    linux-kernel-headers-2.6.32-1.13.5
    kernel-default-3.0.101-0.46.1
    kernel-default-base-3.0.101-0.46.1
    kernel-default-extra-3.0.101-0.46.1

    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

    Friday, October 23, 2015

    Why is sudo command asking for root password in Linux

    I have written two blogs earlier to help you understand sudo configuration and its function which you can follow using the below link
    How to configure passwordless sudo for a user in Linux
    How to give permission to user to run some commands in Linux

    In this blog I will try to keep my self strictly to the point of issue. You might have noticed that at times when you try to execute a command using sudo user it prompts for root password.

    Reason:

    You can see the below line in your /etc/sudoers file
    Defaults       targetpw
    [deepak@test ~]$ sudo /etc/init.d/sshd restart
    [sudo] password for root:

    As per this configuration ask for the password of the target user i.e. root.

    Solution:

    To fix this comment out this line
    # visudo
    # Defaults targetpw

    Save and exit the file

    Next try to use sudo for executing any command
    [deepak@test ~]$ sudo /etc/init.d/sshd restart
    [sudo] password for deepak:

    Follow the below links for more tutorials


    How to configure bridged network in Oracle Virtual Box (Linux)

    I have been asked this question multiple times by many users so I guess it is best if I could write a blog on this on different types of network which can be configured inside Virtual Box and most importantly HOW.

    What is bridged networking ?

    This is for more advanced networking needs such as network simulations and running servers in a guest. When enabled, VirtualBox connects to one of your installed network cards and exchanges network packets directly, circumventing your host operating system's network stack.

    Assuming you have CentOS 6 installed on your virtual box.

    As per my current  Network configuration I have a Wireless Router to which I have connected to using my laptop.

    Router Subnet: 192.168.0.0/24
    Router Gateway: 192.168.0.1

    Open Virtual Box

    Click on "Machine" and Next select "Settings"


    Select "Network" and choose different options as shown below


    What is promiscuous mode?

    A lot can be written about this mode but to be very specific and simple promiscuous mode is a mode of operation in which every data packet transmitted can be received and read by a network adapter.
    But anyhow this should be supported by network adapter and is mostly used for network monitoring purpose.

    Click "OK" and save the configuration

    Next go to the terminal of your Linux console. Here you need to configure your IP Address with the same subnet as of your Router. In a bridged network  the VM inside the virtual box will act as a physical machine on the same LAN to which you can provide a static IP.

    Alternatively you can also configure DHCP here but this will work only if your Router is configured as DHCP server.

    To configure static ip address
    # vi /etc/sysconfig/network-scripts/ifcfg-eth1
    DEVICE="eth1"
    NM_CONTROLLED=no
    ONBOOT=yes
    HWADDR=08:00:27:8d:8b:fb
    TYPE=Ethernet
    BOOTPROTO=none
    IPADDR=192.168.0.8
    PREFIX=24
    GATEWAY=192.168.0.1
    DNS1=8.8.8.8
    DEFROUTE=yes
    IPV4_FAILURE_FATAL=yes
    IPV6INIT=no
    NAME="System eth1"
    UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
    USERCTL=no
    PEERDNS=yes

    Restart your network services to take the change affect
    # /etc/init.d/network restart
    Shutting down interface eth1:                              [  OK  ]
    Shutting down loopback interface:                          [  OK  ]
    Bringing up loopback interface:                            [  OK  ]
    Bringing up interface eth1:                                [  OK  ]

    To configure DHCP
    # vi /etc/sysconfig/network-scripts/ifcfg-eth0
    DEVICE="eth1"
    NM_CONTROLLED=no
    ONBOOT=yes
    HWADDR=08:00:27:8d:8b:fb
    TYPE=Ethernet
    BOOTPROTO=dhcp
    PREFIX=24
    DEFROUTE=yes
    IPV4_FAILURE_FATAL=yes
    IPV6INIT=no
    NAME="System eth1"
    UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
    USERCTL=no
    PEERDNS=yes

    Restart your network services to take the change affect
    # service network restart
    Shutting down interface eth1:                              [  OK  ]
    Shutting down loopback interface:                          [  OK  ]
    Bringing up loopback interface:                            [  OK  ]
    Bringing up interface eth1:
    Determining IP information for eth1... done.
       

    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

    Sunday, February 22, 2015

    How to check memory utilization for a specific process ?

    We have a no. of ways to check the overall memory usage but what if you want to monitor memory usage of some particular process.

    To show an example I am running screen utility on my machine so lets try to find the memory used by the same.

    The below command will create a screen with 50 lakhs line buffer by the name of "work"
    # screen -h 5000000 -LS work
    Once I execute this command a new screen will come up on the screen. To detach the screen press "ctrl + a + d"

    Now on the screen lets see the PID of the running screen utility
    # screen -ls
    There is a screen on:
            2598.work       (Detached)
    1 Socket in /var/run/screen/S-root.

    Here the pid for this screen utility is 2598

    Lets check the memory utilization of the same

    Method 1

    using ps command (this will show the memory utilization in percentage)
    # ps -p 2598 v
      PID TTY      STAT   TIME  MAJFL   TRS   DRS   RSS %MEM COMMAND
     2598 ?        Ss     0:03      0   354 938689 821540 42.9 SCREEN -h 5000000 -LS work

    So the screen utility is using 42.9% of my total available memory i.e. 1869 MB so screen is using 801 MB approximately.

    Method 2

    Using top command
    # top -p 2598
     PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
     2598 root      20   0  917m 802m  864 S  0.0 42.9   0:03.49 screen

    So the output is similar to what we saw using ps command and it again shows us the %age usage but again there is one more section of VIRT which tells you the virtual memory used by the screen utility.

    Basically Virtual memory is a logical combination of RAM memory and swap space which is used by running process.

    Method 3

    Run the below command using the pid of the screen utility process
    # cat  /proc/2598/status | grep -i VMSIZE
    VmSize:   939044 kB

    This will again show you the virtual memory used by the screen utility i.e. 917 MB

    To understand the difference between Physical Memory, Virtual Memory and Swap space follow the below link
    What is virtual memory, paging and swap space?


    Related Articles:
    How to clear cache memory in Linux
    How to increase Swap memory size in Linux
    What is buffers/cache in free command in Linux ?
    What is swappiness and how do we change its value?


    Follow the below links for more tutorials

    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 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 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 do a case sensitive search inside vi editor in Linux
    How does a successful or failed login process works in Linux