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

    Tuesday, November 25, 2014

    Step by Step Red Hat Linux 7.0 installation (64 bit) with screenshots

    Here are the step by step screenshot for the installation of Red Hat Enterprise Linux 7 (64 bit). 

    The installation process is not much different as compared to "CentOS 7.0 (64-bit)" which I have explained in the below Article

    Once you insert and boot your machine with the RHEL DVD, you will get the below screen. Select "Install Red Hat Enterprise Linux 7.0" and Press "Enter".

    As you see the installation process is initiated

    Select the Language preference

    The Next screen contains almost all the configuration which has to be performed for the installation. Since we have already selected our Language and Keyboard preferences, we can skip that step here.

    Lets start by setting the Date and Time

    Select your Location as for me it is Asia/Kolkatta

    Next we will select the packages which we want to install. So Select "Software Installation" which will lead you to the below screen. In my case I will install the "Base Installation" package having "Server with GUI" and in case you want to add any extra Add On, you can select the same from the left panel as shown below.

    Next we need to configure partitions. So select "Installation Destination"

    Select the hard disk which you have used to install RHEL 7, as for my case as you can see 20GB hard drive.

    Also if you want the OS to automatically create the partition select the same or else for this article lets manually create the partitions

    You can create a partition with the below list of partition types. As for this article we will select LVM

    Click on the "+" sign to add new partition.

    For this article I will create /boot, /, swap partition under LVM with Volume Group name as "VolGroup00"

    Change the partition type to Ext4 as by default XFS will be selected for every partition you create.

    Once you change these settings make sure you "update settings"

    By default Volume Group name is "rhel". Let us change it to "VolGroup00"

    You can also configure the storage for RAID but let us skip that part as of now.

    As you see all the mount points as planned are created with below name under LVM
    VolGroup00-root
    VolGroup-swap

    Click on Done and select Accept Changes.

    The last one is to Configure Network

    Provide a hostname for your machine and enable the ethernet device. Next select Configure to configure network settings for your machine

    Change the Ethernet device name or else you can skip that part. Next configure you IP details as per your environment i.e IPv4 or IPv6. We are using IPv4 so selected the "IPv4 Settings" and added the IPNetmask,Gateway and DNS details in the same.. Click on "Done" to save the configuration and go a step back.

    So we are done here with all the options on this screen. Next we can "Begin Installation"

    As you see the installation has begun in the mean time you can add a password for your root user. Also you can create additional user by using the "User Creation" thumbnail.

    Provide a password for root account.

    Create a user.(Optional)

    In the mean time let the installation complete. Once done click on Reboot.

    Once the machine reboots, next it will prompt the below screen. Click on "License Information"

    Accept the Terms and Conditions

    Click on "Finish Configuration"

    Next you will get the Kdump configuration page.

    Let us enable the Kdump and let the machine decide the amount of memory required for the same.

    I do not want to register my system to RHN as for now,also we can perform this step later so let us skip this part for now.

    Next you get your Login Screen which means we have successfully installed our Operation System i.e. RHEL 7.0 (64 bit).

    Related Article:
    Red hat Enterprise Linux 5.5 Installation Guide (Screenshots)

    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, November 24, 2014

    How to keep a process running after putty or terminal is closed

    There can be many times where you are suppose to run some application or process in Linux but you don not want it to be terminated by logoff and session disconnection from putty.

    nohup command

    `nohup' runs the given COMMAND with hangup signals ignored, so that the command can continue running in the background after you log out.

    Syntax
    # nohup COMMAND [ARG]...
    If standard input is a terminal, it is redirected from `/dev/null' so that terminal sessions do not mistakenly consider the terminal to be used by the command.

    If standard output is a terminal, the command's standard output is appended to the file `nohup.out'; if that cannot be written to, it is appended to the file `$HOME/nohup.out'; and if that cannot be written to, the command is not run.  Any `nohup.out' or `$HOME/nohup.out' file created by `nohup' is made readable and writable only to the user, regardless of the current umask settings.

    If standard error is a terminal, it is normally redirected to the same file descriptor as the (possibly-redirected) standard output. However, if standard output is closed, standard error terminal output is instead appended to the file `nohup.out' or `$HOME/nohup.out' as above.

    For Example:
    In this case the output is appended to ~/nohup.out file
    # nohup less /var/log/messages
    nohup: ignoring input and appending output to `nohup.out'

    NOTE: nohup does not automatically put the command it runs in the background; you must do that explicitly, by ending the command line with an `&'.

    You can supress this message and restrict the command from producing or saving any output to nohup.out using the below commands and redirection
    # nohup seq 1223434 > file.txt </dev/null &>/dev/null &
    [1] 3185

    OR
    # nohup seq 1234568 > file.txt 2>&1  &
    [1] 3184

    OR# nohup seq 1234568 > file.txt 2>/dev/null  &
    [1] 3192


    Stadard in, out and err
    There are three standard sources of input and output for a program. The program usually prints to standard output, and sometimes prints to standard error. These three file descriptors (you can think of them as “data pipes”) are often called STDIN, STDOUT, and STDERR.

    Sometimes they’re not named, they’re numbered! The built-in numberings for them are 0, 1, and 2 for STDIN, STDOUT and STDERR respectively.

    disown command

    You can also use this command to run any process without any disruption of active terminal or session

    If run without any options disown removes the JobID from the list of active jobs. As for now lets see how it can run any process in the background even after the terminal is closed or logged off.

    Run a process in background
    # seq 1223434232 > file.txt &
    [1] 3879

    # disown -h 3879
    # top
      PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
     3879 root      20   0  4084  564  512 R 99.0  0.1   0:23.00 seq

    After this I disconnected my complete session and re-logged in to verify if my process is still running
    # top
      PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
     3879 root      20   0  4084  564  512 R 99.9  0.1   1:01.11 seq

    And yes its still in the running status.

    If you use disown command without any switch it will remove all the stopped jobs.

    For Example
    If any of your running process which is stopped by using (Ctrl + Z) can be seen by using
    # jobs
    [1]   Running                 seq 122354332 > file.txt &
    [2]-  Running                 seq 17653434232 > file.txt &
    [3]+  Stopped                 seq 127564232 > file.txt

    Run the disown command without any argument by default it will delete the last stopped processes which in our case is (3)
    # disown
    -bash: warning: deleting stopped job 3 with process group 3896

    In case you want to delete a particular stopped job
    # disown %3
    -bash: warning: deleting stopped job 3 with process group 3904

    To delete all the stopped jobs
    # disown -a
    -bash: warning: deleting stopped job 1 with process group 3915
    -bash: warning: deleting stopped job 2 with process group 3916
    -bash: warning: deleting stopped job 3 with process group 3917
    -bash: warning: deleting stopped job 4 with process group 3918


    Related Articles:
    10 examples to help you understand top command usage in Unix/Linux
    How to run a process in background or bring to foreground in Linux
    How to run any script or cron job in Linux for every second

    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

    How to change the MAC Address of Ethernet device in Linux?

    In case you have added a new ethernet device to your machine or server, How would you determine the new MAC Address and update the same to its relative configuration file?

    You can check for the MAC address of an ethernet card using below command
    # ifconfig
    eth0      Link encap:Ethernet  HWaddr 00:0C:29:A3:F5:E6
              inet addr:192.168.1.6  Bcast:192.168.1.255  Mask:255.255.255.0
              inet6 addr: fe80::20c:29ff:fea3:f5e6/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:356 errors:0 dropped:0 overruns:0 frame:0
              TX packets:322 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:38162 (37.2 KiB)  TX bytes:59986 (58.5 KiB)
              Interrupt:19 Base address:0x2024

    But this command will show the MAC details of configured ethernet device. In case you have added a new ethernet card, ifconfig won't show the output of that new device

    To get the same for new ethernet card use the below command
    # ip link
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
        link/ether 00:0c:29:a3:f5:e6 brd ff:ff:ff:ff:ff:ff
    3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
        link/ether 00:0c:29:a3:f5:f0 brd ff:ff:ff:ff:ff:ff
    4: pan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN
        link/ether 3e:ef:ea:16:07:bc brd ff:ff:ff:ff:ff:ff

    As you see it is showing the MAC details of all the connected ethernet cards

    You can aslo verify the same from the below file
    # grep eth1 /etc/udev/rules.d/70-persistent-net.rules
    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:a3:f5:f0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

    In case you don't know the device name lookout for the newly added device by viewing the file
    # less /etc/udev/rules.d/70-persistent-net.rules
    # PCI device 0x1022:0x2000 (vmxnet) (custom name provided by external tool)
    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:a3:f5:e6", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

    # PCI device 0x1022:0x2000 (vmxnet)
    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:a3:f5:f0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

    Next once you know the Hardware Address of your ethernet device update the same in the configuration file

    You can learn how to create or configure network in Red Hat Linux using the below link
    How to configure network in Red Hat 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

    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