2014年3月19日星期三

Linux Commands for Beginners lesson5 -- pidof,kill and ps commands

In this part,I will show you how to kill processes.


if you know your application's name,you can use pidof and kill commands to kill it.


1.COMMAND:
      pidof
 DESCRIPTION:
      finds the process id's (pids) of the named  programs.


2.COMMAND:
      kill
 DESCRIPTION:
      Terminate a Process


Example:
piniheaven@fish:~$ pidof firefox
8477
piniheaven@fish:~$ kill 8477




unfortunately,most of the time, we can not remenber what the application's name is exactily.In this case,you can use ps cammand to list processes.


3.COMMAND:
      ps 
  SYNOPSIS
      ps [options]


 DESCRIPTION:
       ps displays information about a selection of the active processes.


 OPTION:
     -a all w/ tty(TeleTYpe) except session leaders
     -U by real user ID (supports names)
     -u by effective user ID (supports names)
      x  processes w/o controlling ttys




example:
piniheaven@fish:~$ ps -ux    #all of your Processes  that are running
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
1000      1923  0.0  0.0 442624  3876 ?        Sl   06:31   0:00 /usr/bin/gnome-keyring-daemon --daemonize --login


......
......
1000     26058 15.1  3.7 963772 224616 ?       Sl   08:50   1:37 /usr/lib/firefox/firefox
1000     26416  9.9  2.0 687044 125308 ?       Sl   08:50   1:02 /usr/lib/firefox/plugin-container /usr/lib/flashplugin-installer
1000     28660  0.0  0.0  22360  1276 pts/2    R+   09:00   0:00 ps -ux




piniheaven@fish:~$ ps -aux    #all uses's processes that are running
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0  24592  2500 ?        Ss   06:30   0:00 /sbin/init


......
......
root     25542  0.0  0.0      0     0 ?        S    08:43   0:00 [kworker/0:3]
1000     26058 14.2  3.8 965884 232620 ?       Sl   08:50   2:18 /usr/lib/firefox/firefox
1000     26416  9.0  2.0 687044 125308 ?       Sl   08:50   1:10 /usr/lib/firefo
root     28661  0.1  0.0      0     0 ?        S    09:02   0:00 [kworker/u:1]
1000     28670  0.0  0.0  22360  1272 pts/2    R+   09:03   0:00 ps -aux




piniheaven@fish:~$ps-U piniheaven   #the  specified username's all process that are running
  PID TTY          TIME CMD
 1923 ?        00:00:00 gnome-keyring-d
 1934 ?        00:00:00 gnome-session
 1969 ?        00:00:00 ssh-agent
 ......
 ......
21890 ?        00:00:45 gedit
23530 pts/2    00:00:00 bash
26058 ?        00:02:45 firefox
26416 ?        00:01:31 plugin-containe
28681 pts/2    00:00:00 ps

没有评论:

发表评论