Month: May 2010

4 pgrep command examples in Linux/Unix

Some times it’s required for us to know what is the RAM used by an application. Suppose in your machine Apache service or Mysql service is consuming up all your RAM. So how to check it? Is there any direct command to do this? The answer to this is no. We have to use two commands to do this. Here is the way to see what is the ram used by a particular Application. To see all the process run by a particular application, We can user pgrep(process grep). #pgrep application-name Example(in Ubuntu) #pgrep apache 1946 1951 1952 1954 1955 1957 2894 To see all the memory used by a process we use pmap(process mapping ). #pmap pid-of-that-application Example : # pmap 19461946: /usr/sbin/apache2 -k start 00110000 28K r-x– /lib/tls/i686/cmov/librt-2.10.1.so 00117000 4K r—- /lib/tls/i686/cmov/librt-2.10.1.so 00118000 4K rw— /lib/tls/i686/cmov/librt-2.10.1.so 00119000 8K r-x– /usr/lib/apache2/modules/mod_auth_basic.so 0011b000 4K r—- /usr/lib/apache2/modules/mod_auth_basic.so 0011c000 4K rw— /usr/lib/apache2/modules/mod_auth_basic.so 0011d000 8K r-x– /usr/lib/apache2/modules/mod_authz_groupfile.so 0011f000 4K r—- /usr/lib/apache2/modules/mod_authz_groupfile.so 00120000 4K rw— /usr/lib/apache2/modules/mod_authz_groupfile.so 00121000 16K r-x– /usr/lib/apache2/modules/mod_deflate.so 00125000 4K r—- /usr/lib/apache2/modules/mod_deflate.so 00126000 4K rw— /usr/lib/apache2/modules/mod_deflate.so 00129000 76K r-x– /lib/tls/i686/cmov/libnsl-2.10.1.so 0013c000 4K r—- /lib/tls/i686/cmov/libnsl-2.10.1.so 0013d000 4K rw— /lib/tls/i686/cmov/libnsl-2.10.1.so 0013e000 8K rw— [ anon ] 00140000 32K r-x– /usr/lib/apache2/modules/mod_autoindex.so 00148000 4K r—- /usr/lib/apache2/modules/mod_autoindex.so 00149000 4K rw— /usr/lib/apache2/modules/mod_autoindex.so 0014a000 80K r-x– /lib/libz.so.1.2.3.3 0015e000 4K r—- /lib/libz.so.1.2.3.3 0015f000 4K rw— /lib/libz.so.1.2.3.3 00160000 8K r-x– /lib/libcom_err.so.2.1 00162000 4K r—- /lib/libcom_err.so.2.1 00163000 4K rw— /lib/libcom_err.so.2.1 00164000...

Read More

How To See Total Processes Are Running, Files Opened, Memory Used By An User?

To see all the process run by a perticular user #ps -u username u -u used to specify user name, and u at the end of the command shows you complete path of the command executed. Example #ps -u rajesh u or To see all the files opened by user #lsof | grep username Example #lsof | grep rajesh To see memory used by a perticular user #ps -u username u | awk ‘{print $2}’ Example ps -u krishna u | awk ‘{print $2}’ Now you will get all the PID’s run by user Krishna. So try to get memory usage by using pmap command. Please visit https://www.linuxnix.com for more linux admin...

Read More

How To See What Processes Are Running On Your System?

Q. I know the subject is not quite what I want to know, but there is a command to list running processes and I can’t remember what it is? There are many commands to accomplish this. Here is the list. To see all the process running on a system#ps -AExample output : PID TTY TIME CMD 1 ? 00:00:01 init 2 ? 00:00:00 kthreadd 3 ? 00:00:00 migration/0 4 ? 00:00:00 ksoftirqd/0 5 ? 00:00:00 watchdog/0 6 ? 00:00:00 migration/1 7 ? 00:00:01 ksoftirqd/1 8 ? 00:00:00 watchdog/1 9 ? 00:00:00 events/0 10 ? 00:00:00 events/1To see all the process running on a system with some more information about the executed files location.#ps -ef Example output :UID PID PPID C STIME TTY TIME CMDroot 1 0 0 20:42 ? 00:00:01 /sbin/initroot 2 0 0 20:42 ? 00:00:00 [kthreadd]root 3 2 0 20:42 ? 00:00:00 [migration/0]root 4 2 0 20:42 ? 00:00:00 [ksoftirqd/0]root 5 2 0 20:42 ? 00:00:00 [watchdog/0]root 6 2 0 20:42 ? 00:00:00 [migration/1]root 7 2 0 20:42 ? 00:00:01 [ksoftirqd/1]To see all the process in a “tree structure”#pstreeExample output : init─┬─NetworkManager─┬─pppd │ └─{NetworkManager} ├─acpid ├─apache2───6*[apache2] ├─atd ├─avahi-daemon───avahi-daemon ├─bonobo-activati───{bonobo-activati} ├─console-kit-dae───63*[{console-kit-dae}] ├─cron ├─2*[dbus-daemon] ├─2*[dbus-launch]To see all the files opened#lsof hald-addo 2384 root txt REG 8,8 22236 135896 /usr/lib/hal/hald-addon-storagehald-addo 2384 root mem REG 8,8 117152 5754 /usr/lib/libdbus-glib-1.so.2.1.0hald-addo 2384 root mem REG 8,8 30684 2537 /lib/tls/i686/cmov/librt-2.10.1.sohald-addo 2384 root mem REG...

Read More

Over 16,000 readers, Get fresh content from “The Linux juggernaut”

Email Subscribe

ABOUT ME..!

My photo
My name is Surendra Kumar Anne. I hail from Vijayawada which is cultural capital of south Indian state of Andhra Pradesh. I am a Linux evangelist who believes in Hard work, A down to earth person, Likes to share knowledge with others, Loves dogs, Likes photography. At present I work at Bank of America as Sr. Analyst Systems and Administration. You can contact me at surendra (@) linuxnix dot com.