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

Posted on 2020-03-07 13:45  LeeKYi  阅读(177)  评论(0编辑  收藏  举报

一、实验目的

熟练Linux命令行操作

二、实验内容

  • 使用man查询命令使用手册
  • 基本命令使用

三、实验报告 

1. 实验环境介绍

  • 操作系统:Ubuntu 18.04.3 LTS
  • 平台:双操作系统

2. 常用命令使用

3. 剖析ps命令

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

 1 NAME
 2        ps - report a snapshot of the current
 3        processes.
 4 
 5 SYNOPSIS
 6        ps [options]
 7 
 8 DESCRIPTION
 9        ps displays information about a selection of
10        the active processes.  If you want a
11        repetitive update of the selection and the
12        displayed information, use top(1) instead.
13 
14        This version of ps accepts several kinds of
15        options:
16 
17        1   UNIX options, which may be grouped and
18            must be preceded by a dash.
19        2   BSD options, which may be grouped and
20            must not be used with a dash.
21        3   GNU long options, which are preceded by
22            two dashes.
23 
24        Options of different types may be freely
25        mixed, but conflicts can appear.  There are
26        some synonymous options, which are
27        functionally identical, due to the many
28        standards and ps implementations that this ps
29        is compatible with.
30 
31        Note that "ps -aux" is distinct from
32        "ps aux".  The POSIX and UNIX standards
33        require that "ps -aux" print all processes
34        owned by a user named "x", as well as
35        printing all processes that would be selected
36        by the -a option.  If the user named "x" does
37        not exist, this ps may interpret the command
38        as "ps aux" instead and print a warning.
39        This behavior is intended to aid in
40        transitioning old scripts and habits.  It is
41        fragile, subject to change, and thus should
42        not be relied upon.

 

运行命令ps -ef

1 UID        PID  PPID  C STIME TTY          TIME CMD
2 root         1     0  0 13:04 ?        00:00:00 /init
3 root         7     1  0 13:04 tty1     00:00:00 /init
4 aalud        8     7  0 13:04 tty1     00:00:00 -bash
5 aalud       84     8  0 13:19 tty1     00:00:00 ps -ef
    • UID:用户ID
    • PID:进程ID号
    • PPID:父进程ID号
    • C:cpu使用的资源百分比
    • STIME:系统时间
    • TTY:该进程是在哪个终端机上运行,若与终端机无关则显示“?”
         tty1-tty6是本机上的登入者程序,若为pts/0等则为由网络连接进主机的程序
    • TIME:使用掉的cpu时间
    • CMD:所下达的指令名称

运行ps -aux

1 USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
2 root         1  0.0  0.0   8892   292 ?        Ssl  13:04   0:00 /init
3 root         7  0.0  0.0   8900   208 tty1     Ss   13:04   0:00 /init
4 aalud        8  0.0  0.0  16792  3380 tty1     S    13:04   0:00 -bash
5 aalud       85  0.0  0.0  17648  2052 tty1     R    13:26   0:00 ps -aux
    • USER:该进程属于哪个使用者ID
    • %CPU:该进程使用的CPU资源%
    • %MEM:该进程占用的物理内存%
    • VSZ:该进程使用的虚拟内存量
    • RSS:该进程占用的固定内存量
    • STAT:该程序目前状态
    • START:该进程被触发的启动时间
    • COMMAND:该程序的实际指令

4. 通过该实验产生新的疑问及解答

由于ubuntu是在该课程前就安装的,所以用户名是自己的ID。然后老师要求前缀要带自己姓名,所以就直接改了主机名,方法:计算机→属性→计算机名更改设置→更改→输入名→确认→重启电脑→修改生效。