Sunday, July 31, 2016

Yum commands in LINUX



Let’s assume  you need to install rpm/package    “xorg-x11-apps-7.6-6.el6.x86_64”      

[root@tst:/root]4
[root@tst:/root]4 rpm -qa | grep -i xorg-x11-apps-7.6-6.el6.x86_64       >> first step is to grep either the package installed or not .

[root@tst:/root]5 rpm -qa | grep -i xorg-x11-apps*                             >>if packages was installed  with different  version it wont show since your checking with particular version .so lets grep with just package name . nothing coming up so it means no package was installed


[root@tst:/root]7 yum install xorg-x11-apps-7.6-6.el6.x86_64      >> when you do yum install package name it will get installed if the package is available in repo.
Loaded plugins: refresh-packagekit, security, ulninfo
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package xorg-x11-apps.x86_64 0:7.6-6.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================================================================================================================================================================
Package                                                   Arch                                               Version                                                Repository                                                        Size
============================================================================================================================================================================================================================================
Installing:
xorg-x11-apps                                             x86_64                                             7.6-6.el6                                              oel6_latest_x86_64                                          276 k

Transaction Summary
============================================================================================================================================================================================================================================
Install       1 Package(s)

Total download size: 276 k
Installed size: 705 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : xorg-x11-apps-7.6-6.el6.x86_64                                                                                                                                                                                           1/1
  Verifying  : xorg-x11-apps-7.6-6.el6.x86_64                                                                                                                                                                                           1/1

Installed:
  xorg-x11-apps.x86_64 0:7.6-6.el6

Complete!

What will happen if packages is not at all installed and we are trying to do yum update with that package name ? see below

[root@tst:/root]6 yum update xorg-x11-apps-7.6-6.el6.x86_64             >> if your trying to do yum update , it won’t installed/update since nothing is already installed . yum update will works only when package was already installed and latest version is available .
Loaded plugins: refresh-packagekit, security, ulninfo
Setting up Update Process
Package(s) xorg-x11-apps-7.6-6.el6.x86_64 available, but not installed.
No Packages marked for Update

what will happen if you do yum install when its already installed ?

[root@tst:/root]8 yum install xorg-x11-apps-7.6-6.el6.x86_64      >> it will say package already installed and latest version .
Loaded plugins: refresh-packagekit, security, ulninfo
Setting up Install Process
Package xorg-x11-apps-7.6-6.el6.x86_64 already installed and latest version
Nothing to do

What will happen if you do yum update with package name ?

[root@tst:/root]9 yum update xorg-x11-apps-7.6-6.el6.x86_64   >> you can see here , when you do yum update its getting updated it means package was installed but its not latest and its getting updated to latest version .
Loaded plugins: refresh-packagekit, security, ulninfo
Setting up Update Process
Resolving Dependencies
--> Running transaction check
---> Package xorg-x11-apps.x86_64 0:7.6-6.el6 will be updated
---> Package xorg-x11-apps.x86_64 0:7.7-6.el6 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================================================================================================================================================================
Package                                                   Arch                                               Version                                                Repository                                                        Size
============================================================================================================================================================================================================================================
Updating:
xorg-x11-apps                                             x86_64                                             7.7-6.el6                                              ol6_latest_x86_64                                          276 k

Transaction Summary
============================================================================================================================================================================================================================================
Upgrade       1 Package(s)

Total download size: 276 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : xorg-x11-apps-7.7-6.el6.x86_64                                                                                                                                                                                           1/2
  Cleanup    : xorg-x11-apps-7.6-6.el6.x86_64                                                                                                                                                                                           2/2
  Verifying  : xorg-x11-apps-7.7-6.el6.x86_64                                                                                                                                                                                           1/2
  Verifying  : xorg-x11-apps-7.6-6.el6.x86_64                                                                                                                                                                                           2/2

Updated:
  xorg-x11-apps.x86_64 0:7.7-6.el6

Complete!

What will happen if you do yum update when package is already latest version ?


[root@tst:/root]12 yum update xorg-x11-apps          >> it will show as nothing marked to update . it means no new versions are available already package is to latest version .
Loaded plugins: refresh-packagekit, security, ulninfo
Setting up Update Process
No Packages marked for Update

What will happen if you do yum install if its already installed ?

[root@tst:/root]13 yum install xorg-x11-apps-7.7-6.el6.x86_64
Loaded plugins: refresh-packagekit, security, ulninfo
Setting up Install Process
Package xorg-x11-apps-7.7-6.el6.x86_64 already installed and latest version
Nothing to do

Now let’s do  remove the package and see other scenarios ..

[root@tst:/root]14 yum remove xorg-x11-apps-7.7-6.el6.x86_64
Loaded plugins: refresh-packagekit, security, ulninfo
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package xorg-x11-apps.x86_64 0:7.7-6.el6 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================================================================================================================================================================
Package                                                   Arch                                               Version                                               Repository                                                         Size
============================================================================================================================================================================================================================================
Removing:
xorg-x11-apps                                             x86_64                                             7.7-6.el6                                             @ol6_latest_x86_64                                            704 k

Transaction Summary
============================================================================================================================================================================================================================================
Remove        1 Package(s)

Installed size: 704 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Erasing    : xorg-x11-apps-7.7-6.el6.x86_64                                                                                                                                                                                           1/1
  Verifying  : xorg-x11-apps-7.7-6.el6.x86_64                                                                                                                                                                                           1/1

Removed:
  xorg-x11-apps.x86_64 0:7.7-6.el6

Complete!

Lets do yum install with bit older version

[root@tst:/root]15 yum install xorg-x11-apps-7.6-6.el6.x86_64
Loaded plugins: refresh-packagekit, security, ulninfo
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package xorg-x11-apps.x86_64 0:7.6-6.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================================================================================================================================================================
Package                                                   Arch                                               Version                                                Repository                                                        Size
============================================================================================================================================================================================================================================
Installing:
xorg-x11-apps                                             x86_64                                             7.6-6.el6                                              ol6_latest_x86_64                                       276 k

Transaction Summary
============================================================================================================================================================================================================================================
Install       1 Package(s)

Total download size: 276 k
Installed size: 705 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : xorg-x11-apps-7.6-6.el6.x86_64                                                                                                                                                                                           1/1
  Verifying  : xorg-x11-apps-7.6-6.el6.x86_64                                                                                                                                                                                           1/1

Installed:
  xorg-x11-apps.x86_64 0:7.6-6.el6


ok so package was installed but as we know its bit older version  and latest version is available in repo . then what will happen if we do just yum update ?


Complete!
[root@tst:/root]16 yum update                              >> you can see below “xorg” package getting updated though we didn’t mention about the package name . it means when we do yum update it will update all the packages to latest version as available in our repo .
Loaded plugins: refresh-packagekit, security, ulninfo
Setting up Update Process
Resolving Dependencies
--> Running transaction check
---> Package xorg-x11-apps.x86_64 0:7.6-6.el6 will be updated
---> Package xorg-x11-apps.x86_64 0:7.7-6.el6 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================================================================================================================================================================
Package                                                   Arch                                               Version                                                Repository                                                        Size
============================================================================================================================================================================================================================================
Updating:
xorg-x11-apps                                             x86_64                                             7.7-6.el6                                              ol6_latest_x86_64                                           276 k

Transaction Summary
============================================================================================================================================================================================================================================
Upgrade       1 Package(s)

Total download size: 276 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : xorg-x11-apps-7.7-6.el6.x86_64                                                                                                                                                                                           1/2
  Cleanup    : xorg-x11-apps-7.6-6.el6.x86_64                                                                                                                                                                                           2/2
  Verifying  : xorg-x11-apps-7.7-6.el6.x86_64                                                                                                                                                                                           1/2
  Verifying  : xorg-x11-apps-7.6-6.el6.x86_64                                                                                                                                                                                           2/2

Updated:
  xorg-x11-apps.x86_64 0:7.7-6.el6

Complete!
[root@tst:/root]17



Hope this helps you on how to you use yum . comment below for anything .



Sunday, July 17, 2016

MEMORY USAGE CHECK IN LINUX SYSTEMS


we can check free memory in many ways . Below are the couple of examples on how we can check .

1) free command  :-

using free command it gives current total memory allocated  and current usage including cache/buffer memory usage .

[root@tstvm ~]# free -m
             total       used       free     shared    buffers     cached
Mem:           988        194        794          0         43         49
-/+ buffers/cache:        101        887
Swap:         1983          0       1983

[root@tstvm ~]#

from the above example 

988 gb  = total memory allocated 
194 gb = current used memory 
794 gb = current free memory 

43 and 49 is buffer/cache memory .

NOTE:- Linux uses free memory for buffer/cache to keep data read/write from/to disks in memory for speed access in the future.These memory can be reclaimed in case kernel/application needs to allocation explicitly. 


2) cat /proc/meminfo


[root@tstvm ~]# cat /proc/meminfo
MemTotal:        1012548 kB
MemFree:          813080 kB
Buffers:           44428 kB
Cached:            50812 kB
SwapCached:            0 kB
Active:            67108 kB
Inactive:          44864 kB
Active(anon):      16968 kB
Inactive(anon):        4 kB
Active(file):      50140 kB
Inactive(file):    44860 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:       2031608 kB
SwapFree:        2031608 kB
Dirty:                 8 kB
Writeback:             0 kB
AnonPages:         16752 kB
Mapped:            11060 kB
Shmem:               236 kB
Slab:              64652 kB
SReclaimable:      12612 kB
SUnreclaim:        52040 kB
KernelStack:         776 kB
PageTables:         2912 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     2537880 kB
Committed_AS:     103460 kB
VmallocTotal:   34359738367 kB
VmallocUsed:      276296 kB
VmallocChunk:   34359446148 kB
HardwareCorrupted:     0 kB
AnonHugePages:         0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:        6144 kB
DirectMap2M:     1042432 kB
DirectMap1G:           0 kB
[root@tstvm ~]#




Active memory  is the amount of buffer and cache memory  has been recently used, which is not usually reclaimed
Inactive memory is  the amount of buffer and cache memory that  has not been recently used, can be reclaimed by kernel



3) TOP command :-

using  top command you can see memory/cpu usage including the current running process. you can the each process and that perticular process memory/cpu usage .



top - 07:48:08 up 21 min,  1 user,  load average: 0.00, 0.00, 0.02
Tasks:  89 total,   1 running,  88 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.0%us,  0.3%sy,  0.0%ni, 99.7%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   1012548k total,   199864k used,   812684k free,    44456k buffers
Swap:  2031608k total,        0k used,  2031608k free,    51072k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
    1 root      20   0 19356 1524 1224 S  0.0  0.2   0:01.71 init
    2 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kthreadd
    3 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0
    4 root      20   0     0    0    0 S  0.0  0.0   0:00.01 ksoftirqd/0
    5 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0
    6 root      RT   0     0    0    0 S  0.0  0.0   0:00.01 watchdog/0
    7 root      20   0     0    0    0 S  0.0  0.0   0:02.26 events/0
    8 root      20   0     0    0    0 S  0.0  0.0   0:00.00 cgroup
    9 root      20   0     0    0    0 S  0.0  0.0   0:00.00 khelper
   10 root      20   0     0    0    0 S  0.0  0.0   0:00.00 netns
   11 root      20   0     0    0    0 S  0.0  0.0   0:00.00 async/mgr
   12 root      20   0     0    0    0 S  0.0  0.0   0:00.00 pm
   13 root      20   0     0    0    0 S  0.0  0.0   0:00.01 sync_supers
   14 root      20   0     0    0    0 S  0.0  0.0   0:00.01 bdi-default
   15 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kintegrityd/0
   16 root      20   0     0    0    0 S  0.0  0.0   0:00.20 kblockd/0
   17 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kacpid
   18 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kacpi_notify
   19 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kacpi_hotplug
   20 root      20   0     0    0    0 S  0.0  0.0   0:00.03 ata/0
   21 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ata_aux
   22 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ksuspend_usbd
   23 root      20   0     0    0    0 S  0.0  0.0   0:00.17 khubd
   24 root      20   0     0    0    0 S  0.0  0.0   0:00.02 kseriod
   25 root      20   0     0    0    0 S  0.0  0.0   0:00.00 md/0
   26 root      20   0     0    0    0 S  0.0  0.0   0:00.00 md_misc/0
   27 root      20   0     0    0    0 S  0.0  0.0   0:00.00 khungtaskd
   28 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kswapd0
   29 root      25   5     0    0    0 S  0.0  0.0   0:00.00 ksmd
   30 root      39  19     0    0    0 S  0.0  0.0   0:00.00 khugepaged
   31 root      20   0     0    0    0 S  0.0  0.0   0:00.00 aio/0
   32 root      20   0     0    0    0 S  0.0  0.0   0:00.00 crypto/0
   37 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kthrotld/0
   38 root      20   0     0    0    0 S  0.0  0.0   0:00.00 pciehpd
   40 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kpsmoused
   41 root      20   0     0    0    0 S  0.0  0.0   0:00.00 usbhid_resumer
   72 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kstriped


Top Command Analysis :-


Top is the command which gives system resources details


root@localhost linuxtechnotes]# top
top - 13:31:20 up  1:37,  3 users,  load average: 0.00, 0.00, 0.00

System is uptine is 1 hour 37ms   and current time is  13.31   and current user logined is 3

load average gives 3 time intervals which are 1,5,15ms interval 

As above load average last 1min load is 0%  at last 5ms load is 0% and last 15ms load is 0%


Shift+m  will give based on top memory  utilizatoin
shift +p willl give based on top cpu utilization


NI is nice value  like priority for system resources to use

-20 to +19

-20 is top and 19 is lowest priority  which means lowest value have highest priority and highest value have lower priority 

To chnage the process priority use r option 
r  and then give process id then hit enter
its aks renice pid value then can give as needed


%mem is   % usage of memory that process using.for ex if its 90% process is using 90% of memory 
%cpu is %usage of cpu that process using. for ex if its 200% it means that process is using 2 cores of cpu








what is 404 error in linux ?


404 error is a normal error  that the webpage/URL  you were trying to reach could not be found on the server. It is a Client-side error  which means that either the page has been removed or moved and the URL was not changed accordingly, or that you typed in the URL incorrectly.

for example below webpage has been removed and no longer exist. 



if your trying to access the above webpage you will get 404 error .




same kind of 404 eror in linux you will get when your trying to access http url and yum repository .

lets say you get this error when your trying to run any "yum" command it means the repo URL which setup in your repository is no longer exists .

What commands do you use to check free memory on the linux system ?


we can check free memory in many ways . Below are the couple of examples on how we can check .

1) free command  :-

using free command it gives current total memory allocated  and current usage including cache/buffer memory usage .

[root@tstvm ~]# free -m
             total       used       free     shared    buffers     cached
Mem:           988        194        794          0         43         49
-/+ buffers/cache:        101        887
Swap:         1983          0       1983

[root@tstvm ~]#

from the above example 

988 gb  = total memory allocated 
194 gb = current used memory 
794 gb = current free memory 

43 and 49 is buffer/cache memory .

NOTE:- Linux uses free memory for buffer/cache to keep data read/write from/to disks in memory for speed access in the future.These memory can be reclaimed in case kernel/application needs to allocation explicitly. 


2) cat /proc/meminfo


[root@tstvm ~]# cat /proc/meminfo
MemTotal:        1012548 kB
MemFree:          813080 kB
Buffers:           44428 kB
Cached:            50812 kB
SwapCached:            0 kB
Active:            67108 kB
Inactive:          44864 kB
Active(anon):      16968 kB
Inactive(anon):        4 kB
Active(file):      50140 kB
Inactive(file):    44860 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:       2031608 kB
SwapFree:        2031608 kB
Dirty:                 8 kB
Writeback:             0 kB
AnonPages:         16752 kB
Mapped:            11060 kB
Shmem:               236 kB
Slab:              64652 kB
SReclaimable:      12612 kB
SUnreclaim:        52040 kB
KernelStack:         776 kB
PageTables:         2912 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     2537880 kB
Committed_AS:     103460 kB
VmallocTotal:   34359738367 kB
VmallocUsed:      276296 kB
VmallocChunk:   34359446148 kB
HardwareCorrupted:     0 kB
AnonHugePages:         0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:        6144 kB
DirectMap2M:     1042432 kB
DirectMap1G:           0 kB
[root@tstvm ~]#




Active memory  is the amount of buffer and cache memory  has been recently used, which is not usually reclaimed
Inactive memory is  the amount of buffer and cache memory that  has not been recently used, can be reclaimed by kernel



3) TOP command :-

using  top command you can see memory/cpu usage including the current running process. you can the each process and that perticular process memory/cpu usage .

top - 07:48:08 up 21 min,  1 user,  load average: 0.00, 0.00, 0.02
Tasks:  89 total,   1 running,  88 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.0%us,  0.3%sy,  0.0%ni, 99.7%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   1012548k total,   199864k used,   812684k free,    44456k buffers
Swap:  2031608k total,        0k used,  2031608k free,    51072k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
    1 root      20   0 19356 1524 1224 S  0.0  0.2   0:01.71 init
    2 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kthreadd
    3 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0
    4 root      20   0     0    0    0 S  0.0  0.0   0:00.01 ksoftirqd/0
    5 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0
    6 root      RT   0     0    0    0 S  0.0  0.0   0:00.01 watchdog/0
    7 root      20   0     0    0    0 S  0.0  0.0   0:02.26 events/0
    8 root      20   0     0    0    0 S  0.0  0.0   0:00.00 cgroup
    9 root      20   0     0    0    0 S  0.0  0.0   0:00.00 khelper
   10 root      20   0     0    0    0 S  0.0  0.0   0:00.00 netns
   11 root      20   0     0    0    0 S  0.0  0.0   0:00.00 async/mgr
   12 root      20   0     0    0    0 S  0.0  0.0   0:00.00 pm
   13 root      20   0     0    0    0 S  0.0  0.0   0:00.01 sync_supers
   14 root      20   0     0    0    0 S  0.0  0.0   0:00.01 bdi-default
   15 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kintegrityd/0
   16 root      20   0     0    0    0 S  0.0  0.0   0:00.20 kblockd/0
   17 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kacpid
   18 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kacpi_notify
   19 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kacpi_hotplug
   20 root      20   0     0    0    0 S  0.0  0.0   0:00.03 ata/0
   21 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ata_aux
   22 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ksuspend_usbd
   23 root      20   0     0    0    0 S  0.0  0.0   0:00.17 khubd
   24 root      20   0     0    0    0 S  0.0  0.0   0:00.02 kseriod
   25 root      20   0     0    0    0 S  0.0  0.0   0:00.00 md/0
   26 root      20   0     0    0    0 S  0.0  0.0   0:00.00 md_misc/0
   27 root      20   0     0    0    0 S  0.0  0.0   0:00.00 khungtaskd
   28 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kswapd0
   29 root      25   5     0    0    0 S  0.0  0.0   0:00.00 ksmd
   30 root      39  19     0    0    0 S  0.0  0.0   0:00.00 khugepaged
   31 root      20   0     0    0    0 S  0.0  0.0   0:00.00 aio/0
   32 root      20   0     0    0    0 S  0.0  0.0   0:00.00 crypto/0
   37 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kthrotld/0
   38 root      20   0     0    0    0 S  0.0  0.0   0:00.00 pciehpd
   40 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kpsmoused
   41 root      20   0     0    0    0 S  0.0  0.0   0:00.00 usbhid_resumer
   72 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kstriped