Windows中是否有类似UNIX中ps -aux的命令?


30

在学校里,我们正在学习将UNIX与SSH结合使用。Windows中有没有办法在ps -aux没有GUI的情况下获得类似于UNIX 命令的输出?我希望在命令行界面中查看程序名称,PID和其他详细信息。

Answers:


40

我相信您正在寻找tasklist命令。

C:\Documents and Settings\Administrator>tasklist /?

TASKLIST [/S system [/U username [/P [password]]]]
         [/M [module] | /SVC | /V] [/FI filter] [/FO format] [/NH]

Description:
    This command line tool displays a list of application(s) and
    associated task(s)/process(es) currently running on either a local or
    remote system.

Parameter List:
   /S     system           Specifies the remote system to connect to.

   /U     [domain\]user    Specifies the user context under which
                           the command should execute.

   /P     [password]       Specifies the password for the given
                           user context. Prompts for input if omitted.

   /M     [module]         Lists all tasks that have DLL modules loaded
                           in them that match the given pattern name.
                           If the module name is not specified,
                           displays all modules loaded by each task.

   /SVC                    Displays services in each process.

   /V                      Specifies that the verbose information
                           is to be displayed.

   /FI    filter           Displays a set of tasks that match a
                           given criteria specified by the filter.

   /FO    format           Specifies the output format.
                           Valid values: "TABLE", "LIST", "CSV".

   /NH                     Specifies that the "Column Header" should
                           not be displayed in the output.
                           Valid only for "TABLE" and "CSV" formats.

   /?                      Displays this help/usage.

Filters:
    Filter Name     Valid Operators           Valid Value(s)
    -----------     ---------------           --------------
    STATUS          eq, ne                    RUNNING | NOT RESPONDING
    IMAGENAME       eq, ne                    Image name
    PID             eq, ne, gt, lt, ge, le    PID value
    SESSION         eq, ne, gt, lt, ge, le    Session number
    SESSIONNAME     eq, ne                    Session name
    CPUTIME         eq, ne, gt, lt, ge, le    CPU time in the format
                                              of hh:mm:ss.
                                              hh - hours,
                                              mm - minutes, ss - seconds
    MEMUSAGE        eq, ne, gt, lt, ge, le    Memory usage in KB
    USERNAME        eq, ne                    User name in [domain\]user
                                              format
    SERVICES        eq, ne                    Service name
    WINDOWTITLE     eq, ne                    Window title
    MODULES         eq, ne                    DLL name

Examples:
    TASKLIST
    TASKLIST /M
    TASKLIST /V
    TASKLIST /SVC
    TASKLIST /M wbem*
    TASKLIST /S system /FO LIST
    TASKLIST /S system /U domain\username /FO CSV /NH
    TASKLIST /S system /U username /P password /FO TABLE /NH
    TASKLIST /FI "USERNAME ne NT AUTHORITY\SYSTEM" /FI "STATUS eq running"

输出示例:

C:\Documents and Settings\Administrator>tasklist

Image Name                   PID Session Name     Session#    Mem Usage
========================= ====== ================ ======== ============
System Idle Process            0 Console                 0         16 K
System                         4 Console                 0         40 K
smss.exe                     564 Console                 0         52 K
csrss.exe                    628 Console                 0      2,168 K
winlogon.exe                 652 Console                 0      1,052 K
services.exe                 696 Console                 0      1,452 K
lsass.exe                    708 Console                 0      1,272 K
svchost.exe                  860 Console                 0      1,620 K
svchost.exe                  940 Console                 0      1,324 K
svchost.exe                 1032 Console                 0      8,204 K
svchost.exe                 1080 Console                 0      1,200 K
svchost.exe                 1132 Console                 0        544 K
spoolsv.exe                 1436 Console                 0        940 K
explorer.exe                1676 Console                 0      6,500 K
svchost.exe                 1920 Console                 0      1,372 K
cmd.exe                     1520 Console                 0         92 K
firefox.exe                  796 Console                 0     77,080 K
cmd.exe                      436 Console                 0      2,280 K
tasklist.exe                 196 Console                 0      3,984 K

您还可以使用/ V参数(详细)来获取更多详细信息,但是只需使用tasklist将列出程序及其PID。


11

虽然tasklist很可能需要使用Windows,但在Windows上还有其他方法:

  • 启动WMI控制台wmic,然后输入process。这可能会给您带来比您所需要的更多的东西:-)
  • 在Powershell中,该Get-Processcmdlet或其别名,ps或者gpsWil所提到的。
  • 在Powershell中通过WMI :Get-WMIObject Win32_Process。但是,您将必须缩小字段以显示它,以使其有用。
  • 特别是通过Sysinternals PSToolspslist。这些全都可以找到\\live.sysinternals.com

1
WMIC很棒...
Chandra Nakka 2014年

3

另外,如果您使用Microsoft Powershell,则PS命令可与大量其他* nix命令一起使用!


1
从技术上讲,这些是用于执行PowerShell命令的Unix命令名称的别名。与PowerShell具有的“ DOS”命令相同
。– jtimberman
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.