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

    Sunday, November 23, 2014

    Step by Step CentOS 7 (64 bit) Installation Guide with Screenshots

    Please follow the screenshots to understand the installation process of CentOS 7 64-bit.
    (Click on the image to enlarge the view)

    Insert the CentOS DVD and boot your machine with the cdrom. You will get the below screen.
    Select "Install CentOS 7" and Press Enter

    Next Select the Language as per your preference and click on "Continue"

    The Next screen completely new as compared to earlier releases of CentOS. Now you have to work on all the thumbnails you see on this screen one by one. So lets start by adjusting "Date and Time"

    Next you will get the below screen where you can select your continent and click on "Done"

    NOTE: I am skipping the "Language Support" and "Keyboard" as it already shows English(US) which we had opted for in the earlier options above.

    You will come back to your previous screen where you can select the next thumbnail to edit. Lets go to "Software Installation"

    Here you will find a bunch of pre-defined groups of packages which you can select as per your environment. Select any one "Base Environment" and in case you want any add ons the same can be selected from the left panel as shown below. Once selected click on "Done" to go back to the previous screen.

    Next lets configure our partition using "Installation Destination"

    Now in my case I am using simple internal datastore to install my OS. But in case you want to add any iSCSI Target, Click on "Add Disk" and add the iscsi target details. For now we will skip those details.

    Select the disk where you want to continue the installation. As you see a "check mark" is visible once I selected the disk.
    Make sure you have checked the box "I will configure partitioning" or else the image will automatically create partitions for you.
    Click on "Done"

    Saturday, November 22, 2014

    What is nice and how to change the priority of any process in Linux?

    If you want to change the priority of any process there are two things which you need to consider. There are two terms which will be used in this article i.e. NICE and PRIORITY.

    In case you haven't notice when you run top command you get two different values for any process as I have marked in different color below
      PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
     2899 root      20   0  2704 1128  868 R  0.3  0.1   0:02.26 top
        1 root      20   0  2892 1420 1200 S  0.0  0.1   0:01.29 init
    Here PR denoted PRIORITY and NI denotes NICE value where the PRIORITY range varies from 0 to 39 for any process in Linux and NICE value varies from -20 to 19.

    `nice' prints or modifies a process's "niceness", a parameter that affects whether the process is scheduled favorably.

    Syntax
    # nice [OPTION] [COMMAND [ARG]...]
    Example:
    The below command will give a nice value of -20 to 2342 PID
    # nice --20 2342
    NOTE: Use (--) to give a negative nice value and (-) to give a positive nice value

    The below command will give a nice value of 20 to 2342 PID
    # nice -20 2342
    Below comes the complicated part so please bear with me.

    How do I understand from the NICE value about the priority of the process?
    If you consider to look after NICE value to determine the priority of the process then as I said above its value ranges from -20 to 19 where
    • -20 (process has high priority and gets more resources, thus slowing down other processes)
    • 19 (process has lower priority and runs slowly itself, but has less impact on the speed of other running processes)
    So in case you want any process to be given high priority (considering the fact that other processes might get slow) you can change their priority to any negative value upto -20 which will decrease the execution time of the process and the process will complete faster comparatively.

    Let us see some real time examples

    Run a process with nice value as -20
    # time nice --20 seq 4234567 > file.txt
    real    0m2.572s
    user    0m2.519s
    sys     0m0.047s

    Deleted the file and ran the same process with nice value of +20
    # time nice -20 seq 4234567 > file.txt
    real    0m2.693s
    user    0m2.626s
    sys     0m0.059s

    As you can see the former command executed faster with a negative nice value.
    Value
    Description
    real
    It represents time taken by command to execute since its initiation to its termination
    user
    It represents the amount of time that command/program took to execute its own code
    sys
    It represents time taken by Unix to fire the command
    How do I understand from the PRIORITY value about the priority of the process?
    Again in case you consider to look at PR value for understanding the priority of the process the value ranges from 0 to 39 where
    • 0 (process has high priority and gets more resources, thus slowing down other processes)
    • 39 (process has lower priority and runs slowly itself, but has less impact on the speed of other running processes)
    Let us see some real time examples

    Run a process with positive nice value
    # time nice -20 seq 42345671 > file.txt
    real    0m27.548s
    user    0m26.091s
    sys     0m1.004s

    As you see we are running a process with nice value +20 for which the NI appears 19 and PR as 39 which means the process will have the least priority and it will give priority to other process with higher nice value to use the system resources for their execution.
    # top
      PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
     3192 root      39  19  4084  568  512 R 99.8  0.1   0:03.29 seq
        1 root      20   0  2892 1420 1200 S  0.0  0.1   0:01.29 init

    Similarly for a negative nice value
    # time nice --20 seq 42345671 > file.txt
    real    0m27.397s
    user    0m26.555s
    sys     0m0.600s

    As you see the NI value is changed to -20 for PR value of 0.
    # top
      PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
     3205 root       0 -20  4084  568  512 R 75.0  0.1   0:02.26 seq
        1 root      20   0  2892 1420 1200 S  0.0  0.1   0:01.29 init

    What would happen if I give a nice value out of range i.e. -20 to 19 to any process?
    It can happen but your system won't understand any value other than -20 to 19 and will take the default value of -20 for high priority and 19 for least priority.

    Let us see some real time examples

    Assigning a nice value of -40
    # time nice --40 seq 42345671 > file.txt
    But still as you see the system is taking the nice value as -20 which is the highest recognizable value
    # top
      PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
     3226 root       0 -20  4084  568  512 R  7.6  0.1   0:00.23 seq
     1600 root      20   0 38616 3976 3284 S  0.3  0.4   0:01.68 vmtoolsd

    Assigning a nice value of 40
    # time nice -40 seq 42345671 > file.txt
    Naah, it didn't worked either as top shows the process is using 19 as the nice value.
    # top
      PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
     3235 root      39  19  4084  568  512 R 62.0  0.1   0:01.87 seq
     2899 root      20   0  2704 1128  868 R  0.7  0.1   0:08.66 top
    So I guess I made my point.

    If you want to manually check the nice value along with the CPU and memory usage bu any process then use this command
    # ps -o pid,pcpu,pmem,ni -p 88
     PID %CPU %MEM  NI
      88  0.0  0.0 -10
    This will show you PID, %CPU,%MEM and nice value along with the process ID where 88 is the process id.

    How to change the nice value of a running process?
    In the above examples I started the process with a pre-defined nice value but what if the process is running and you want to change its nice value. For this we have another command i.e. renice

    Syntax
    # renice [-n] priority [[-p] pid ...]
    Some Examples:
    # seq 4234567112 > file.txt
    # top
      PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
     3354 root      20   0  4084  568  512 R 95.4  0.1   0:07.19 seq

    Changing the nice value to -5
    # renice -n -5 -p 3354
    3354: old priority 0, new priority -5

    # top
      PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
     3354 root      15  -5  4084  568  512 R 99.7  0.1   0:30.26 seq

    Changing the nice value to 10
    # renice -n 10 -p 3354
    3354: old priority -5, new priority 10

    # top
      PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
     3354 root      30  10  4084  568  512 R 99.1  0.1   0:51.16 seq

    Changing the nice value to -15
    # renice -n -15 -p 3354
    3354: old priority 10, new priority -15

    # top
      PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
     3354 root       5 -15  4084  568  512 R 98.0  0.1   1:12.04 seq

    How to change the nice value of any user?
    Suppose you do not want a particular user to use much of your system resource, I thoses cases you can assign low nice value so that every process started by that user will use less system resources.

    # renice -n 5 -u deepak
    500: old priority 0, new priority 5

    Execute a process by user "deepak"
    [deepak@test ~]$ seq 12345678 > file.txt
    Verify the NI value for "deepak"
    # top
      PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
     4414 deepak    25   5  4084  588  532 R 97.3  0.1   0:05.54 seq

    How to change the nice value of any user?
    The same magic can be done for any particular group as well using the below command
    # renice -n 5 -g work The above command will change the default nice value of "work" group to 5 for any process running under their ownership.

    What is the default NI value for any process?
    The default NI value is 0 and PR value is 20 for any process running under Linux.

    How to change the nice value for any user or group permanently?
    The above shown examples are terminal based hence temporary. As soon as you reboot your machine the default nice value would be applicable for the defined user.

    To make these changes permanent follow the below steps
    NOTE: You can either user PR value or NI value to set the priority. I would suggest to use NICE value
    # vi /etc/security/limits.conf
    deepak hard priority 5
    This will set hard priority for user deepak as "5"


    Related Articles:
    10 examples to help you understand top command usage in Unix/Linux
    Tutorial for Monitoring Tools SAR and KSAR with examples in Linux
    How to check all the currently running services in Linux
    How to auto start service after reboot in 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

    Tuesday, November 18, 2014

    How to use yum locally without internet connection using cache?

    yum is an short abbreviation for Yellowdog Updater Modified

    What is yum?

    yum  is  an  interactive, rpm based, package manager. It can automatically perform system updates, including dependency analysis and obsolete processing based on "repository" metadata. It can also perform installation of  new  packages,  removal  of  old packages and perform queries on the installed and/or available packages among many other commands/services.

    How to use yum without internet connection?

    By default, yum deletes downloaded data files when they are no longer needed after a successful operation. This minimizes the amount of storage space that yum uses.

    However, you can enable caching, so that the package files downloaded by yum stay in cache directories. By using cached data, you can carry out certain operations without a network connection, you can also copy packages stored in the caches and reuse them elsewhere

    yum stores temporary files in the /var/cache/yum/$basearch/$releasever/directory, where $basearch and $releasever are Yum variables refering to base architecture of the system and the release version of Red Hat Enterprise Linux.

    You can find the values for the $basearch and $releasever variables in the output of the yum version command.
    # yum version
    Loaded plugins: fastestmirror, refresh-packagekit, security
    Warning: RPMDB altered outside of yum.
    Installed: 6/i386                  1143:95f0fe20d81af24850e6364a81367b66c9f4a1e2
    Group-Installed: yum                 14:3224f04a082a6cc0af5bc42667a6c5315ca35e96
    version

    Enabling the Caches

    To retain the cache of packages after a successful installation, add the following text to the [main] section of /etc/yum.conf.
    keepcache = 1 Once you enabled caching, every yum operation may download package data from the configured repositories.
    To download and make usable all the metadata for the currently enabled yum repositories, type:
    # yum makecache
    Loaded plugins: fastestmirror, refresh-packagekit, security
    Loading mirror speeds from cached hostfile
     * base: mirrors.ispros.com.bd
     * extras: mirror.digistar.vn
     * updates: mirror.vietoss.com
    base                                                     | 3.7 kB     00:00
    base/group_gz                                            | 214 kB     00:11
    base/filelists_db                                        | 5.1 MB     07:31
    base/primary_db                                          | 3.6 MB     08:58
    base/other_db                                            | 2.2 MB     05:25
    extras                                                   | 3.3 kB     00:00
    extras/filelists_db                                      |  31 kB     00:00
    extras/prestodelta                                       |   78 B     00:00
    extras/primary_db                                        |  28 kB     00:00
    extras/other_db                                          |  35 kB     00:01
    updates                                                  | 3.4 kB     00:00
    updates/filelists_db                                     | 614 kB     00:08
    updates/prestodelta                                      |  58 kB     00:00
    updates/primary_db                                       | 800 kB     00:10
    updates/other_db                                         | 6.0 MB     00:58
    Metadata Cache Created

    This is useful if you want to make sure that the cache is fully up to date with all metadata. To set the time after which the metadata will expire, use the metadata-expire setting in /etc/yum.conf.

    From man page
    makecache: Is used to download and make usable all the metadata for the currently enabled yum repos.

    Using yum in Cache-only Mode

    To carry out a yum command without a network connection, add the -C command-line option. With this option, yum proceeds without checking any network repositories, and uses only cached files. In this mode, yum may only install packages that have been downloaded and cached by a previous operation.
    # yum -C list glibc
    Loaded plugins: fastestmirror, refresh-packagekit, security
    Installed Packages
    glibc.i686                         2.12-1.132.el6                          @base
    Available Packages
    glibc.i686                         2.12-1.149.el6                          base

    So as you see we have an update for glibc package which we can install with out internet connection using the cache by using the below command
    # yum -C update glibc

    Clearing the yum Caches

    It is often useful to remove entries accumulated in the /var/cache/yum/ directory. If you remove a package from the cache, you do not affect the copy of the software installed on your system. To remove all entries for currently enabled repositories from the cache, type the following as a root:
    # yum clean all
    I hope the tutorial was helpful.

    Related Articles:
    YUM with APACHE configuration
    Existing lock /var/run/yum.pid: another copy is running


    Follow the below links for more tutorials

    How to configure iscsi target using Red Hat Linux
    What are the different types of Virtual Web Hosting in Apache
    Comparison and Difference between VMFS 3 and VMFS 5
    How to configure PXE boot server in Linux using Red Hat 6
    How to secure Apache web server in Linux using password (.htaccess)
    How to register Red Hat Linux with RHN (Red Hat Network )
    15 tips to enhance security of your Linux machine
    How does a DNS query works when you type a URL on your browser?
    How to create password less ssh connection for multiple non-root users
    How to create user without useradd command in Linux
    How to give normal user root privileges using sudo in Linux/Unix
    How to do Ethernet/NIC bonding/teaming in Red Hat Linux
    How to install/uninstall/upgrade rpm package with/without dependencies
    Why is Linux more secure than windows and any other OS
    What is the difference between "su" and "su -" in Linux?

    What is umask and how to change the default value permanently?

    umask is a command that determines the settings of a mask that controls which file permissions are set for files and directories when they are created.

    When a user creates a file or a directory under Linux, there is a set of default permission which is applied on those files and directory. These pre-defined premissions are assigned as per the value of default umask.

    Before going ahead let me brief you out about the permission values in Linux. The permission in Linux can be set using two methods i.e.
    • Octal
    • Symbolic

    Octal method

    Using this method relative permission is provided to files and directories from a scale of 0 to 7 as per the table below
    Octal Values
    Permission
    0
    no permissions
    1
    execute only
    2
    write only
    3
    write and execute
    4
    read only
    5
    read and execute
    6
    read and write
    7
    read, write and execute

    Monday, November 17, 2014

    Understanding Partition Scheme MBR vs GPT

    In this article I will try to explain the most basic and common things about partitions and partition scheme which one should know as it will be used on your day to day life if you are a system administrator.

    To start of lets start with the most basic question

    What is a partition?
    Partition is the act of dividing a hard disk (HDD) into multiple logical storage units referred to as partitions, to treat one physical disk drive as if it were multiple disks, so that a different file system can be used on each partition.

    What are the types of partitions?
    Basically partition can be divided into two parts
    • Primary Partition
    • Extended partition
    • Logical Partition
    Now to understand more of both the types of partition you should also know about the two partition schemes available i.e.
    • Master Boot Record (MBR)
    • GUID Partition Table (GPT)

    Master Boot Record

    • MBR is a special type of boot sector at the very beginning of partitioned computer mass storage devices like fixed disks or removable drives that holds the information on how the logical partitions, containing file systems, are organized on that medium.
    • This MBR code is usually referred to as a boot loader.
    • It is the first sector of the Hard Disk with a size of 512 bytes.
    • The first 434 - 446 bytes are the primary boot loader, 64 bytes for partition table and 6 bytes for MBR validation timestamp.
    • The Partition Table, located in the master boot record, contains 16-byte entries, each of which describes a partition.
    • The organization of the partition table in the MBR limits the maximum addressable storage space of a disk to 2 TB (232 × 512 bytes)

    Primary Partition

    • The total data storage space of a PC HDD can contain at most four primary partitions, or alternatively three primary partitions and an extended partition.
    • Only one partition may be designated, at any given time, as active. That partition will be used for booting the system.
    • All Windows operating systems from Windows 95 onwards can be located on (almost) any partition, but the boot files (io.sys, bootmgr, ntldr, etc.) must reside on a primary partition.

    Extended Partition

    What if you want to have more than 4 partitions in your machine?
    • For these scenarios "Extended Partition" comes to the rescue. Now as explained with MBR scheme a maximum of 4 partitions can be created so we create 3 Primary partitions and one extended partition
    • Within the partition table in reality takes the same amount of space as primary partitions.
    • Now you can create multiple logical partition inside the extended partition.
    • Since these extended partitions are not defined inside the main MBR, they are not primary partitions, and you typically cannot boot from them

    Logical Partition

    • A logical partition is a a partition that has been created inside of an extended partition.
    • By using an extended partition you can now have up to 15 logical partitions per disk.
    To be brief limitations of MBR Partition scheme
    • Supports maximum of 4 partitions
    • Limitation of maximum disk size of 2TB
    • It uses 32 bits for storing logical block addresses and size information
    To overcome these features GPT partition scheme came into the picture so let us understand it in more detail

    GUID Partition Table

    • It is a standard for the layout of the partition table on a physical hard disk, using globally unique identifiers (GUID).
    • GPT allocates 64 bits for logical block addresses, therefore allowing a maximum disk size of 264 sectors.
    • For disks with 512-byte sectors, maximum size is 9.4 ZB (9.4 × 1021 bytes) or 8 ZiB
    • The partition contains 2 "GPT headers" one at the top of the device and another at the bottom providing a redundancy so that in case any one of the GPT headers get corrupted the partition information could be collected from the secondary header.

    • If the minimum size of 16,384 bytes is allocated for the partition entry array, and the default size of 128 bytes is used for each partition entry, then the maximum number of partitions is limited to 128.
    Related Articles:
    What is the difference between ext3 and ext4 filesystem in Linux ?
    What is the difference/comparison between Unix and Linux ?
    RAID levels 0, 1, 2, 3, 4, 5, 6, 0+1, 1+0 features explained in detail


    Follow the below links for more tutorials

    Tutorial for Monitoring Tools SAR and KSAR with examples in Linux
    How to secure Apache web server in Linux using password (.htaccess)
    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
    How to log iptables messages in different log file