
Terminal - Commands using ps - 244 results
ps aux | grep [h]ttpd | cat -n
This is sample output - yours may be different.
If you're on a system that doesn't have nl, you can use cat -n.
ps aux | grep [a]pache2 | nl
This is sample output - yours may be different.
1 root 2459 0.0 0.4 24068 7408 ? Ss Dec09 0:00 /usr/sbin/apache2 -k start
2 www-data 5191 0.0 0.5 26312 10068 ? S Dec11 4:28 /usr/sbin/apache2 -k start
3 www-data 5909 0.0 0.5 26312 10064 ? S Dec11 4:02 /usr/sbin/apache2 -k start
4 www-data 5991 0.0 0.5 26312 10252 ? S Dec11 4:05 /usr/sbin/apache2 -k start
...
98 www-data 12931 0.0 0.4 25144 8308 ? S 13:28 0:00 /usr/sbin/apache2 -k start
99 www-data 12932 0.0 0.4 25144 8312 ? S 13:28 0:00 /usr/sbin/apache2 -k start
100 www-data 12933 0.0 0.4 25144 8316 ? S 13:28 0:00 /usr/sbin/apache2 -k start
Write each FILE to standard output, with line numbers added. With no FILE, or when FILE is -, read standard input.
ps ax| awk '/[h]ttpd/{print $1}'| xargs kill -9
This is sample output - yours may be different.
ps aux| grep -v grep| grep httpd| awk {'print $2'}| xargs kill -9
This is sample output - yours may be different.
ps -o thcount -p <process id>
This is sample output - yours may be different.
psu(){ command ps -Hcl -F S f -u ${1:-$USER}; }
This is sample output - yours may be different.
$ psu askapache
F S PID PPID CLS PRI ADDR SZ WCHAN RSS PSR TTY CMD
5 S 4111 4099 TS 19 - 1790 poll_s 1556 0 ? sshd: [email protected]/0
0 S 4121 4111 TS 19 - 743 wait 1792 3 pts/0 \_ -bash
0 R 22083 4121 TS 19 - 641 - 824 0 pts/0 \_ ps -Hcl -F S f -u askapache
$ psu root
4 S 1 0 TS 19 - 486 poll_s 372 0 ? init [2]
1 S 7007 1 TS 19 - 690 poll_s 1104 1 ? /sbin/syslog-ng -p /var/run/syslog-ng.pid
5 S 7015 1 TS 19 - 1076 poll_s 852 0 ? /usr/sbin/sshd
4 S 4099 7015 TS 19 - 1720 unix_s 2160 0 ? \_ sshd: askapache [priv]
4 S 22256 7015 TS 19 - 1076 sk_wai 1848 1 ? \_ sshd: [accepted]
ps -ec -o command,rss | grep Stainless | awk -F ' ' '{ x = x + $2 } END { print x/(1024) " MB."}'
This is sample output - yours may be different.
Adds up the total memory used by all Stainless processes: 1 Stainless, 1 StainlessManager and 1 StainlessClient per tab open.
ps -eo pcpu,user,pid,cmd | sort -r | head -5
This is sample output - yours may be different.
ps -eo user,pcpu,pmem | tail -n +2 | awk '{num[$1]++; cpu[$1] += $2; mem[$1] += $3} END{printf("NPROC\tUSER\tCPU\tMEM\n"); for (user in cpu) printf("%d\t%s\t%.2f\t%.2f\n",num[user], user, cpu[user], mem[user]) }'
This is sample output - yours may be different.
The original version gives an error, here is the correct output
This is sample output - yours may be different.
root 21 0.0 0.0 0 0 ? S< Oct10 0:11 [ata/0]
68 1417 0.0 0.2 6772 2900 ? Ss Oct10 0:14 hald
root 1586 0.0 0.1 17184 1836 ? Ssl Oct10 0:14 NetworkManager --pid-file=/var/run/NetworkManager/NetworkManager.pid
root 1554 0.0 0.0 3516 564 ? S Oct10 0:19 hald-addon-storage: polling /dev/sr0 (every 2 sec)
ali 2013 0.0 0.9 247540 10068 ? S Oct10 0:24 kwin -session 10dad4d46f000125200430400000021020032_1255123367_509351
dbus 1377 0.0 0.1 13492 1484 ? Ssl Oct10 0:25 dbus-daemon --system
root 47 0.0 0.0 0 0 ? S< Oct10 0:29 [scsi_eh_1]
ali 2047 0.0 1.5 123976 15816 ? Rl Oct10 0:44 yakuake -session 10dad4d46f000125165081500000020800011_1255123367_401521 -name Qt-subapplication
ali 2323 0.1 0.2 1610188 2528 ? Ss Oct10 0:52 C:\windows\system32\explorer.exe /desktop
ali 2021 0.1 2.2 287952 23152 ? Sl Oct10 1:37 /usr/bin/plasma-desktop
ali 2299 0.2 0.0 5404 992 ? Ss Oct10 2:24 /usr/bin/wineserver
root 6341 0.5 7.0 122288 72160 pts/3 S+ 00:33 0:33 /usr/bin/python /usr/bin/yum groupinstall GNOME Desktop Environment
ali 2296 0.6 0.7 1694604 8076 ? Sl Oct10 5:03 C:\Program Files\www.cproxy.com\cproxy.exe
ali 2191 0.8 0.2 100880 2160 ? Ssl Oct10 7:07 /usr/bin/pulseaudio --start --log-target=syslog
ali 6164 1.2 3.2 165432 33084 ? Sl 00:30 1:20 /usr/bin/kopete -caption Kopete
ali 4854 2.6 2.2 147408 22468 ? Sl Oct10 6:07 /usr/lib/nspluginwrapper/npviewer.bin --plugin /usr/lib/mozilla/plugins/libflashplayer.so --connection /org/wrapper/NSPlugins/libflashplayer.so/4759-1
ali 4546 2.9 5.9 228028 61048 ? Sl Oct10 7:24 /usr/lib/songbird-1.2.0/./songbird-bin
root 1840 5.9 2.7 55864 28172 tty1 Ss+ Oct10 49:50 /usr/bin/X -br -nolisten tcp :0 vt1 -auth /var/run/xauth/A:0-lhNFjm
ali 4759 16.6 18.4 652080 187640 ? Sl Oct10 38:56 /usr/lib/firefox-3.5.3/firefox
ali 7231 2.0 0.0 4764 988 pts/0 R+ 02:16 0:00 ps aux --sort=%mem,%cpu
you can also pipe it to "tail" command to show 10 most memory using processes.
This is sample output - yours may be different.
ps -C program_name || { program_name & }
This is sample output - yours may be different.
This is sample output - yours may be different.
psg() { ps aux | grep "[${1[1]}]${1[2,-1]}"; }
This is sample output - yours may be different.
`--> ps? urxvt
root 5850 0.0 0.0 74404 3812 ? Ss 20:21 0:00 urxvt
root 25961 0.0 0.0 74388 3732 ? Ss 20:34 0:00 urxvt
alias ps?='psg' for maximum hawtness. Works in bash or zsh.
ps -ef | awk '/process-name/ && !/awk/ {print}'
This is sample output - yours may be different.
$ ps -ef | awk '/mingetty/ && !/awk/ {print}'
root 4976 1 0 Jul01 tty1 00:00:00 /sbin/mingetty --noclear tty1
root 4977 1 0 Jul01 tty2 00:00:00 /sbin/mingetty tty2
root 4978 1 0 Jul01 tty3 00:00:00 /sbin/mingetty tty3
root 4979 1 0 Jul01 tty4 00:00:00 /sbin/mingetty tty4
root 4980 1 0 Jul01 tty5 00:00:00 /sbin/mingetty tty5
root 4981 1 0 Jul01 tty6 00:00:00 /sbin/mingetty tty6
This does the same thing as many of the 'grep' based alternatives but allows a more finite control over the output. For example if you only wanted the process ID you could change the command:
ps -ef | awk '/mingetty/ && !/awk/ {print $2}'
If you wanted to kill the returned PID's:
ps -ef | awk '/mingetty/ && !/awk/ {print $2}' | xargs -i kill {}
command ps -Hacl -F S -A f
This is sample output - yours may be different.
F S UID PID PPID CLS PRI ADDR SZ WCHAN RSS PSR STIME TTY TIME CMD
5 S root 30780 1 TS 29 - 1075 - 1044 3 Aug18 ? 0:19 /usr/sbin/sshd
4 S root 17479 30780 TS 27 - 1719 - 2156 0 00:13 ? 0:00 \_ sshd: graves [priv]
5 S graves 17482 17479 TS 29 - 1775 - 1676 0 00:13 ? 0:00 \_ sshd: [email protected]/0
0 S graves 17483 17482 TS 29 - 864 wait 2280 0 00:13 pts/0 0:00 \_ -bash
0 R graves 17142 17483 TS 27 - 640 - 820 3 02:46 pts/0 0:00 \_ ps -Hacl -F S -A f
5 S root 30816 1 TS 26 - 8484 - 20872 3 Aug18 ? 14:31 /dh/apache2/apache2-etherape/apache2-etherape-httpd -DModSSL -d /dh/apache2/apache2-etherape
5 S dhapache 8429 30816 TS 29 - 8404 - 14788 1 Aug18 ? 0:00 \_ /dh/apache2/apache2-etherape/fcgi-pm -DModSSL -d /dh/apache2/apache2-etherape
5 S dhapache 8442 30816 TS 29 - 8484 - 15004 2 Aug18 ? 0:47 \_ /dh/apache2/apache2-etherape/apache2-etherape-httpd -DModSSL -d /dh/apache2/apache2-etherape
4 S htacces 5374 8442 TS 27 - 4961 376052 8680 0 01:51 ? 0:03 | \_ php5.cgi
4 S htacces 5375 8442 TS 28 - 4957 390250 8648 0 01:51 ? 0:02 | \_ php5.cgi
0 S root 8466 30816 TS 25 - 790 sinitt 1156 0 Aug18 ? 0:00 \_ /dh/passenger/ext/apache2/ApplicationPoolServerExecutable 0 /usr/bin/ruby
I don't truly enjoy many commands more than this one, which I alias to be ps1.. Cool to be able to see the heirarchy and makes it clearer what need to be killed, and whats really going on.
ps aux | grep [c]ommandname
This is sample output - yours may be different.
This is sample output - yours may be different.
[email protected]:~$ ps -C ps
PID TTY TIME CMD
14524 pts/1 00:00:00 ps
[email protected]:~$ ps -fC ps
UID PID PPID C STIME TTY TIME CMD
ion 14544 13940 0 11:23 pts/1 00:00:00 ps -fC ps
preferred way to query ps for a specific process name (not supported with all flavors of ps, but will work on just about any linux afaik)
ps aux | grep [p]rocess-name
This is sample output - yours may be different.
> ps aux | grep [m]ingetty
root 2381 0.0 0.0 7152 824 tty1 Ss+ Aug11 0:00 /sbin/mingetty --noclear tty1
root 2382 0.0 0.0 7152 828 tty2 Ss+ Aug11 0:00 /sbin/mingetty tty2
root 2383 0.0 0.0 7156 828 tty3 Ss+ Aug11 0:00 /sbin/mingetty tty3
root 2384 0.0 0.0 7156 828 tty4 Ss+ Aug11 0:00 /sbin/mingetty tty4
root 2385 0.0 0.0 7156 832 tty5 Ss+ Aug11 0:00 /sbin/mingetty tty5
root 2410 0.0 0.0 7156 832 tty6 Ss+ Aug11 0:00 /sbin/mingetty tty6
As an alternative to using an additional grep -v grep you can use a simple regular expression in the search pattern (first letter is something out of the single letter list ;-)) to drop the grep command itself.
ps aux | grep process-name | grep -v "grep"
This is sample output - yours may be different.
This is sample output - yours may be different.
ps -o comm= -p $(ps -o ppid= -p $$)
This is sample output - yours may be different.
Get the name of the parent command. This might be helpful, if you need to react on that information. E. g. a script called directly via ssh has got sshd as parent, manually invoked the parent process will probably be bash
ps -o rss -C httpd | tail -n +2 | (sed 's/^/x+=/'; echo x) | bc
This is sample output - yours may be different.
Display the amount of memory used by all the httpd processes. Great in case you are being Slashdoted!
ps -u $USER |grep $1 | awk '{ print $1}'| xargs kill
This is sample output - yours may be different.
Well this can come handy , when you don't feel like playing with pid rather if you know
the process name say "firefox",it would kill it.The script given below would kill the process with its name given as first parameter , though not robust enough to notify that process doesn't exist , well if you know what you are doing that's wouldn't be a problem.:)
----
killhim.sh
----
#!/bin/bash
ps -u $USER |grep $1 | awk '{ print $1}'| xargs kill
----
ps ax -o "%p %U %u %x %c %n"
This is sample output - yours may be different.
27281 1000 1000 00:00:00 kio_file 0
27282 1000 1000 00:00:00 ruby 0
27301 1000 1000 00:00:00 kio_uiserver 0
27355 1000 1000 00:00:00 kdesud 0
28425 1000 1000 00:00:00 bash 0
30166 1000 1000 00:00:17 htop 0
32256 1000 1000 00:00:00 kio_pop3 0
32359 1000 1000 00:00:00 man 0
32370 1000 1000 00:00:00 pager 0
ps command gives the possibility to display information with custom formatting with the -o options followed by the format specifier list.