Thursday, February 23, 2017

What is D state process and how to check ? And what is the impact of it ?



To check the d state prcoess

#ps axl | awk '$10 ~ /D/'
#ps -aux

D state occurs when  the process is in uninterruptible sleep. This state is bad, because you can't do anything with the process in D state. Fortunately, process normally remains in such state not for so long. But if you have a heap of D state processes then some logic in system is disrupt. If that is happening, the very important thing is to determine where this unlucky sleep occurs. It is easy to do with ps command with l option. WCHAN column shows the name of the kernel function where the process is sleeping:


State D means uninterruptible sleep, which usually means IO. When the IO completes the process will change state.  If you think a specific process is hung you can truss or strace it to see what it is doing. i.e.

strace -p <pid of process>

If it does nothing for a long time it is more than likely stuck.


It may nothing to do with which disk folder.

The D state process effect cpu/processor scheduling.
Theoretically, D state still occupying cpu/processor resources.
So if too many D state processes, the cpus are busy on scheduling and re-scheduling (that is why we see high system load).

So the result could be unpredictable.



How to clear D-state process ?

D-state process is nothing but uninterruptible sleep. When doing IO, the process is locked as uninterruptible so the data will not be corrupted. When IO finished, the process will not be D-sate
But for some reason the IO could not be finished or hung, then the process may stick in D. in this cases we need to reboot the server to clear  D-state process.

How to check CPU /memory of particular process ?

We can check from top command also can get it using below command


#ps -p <pid> -o %cpu


[root@linuxtechnotes ~]# ps -p 19930   -o %mem
%MEM
 0.0
[root@linuxtechnotes ~]#
[root@linuxtechnotes ~]# ps -p 19930   -o %cpu
%CPU
97.0
[root@linuxtechnotes ~]#
[root@linuxtechnotes ~]#

How to check Primary Control Domain of Ldom ?


# virtinfo -a


How to generate logs in Solaris ?


If Solaris 10,

#/opt/SUNWexplo/bin/explorer

If Solaris 11,

 #/usr/sbin/explorer

How to get multiple console connections in Solaris ? Does it possible ?

In Solaris we can get multiple Console connections.However only one must be writable and other connections are readable only .

So we cant get multiple connections with writable .

lets say their was already writable connection and you want to connect to it then how can we do that ?

LDOM :-   kill the current telnet process 

#ps -ef | grep -i telnet 
#kill -9 <process ID>

From then you can able to login to console as writable . However without killing the current process you can get the read access to console 

Physical host:-

 

 start -force /SP/console

What is alternate command for telnet to check Connectivity for destination IP and port ?

We can use below command incase telnet is not available

#ssh -v -p <port> <host to connect to>

How to check vmware tools version from command line ?


#/usr/bin/vmware-toolbox-cmd -v



[root@linuxtechnotes ~]# /usr/bin/vmware-toolbox-cmd -v
9.2.0.15626 (build-799703)
[root@linuxtechnotes ~]#
[root@linuxtechnotes ~]#
[root@linuxtechnotes ~]#

Wednesday, February 15, 2017

How to check history of user logins and reboot history ?



How to check when system was rebooted ?

#last | grep -i reboot

[root@linuxtechnotes ~]#
[root@linuxtechnotes ~]# last | grep -i reboot
reboot   system boot  2.6.32-504.el6.i Fri Feb 10 14:02 - 21:10 (5+07:08)
reboot   system boot  2.6.32-504.el6.i Sat Feb  4 06:25 - 21:10 (11+14:45)
reboot   system boot  2.6.32-504.el6.i Thu Feb  2 08:15 - 21:10 (13+12:55)
reboot   system boot  2.6.32-504.el6.i Sun Jan 29 02:42 - 21:10 (17+18:28)
[root@linuxtechnotes ~]#
[root@linuxtechnotes ~]#


How to check history of server who are all logined with time and date ?

#last 

[root@linuxtechnotes ~]# last | tail -10
root     pts/1        192.168.150.1    Thu Feb  2 16:26 - 19:22  (02:55)
root     pts/0        :0.0             Thu Feb  2 16:22 - crash (1+14:02)
root     tty1         :0               Thu Feb  2 16:22 - crash (1+14:03)
reboot   system boot  2.6.32-504.el6.i Thu Feb  2 08:15 - 21:11 (13+12:55)
root     pts/1        192.168.150.1    Sun Jan 29 20:57 - 21:45  (00:48)
linuxtec pts/0        :0.0             Sun Jan 29 15:36 - crash (3+16:39)
linuxtec tty1         :0               Sun Jan 29 15:35 - crash (3+16:39)
reboot   system boot  2.6.32-504.el6.i Sun Jan 29 02:42 - 21:11 (17+18:28)

wtmp begins Sun Jan 29 02:42:35 2017
[root@linuxtechnotes ~]#




Day to Day usage commands in LInux ?


How to know the hostname of server ?

Command "hostname" will give you the host name of  the server. from the below example linuxtechnotes is the hostname of server.

[root@linuxtechnotes ~]# hostname
linuxtechnotes
[root@linuxtechnotes ~]#

How to know the present working directory ?

command "pwd" will give you current working directory . as per below example /root is the current directory .

[root@linuxtechnotes ~]#
[root@linuxtechnotes ~]# pwd
/root
[root@linuxtechnotes ~]#

How can we know who all logined to server currently ?
#who

[root@linuxtechnotes ~]# who
linuxtechnotes tty1         2017-02-10 22:03 (:0)
linuxtechnotes pts/0        2017-02-14 22:34 (:0.0)
root     pts/1        2017-02-15 20:55 (192.168.150.1)
[root@linuxtechnotes ~]#
[root@linuxtechnotes ~]#

How to know time and date in server ?

# date

[root@linuxtechnotes ~]# date
Wed Feb 15 20:58:10 PST 2017
[root@linuxtechnotes ~]#
[root@linuxtechnotes ~]#

How to know the current shell user login ?

#whoami

[root@linuxtechnotes ~]# whoami
root
[root@linuxtechnotes ~]#
[root@linuxtechnotes ~]#



How to get calender in server ?

#cal

[root@linuxtechnotes ~]#
[root@linuxtechnotes ~]#
[root@linuxtechnotes ~]# cal
    February 2017
Su Mo Tu We Th Fr Sa
          1  2  3  4
 5  6  7  8  9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28


How to use calculator in server ?

# bc

[root@linuxtechnotes ~]# bc
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
19-5
14
^C
(interrupt) Exiting bc.

How to check current terminal ?

#tty

[root@linuxtechnotes ~]# tty
/dev/pts/1

How to check total memory and its usage ?

# free -m /free -g

[root@linuxtechnotes ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          1893        640       1253          3        130        328
-/+ buffers/cache:        180       1712
Swap:          511          0        511
[root@linuxtechnotes ~]#

How to check system uptime ?

#uptime

[root@linuxtechnotes ~]# uptime
 21:07:05 up 1 day, 18:01,  3 users,  load average: 0.00, 0.00, 0.00
[root@linuxtechnotes ~]#

How to check system kernel and Os details ?


[root@linuxtechnotes ~]# uname -a
Linux linuxtechnotes 2.6.32-504.el6.i686 #1 SMP Tue Sep 16 01:56:19 EDT 2014 i686 i686 i386 GNU/Linux
[root@linuxtechnotes ~]#
[root@linuxtechnotes ~]# uname -r
2.6.32-504.el6.i686
[root@linuxtechnotes ~]#
[root@linuxtechnotes ~]#



How to check when system was rebooted ?

#last | grep -i reboot

[root@linuxtechnotes ~]#
[root@linuxtechnotes ~]# last | grep -i reboot
reboot   system boot  2.6.32-504.el6.i Fri Feb 10 14:02 - 21:10 (5+07:08)
reboot   system boot  2.6.32-504.el6.i Sat Feb  4 06:25 - 21:10 (11+14:45)
reboot   system boot  2.6.32-504.el6.i Thu Feb  2 08:15 - 21:10 (13+12:55)
reboot   system boot  2.6.32-504.el6.i Sun Jan 29 02:42 - 21:10 (17+18:28)
[root@linuxtechnotes ~]#
[root@linuxtechnotes ~]#


How to check history of server who are all logined with time and date ?

#last 

[root@linuxtechnotes ~]# last | tail -10
root     pts/1        192.168.150.1    Thu Feb  2 16:26 - 19:22  (02:55)
root     pts/0        :0.0             Thu Feb  2 16:22 - crash (1+14:02)
root     tty1         :0               Thu Feb  2 16:22 - crash (1+14:03)
reboot   system boot  2.6.32-504.el6.i Thu Feb  2 08:15 - 21:11 (13+12:55)
root     pts/1        192.168.150.1    Sun Jan 29 20:57 - 21:45  (00:48)
linuxtec pts/0        :0.0             Sun Jan 29 15:36 - crash (3+16:39)
linuxtec tty1         :0               Sun Jan 29 15:35 - crash (3+16:39)
reboot   system boot  2.6.32-504.el6.i Sun Jan 29 02:42 - 21:11 (17+18:28)

wtmp begins Sun Jan 29 02:42:35 2017
[root@linuxtechnotes ~]#




Monday, February 13, 2017

Does the "dmesg" log will shows the time and date ?


Answer is no .we usually see lot of errros in dmesg which may not showup in syslog . But the drawback is dmesg won't show up date and time . So we are not sure on when that was happend. Whereas in syslog we can see logs with date and time .

Do we need to reboot the system in order to update the kernel package? Just to update without activating it ?


Answer is "NO". Actually In Linux we dont need to reboot the server to install any of the package .
same as in above example inorder to update/install the kernel package we dont need to reboot the system . However if you want to activate/boot into the new kernel then we need to reboot the server .

Saturday, February 11, 2017

What are all Linux Folders and its details/usage ?


1) /  (slash)   :-  

*  / is called as  root /super user .
*   It  is  parent directory for all other directories.
*  It is called as ROOT directory.
*  It is represented by forward slash(/).

2)   /root  :-

 *  /root is home directory for root user(super user)
 * It provides working environment for root user

3) /boot  :-

* /boot contains bootable files Like Grub.conf .

 4)  /usr  :-  

*  By default system software’s are installed in /usr directory.

5) /sbin  :-

* /sbin contains commands used by only Super User(root)
 
6)  /bin  :-            

* /bin contains commands used by all users and binary files.
          
7) /home :-

*  It is home directory for all local  users.
* It provides working environment for other users (other than root).

8)  /etc  :-       

* /etc contains all configuration files like 
       > /etc/passwd for all local users details               
       > /etc/sysconfig/network        uses for network file .
                 
9) /opt :-      

 * /opt is optional directory for /usr/local.
 * It contains all third party softwares.
           
10) /var :-

* /var is containing variable data like mails, log files.
           
11) /mnt  :-

* /mnt is default mount point for any partition.
* It is empty by default.
* It contains all of removable media like cdrom, pen drive

     
12)  /proc  :-

*  /proc contains all the  process files
* This folder contents are not permanent, they keep change.
* It's file contain useful information used by OS like,
         > /proc/meminfo    To check system memory details.
         >/proc/cpuinfo     To check system cpu details.
           
         
13) /dev :-

* /dev contains device files like 
       /dev/hda           for harddisk
       /dev/cdrom       for cdrom
          
14) /lib  :-       

* /lib contains library files which are used by OS.
* library files in linux are shared object files .           

15) /tmp :-

* /tmp contains all the temp files.
           
         

Friday, February 10, 2017

Is it possible to upgrade Linux Os version from 5x to 6x ? For example 5.8/5.11 versions to 6.6/6.8 ? Have you ever tried ?

Actually the answer is "NO". We cant upgrade any Linux OS version from one version to different version like from 4x to 5x or 5x to 6x.
I personally tried to install/update package using 6.8 repo on 5.11 servers , but it didnt wrok .
But you can upgrade to any version within perticular version like from 5.1 to you can directly upgrade to 5.x versions like 5.2----5.11) same like for 6x/7x.

Try comment yourself below if any ??????

Saturday, February 4, 2017

How to check Disk Performance using iostat Commands ?



Using  iostat command we can get CPU, Device and  Network Filesystem report.

# iostat -xm 2   >> using this command you can see read/write statistics in mb's as below for every 2sec.




#iostat -xm 2 6    >> This will gives performance report of 6 intervals of every 2sec's.




So As per the above examples  

            rrqm/s
                     The number of read requests merged per second that were queued to the device.

              wrqm/s
                     The number of write requests merged per second that were queued to the device.

              r/s
                     The number of read requests that were issued to the device per second.

              w/s
                     The number of write requests that were issued to the device per second.

              rMB/s
                     The number of megabytes read from the device per second.

              wMB/s
                     The number of megabytes written to the device per second.

              avgrq-sz
                     The average size (in sectors) of the requests that were issued to the device.

              avgqu-sz
                     The average queue length of the requests that were issued to the device.

              await
                     The average time (in milliseconds) for I/O requests issued to the device to be served. 

              %util 
                     Percentage of CPU time during which I/O requests were issued to the device (bandwidth                        utilization for the device). Device saturation occurs when this
                     value is close to 100%.


From the above example since we have one Deivce(sda) its ok . If we have multiple Devices how can we know which file is related to what ?

Using #lsblk Command we can find that .



Does Limits.d file overwrites to limits.conf file ?



Does limits.d will overwrite to limits.conf file ?. Below you can see how it works ?


Below you can see ulimit values setup in limits.d file for user "john" and thier is nothing in limits.conf

[root@linuxtechnotes ~]# cat /etc/security/limits.d/90-nproc.conf
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.

*          soft    nproc     1024
root       soft    nproc     unlimited

john  soft nproc 8000
john  hard nproc 8000
john  soft nofile 8000
john  hard nofile 8000

[root@linuxtechnotes ~]# su - john
[john@linuxtechnotes ~]$ ulimit -n -u
open files                      (-n) 8000
max user processes              (-u) 8000
[john@linuxtechnotes ~]$ cat /etc/security/limits.conf | tail -3
#@student        -       maxlogins       4

# End of file
[john@linuxtechnotes ~]$ whoami
john
[john@linuxtechnotes ~]$ 


Now below you can see i have setup values as 65535 in limits.conf file and 8000 in limits.d file . you can see below on which file wins 


[root@linuxtechnotes ~]# cat /etc/security/limits.d/90-nproc.conf
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.

*          soft    nproc     1024
root       soft    nproc     unlimited

john  soft nproc 8000
john  hard nproc 8000
john  soft nofile 8000
john  hard nofile 8000

[root@linuxtechnotes ~]# su - john
[john@linuxtechnotes ~]$ ulimit -n -u
open files                      (-n) 8000
max user processes              (-u) 8000
[john@linuxtechnotes ~]$ cat /etc/security/limits.conf | tail -3
#@student        -       maxlogins       4

# End of file
[john@linuxtechnotes ~]$ whoami
john
[john@linuxtechnotes ~]$ exit
logout
[root@linuxtechnotes ~]# vi /etc/security/limits.conf
[root@linuxtechnotes ~]# cat /etc/security/limits.conf | tail -5
# End of file
john soft nofile 65535
john hard nofile 65535
john soft nproc 65535
john hard nproc 65535
[root@linuxtechnotes ~]# su - john
[john@linuxtechnotes ~]$ ulimit -n -u
open files                      (-n) 8000
max user processes              (-u) 8000
[john@linuxtechnotes ~]$ whoami
john

[john@linuxtechnotes ~]$ exit



so as you see above limits.d wins . its means limits.d over writes to limits.conf file . Now Below lets try to remove the values in limits.d file and see which values reflects .


[root@linuxtechnotes ~]# cat /etc/security/limits.conf | tail -5
# End of file
john soft nofile 65535
john hard nofile 65535
john soft nproc 65535
john hard nproc 65535
[root@linuxtechnotes ~]# su - john
[john@linuxtechnotes ~]$ ulimit -n -u
open files                      (-n) 8000
max user processes              (-u) 8000
[john@linuxtechnotes ~]$ whoami
john
[john@linuxtechnotes ~]$ exit
logout
[root@linuxtechnotes ~]# cat /etc/security/limits.d/90-nproc.conf
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.

*          soft    nproc     1024
root       soft    nproc     unlimited

john  soft nproc 8000
john  hard nproc 8000
john  soft nofile 8000
john  hard nofile 8000

[root@linuxtechnotes ~]# vi /etc/security/limits.d/90-nproc.conf
[root@linuxtechnotes ~]# cat /etc/security/limits.d/90-nproc.conf
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.

*          soft    nproc     1024
root       soft    nproc     unlimited


[root@linuxtechnotes ~]# su - john
[john@linuxtechnotes ~]$ ulimit -n -u
open files                      (-n) 65535
max user processes              (-u) 65535
[john@linuxtechnotes ~]$ whoami
john

[john@linuxtechnotes ~]$