Tuesday, July 15, 2014

The useful memory commands in Linux


  • top
Monitor processes
kiennguyen@kiennguyen-OptiPlex-790:~$ top

top - 13:21:33 up 2 days,  4:23, 14 users,  load average: 0.09, 0.20, 0.20

Tasks: 278 total,   1 running, 277 sleeping,   0 stopped,   0 zombie

%Cpu(s):  1.9 us,  0.7 sy,  0.0 ni, 96.1 id,  1.3 wa,  0.0 hi,  0.0 si,  0.0 st

KiB Mem:   8054712 total,  7755744 used,   298968 free,    31392 buffers

KiB Swap:  4070396 total,   805808 used,  3264588 free,  1204956 cached

 
  PID USER      PR  NI  VIRT  RES  SHR S  %CPU %MEM    TIME+  COMMAND                                                                                                                                        

 2920 kiennguy  20   0  693m  88m  19m S   2.3  1.1  77:41.36 skype                                                                                                                                          

 3344 kiennguy  20   0 1339m 471m  21m S   2.0  6.0  40:55.79 firefox                                                                                                                                        

13202 kiennguy  20   0 3618m 1.0g  18m S   1.3 12.8  16:32.04 java                                                                                                                                           

19523 kiennguy  20   0 1041m 104m  25m S   1.3  1.3   0:26.08 chrome                                                                                                                                         

 3580 kiennguy  20   0  579m  23m 7936 S   0.7  0.3   1:58.67 gnome-terminal                                                                                                                                 

15301 kiennguy  20   0  800m  21m 7908 S   0.7  0.3   1:07.96 chromium-browse                                                                                                                                

16530 kiennguy  20   0 1001m 149m  45m S   0.7  1.9  10:47.10 chrome                                                                                                                                         

17010 kiennguy  20   0 2030m 320m 4936 S   0.7  4.1   2:15.19 java                                                                                                                                           

 1736 root      20   0  106m  952  568 S   0.3  0.0   4:37.82 ruby                                                                                                                                           

 2103 root      20   0 50056 3964  900 S   0.3  0.0   4:23.66 ruby1.8                                                                                                                                        

10324 kiennguy  20   0 3932m 1.1g 3736 S   0.3 14.1  25:23.91 java                                                                                                                                           

20346 kiennguy  20   0 1017m  95m  25m S   0.3  1.2   0:16.64 chrome
  • vmstat
Virtual memory statistics
kiennguyen@kiennguyen-OptiPlex-790:~$ vmstat
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
 1  0 847924 240864  20220 1116116    1    2    17    34   46   53  3  1 95  1
  • ulimit
Control the resources and processes available
kiennguyen@kiennguyen-OptiPlex-790:~$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 62776
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 62776
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
  • ps
Display screen shots of current running process
kiennguyen@kiennguyen-OptiPlex-790:~$ ps aux | grep tomcat
1000     10324  0.8 14.0 4027260 1131316 pts/11 Sl+ Jul14  25:28 /opt/devel/tools/jdk1.6.0_34/bin/java -Djava.util.logging.config.file=/opt/devel/tools/apache-tomcat-6.0.35/conf/logging.properties -Xshare:auto -Xms1024M -Xmx1G -XX:MaxPermSize=512M -Dexo.directory.base=/opt/devel -javaagent:/opt/devel/solr/newrelic/newrelic.jar -Dsolr.solr.home=/opt/devel/solr -Dsolr.data.dir=/opt/devel/solr/data -Dsolr.slave.url=http://localhost:8080/solr -Dsolr.master.url=http://localhost:8080/solr -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1024 -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/opt/devel/tools/apache-tomcat-6.0.35/endorsed -classpath /opt/devel/tools/apache-tomcat-6.0.35/bin/bootstrap.jar -Dcatalina.base=/opt/devel/tools/apache-tomcat-6.0.35 -Dcatalina.home=/opt/devel/tools/apache-tomcat-6.0.35 -Djava.io.tmpdir=/opt/devel/tools/apache-tomcat-6.0.35/temp org.apache.catalina.startup.Bootstrap start
1000     21485  0.0  0.0  10924   924 pts/25   S+   13:32   0:00 grep tomcat
  • kill
Kill process
kiennguyen@kiennguyen-OptiPlex-790:~$ kill -9 19523
  • iftop
Monitor the network bandwidth

No comments:

Post a Comment