系统相关
首页 > 系统相关> > OS第1次实验报告:熟悉使用Linux命令和剖析ps命令

OS第1次实验报告:熟悉使用Linux命令和剖析ps命令

作者:互联网

聂戴成

201821121012

计算1811

1. 实验环境介绍

给出实验环境:

用户名设为自己名字的拼音,举例,刘看山,那么操作系统用户名可以是kanshanliukanshan。并给出一个带自己名字的命令行窗口截图。

2. 常用命令使用

按照PPT,练习常用命令使用。

PS:这部分不要求做详细记录。

3. 剖析ps命令

运行man ps,将ps使用方法拷贝过来,比如:

$ ps --help
Usage: ps [-aefls] [-u UID] [-p PID]

Report process status

 -a, --all       show processes of all users
 -e, --everyone  show processes of all users
 -f, --full      show process uids, ppids
 -h, --help      output usage information and exit
 -l, --long      show process uids, ppids, pgids, winpids
 -p, --process   show information for specified PID
 -s, --summary   show process summary
 -u, --user      list processes owned by UID
 -V, --version   output version information and exit
 -W, --windows   show windows as well as cygwin processes

With no options, ps outputs the long format by default

$ ps -ef
     UID     PID    PPID  TTY        STIME COMMAND
niedaich    1601       1 ?        19:47:22 /usr/bin/mintty
niedaich    1602    1601 pty0     19:47:23 /usr/bin/bash
niedaich    1663    1602 pty0     20:12:18 /usr/bin/ps

-e:显示所有进程;

-f:完整输出显示进程之间的父子关系;

UID:用户的id

PID:进程的标志符

PPID:副进程的标志符

STIME:创建时的系统时间

TTY:终端

COMMAND:发出命令的程序的所在地址

$ ps -al
      PID    PPID    PGID     WINPID   TTY         UID    STIME COMMAND
     1601       1    1601      21148  ?         197609 19:47:22 /usr/bin/mintty
     1668    1602    1668       4876  pty0      197609 20:39:46 /usr/bin/ps
     1602    1601    1602      10040  pty0      197609 19:47:23 /usr/bin/bash

-a:显示所有进程

-l:显示更详细信息

PGID:进程组id

WINPID:在windows下的进程ID

$ ps -h
Usage: ps [-aefls] [-u UID] [-p PID]

Report process status

 -a, --all       show processes of all users
 -e, --everyone  show processes of all users
 -f, --full      show process uids, ppids
 -h, --help      output usage information and exit
 -l, --long      show process uids, ppids, pgids, winpids
 -p, --process   show information for specified PID
 -s, --summary   show process summary
 -u, --user      list processes owned by UID
 -V, --version   output version information and exit
 -W, --windows   show windows as well as cygwin processes

With no options, ps outputs the long format by default

-h:帮助

$ ps -p1601
      PID    PPID    PGID     WINPID   TTY         UID    STIME COMMAND
     1601       1    1601      21148  ?         197609 19:47:22 /usr/bin/mintty

-p:查看某个具体进程的数据

$ ps -s
    PID  TTY        STIME COMMAND
   1686 pty0     21:17:27 /usr/bin/ps
   1601 ?        19:47:22 /usr/bin/mintty
   1602 pty0     19:47:23 /usr/bin/bash

-p:简短地查看进程数据

$ ps -u197609
      PID    PPID    PGID     WINPID   TTY         UID    STIME COMMAND
     1601       1    1601      21148  ?         197609 19:47:22 /usr/bin/mintty
     1602    1601    1602      10040  pty0      197609 19:47:23 /usr/bin/bash
     1688    1602    1688      19596  pty0      197609 21:19:31 /usr/bin/ps

-u:查看某个具体用户所拥有的进程

$ ps --version
ps (cygwin) 3.1.4
Show process statistics
Copyright (C) 1996 - 2020 Cygwin Authors
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

--version:查看cygwin版本

$ ps --windows
      PID    PPID    PGID     WINPID   TTY         UID    STIME COMMAND
    65540       0       0          4  ?              0   Feb 22 System
    65656       0       0        120  ?              0   Feb 22 Registry

--Windows:查看Windows和cygwin的进程(代码只列取了一部分)

标签:bin,ps,show,1601,PID,命令,usr,Linux
来源: https://www.cnblogs.com/Dlementine/p/12431117.html