Pages

Monday, June 30, 2014

how to delete a speacial character from last line

Please use the below command to delete special character from the last line of grep output

rev | cut -c 2- | rev

Thursday, June 5, 2014

Adding SWAP space

First method : on hard disk

create a new filesystem

# mkswap /dev/sdc1
swapon /dev/sdc1
# vim /etc/fstab
/dev/sdc1               swap                    swap    defaults        0 0
# swapon -s
Filename                        Type            Size    Used    Priority
/dev/sda2                       partition       4192956 0       -1
/dev/sdc1                       partition       1048568 0       -2

# free -k
             total       used       free     shared    buffers     cached
Mem:       3082356    3022364      59992          0      52056    2646472
-/+ buffers/cache:     323836    2758520
Swap:      5241524          0    5241524
The SWAP sizer formula : if RAM is < 8 GB , SWAP should be equal to 8GB
If RAM is > 8 GB, the SWAP is half of the RAM size

How to check which process is using more memory in linux server

1. ps -eo pmem,pcpu,vsize,pid,cmd | sort -k 1 -nr | head -5

2. use top command

then SHIFT + f button in the keyboard

Press the Letter corresponding to %MEM

Then press ENTER

3. ps aux | awk '{print $2, $4, $11}' | sort -k2rn | head -n 10

4. ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS