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

  • 姓名:杨富宏  
  • 学号:201821121017
  • 班级:计算1811

1. 实验环境介绍

给出实验环境:

  • 操作系统:ubuntu 18.04.4(详细到版本)
  • 平台:虚拟机

2. 常用命令使用

使用了PDF给出的一些命令:

sudo su(进入特权模式)

ls(显示文件夹下文件)

cd+文件名(打开文件)

mkdir+文件名(创建文件)

rmdir+文件名(删除文件)

 

 

 

 

3. 剖析ps命令

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

NAME
ps - report a snapshot of the current processes.

SYNOPSIS
ps [options]

DESCRIPTION
ps displays information about a selection of the active processes. If you want a
repetitive update of the selection and the displayed information, use top(1) instead.

This version of ps accepts several kinds of options:

1 UNIX options, which may be grouped and must be preceded by a dash.
2 BSD options, which may be grouped and must not be used with a dash.
3 GNU long options, which are preceded by two dashes.

运行命令ps -ef,系统的返回结果:

UID         PID   PPID  C STIME TTY          TIME CMD
root          1      0  0 15:50 ?        00:00:02 /sbin/init splash
root          2      0  0 15:50 ?        00:00:00 [kthreadd]
root          3      2  0 15:50 ?        00:00:00 [rcu_gp]
root          4      2  0 15:50 ?        00:00:00 [rcu_par_gp]
root          6      2  0 15:50 ?        00:00:00 [kworker/0:0H-kb]
root          9      2  0 15:50 ?        00:00:00 [mm_percpu_wq]
root         10      2  0 15:50 ?        00:00:00 [ksoftirqd/0]
root         11      2  0 15:50 ?        00:00:00 [rcu_sched]
root         12      2  0 15:50 ?        00:00:00 [migration/0]
root         13      2  0 15:50 ?        00:00:00 [idle_inject/0]
root         14      2  0 15:50 ?        00:00:00 [cpuhp/0]
root         15      2  0 15:50 ?        00:00:00 [kdevtmpfs]
root         16      2  0 15:50 ?        00:00:00 [netns]
root         17      2  0 15:50 ?        00:00:00 [rcu_tasks_kthre]
root         18      2  0 15:50 ?        00:00:00 [kauditd]
root         19      2  0 15:50 ?        00:00:00 [khungtaskd]
root         20      2  0 15:50 ?        00:00:00 [oom_reaper]
root         21      2  0 15:50 ?        00:00:00 [writeback]
root         22      2  0 15:50 ?        00:00:00 [kcompactd0]
root         23      2  0 15:50 ?        00:00:00 [ksmd]
root         24      2  0 15:50 ?        00:00:00 [khugepaged]
root        116      2  0 15:50 ?        00:00:00 [kintegrityd]
root        117      2  0 15:50 ?        00:00:00 [kblockd]
root        118      2  0 15:50 ?        00:00:00 [blkcg_punt_bio]
root        119      2  0 15:50 ?        00:00:00 [tpm_dev_wq]
root        120      2  0 15:50 ?        00:00:00 [ata_sff]
root        121      2  0 15:50 ?        00:00:00 [md]
root        122      2  0 15:50 ?        00:00:00 [edac-poller]
root        123      2  0 15:50 ?        00:00:00 [devfreq_wq]
root        124      2  0 15:50 ?        00:00:00 [watchdogd]
root        127      2  0 15:50 ?        00:00:00 [kswapd0]
root        128      2  0 15:50 ?        00:00:00 [kworker/u257:0]
root        129      2  0 15:50 ?        00:00:00 [ecryptfs-kthrea]
root        132      2  0 15:50 ?        00:00:00 [kthrotld]

首先,解释命令中参数的含义:

ps:表示查看当前进程的状态。

-e:与-A相同,显示所以进程

-f:表示显示将额外的几个栏目显示出来。

接着,解释返回结果每个字段的含义,接着上个例子,需要解释以下字段的含义:

UID:用户ID

PID:进程的ID

PPID:父进程的ID

C:进程占用CPU的百分比

STIME:进程启动到目前状态的时间

TTY:该进程运行的终端

TIME:此程序使用CPU的时间

CMD:命令的名称及参数

 

ps -aux的执行结果:

USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root          1  0.1  0.4 160016  9308 ?        Ss   15:50   0:02 /sbin/init spl
root          2  0.0  0.0      0     0 ?        S    15:50   0:00 [kthreadd]
root          3  0.0  0.0      0     0 ?        I<   15:50   0:00 [rcu_gp]
root          4  0.0  0.0      0     0 ?        I<   15:50   0:00 [rcu_par_gp]
root          6  0.0  0.0      0     0 ?        I<   15:50   0:00 [kworker/0:0H-
root          9  0.0  0.0      0     0 ?        I<   15:50   0:00 [mm_percpu_wq]
root         10  0.0  0.0      0     0 ?        S    15:50   0:00 [ksoftirqd/0]
root         11  0.0  0.0      0     0 ?        I    15:50   0:00 [rcu_sched]
root         12  0.0  0.0      0     0 ?        S    15:50   0:00 [migration/0]
root         13  0.0  0.0      0     0 ?        S    15:50   0:00 [idle_inject/0
root         14  0.0  0.0      0     0 ?        S    15:50   0:00 [cpuhp/0]

UESR:用户名

%CPU:CPU占用的百分比

%MEM:该程序占用内存的百分比

VSZ:占用虚拟内存量

RSS:占用固定内存量

STAT:进程的状态

START:该进程被触发启动的时间

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

  这次实验我是用虚拟机(VMware)内下载的Ubuntu 18.04.4完成,刚开始遇到需要复制代码时,不能进行复制,查阅网络后通过下载VMware Tools 工具解决,而且刚开始接触这个系统用的不是很习惯,在终端的这些命令都是查阅老师给的PDF解决。

posted @ 2020-03-06 16:31  waiting!  阅读(209)  评论(0编辑  收藏  举报