OS第一次实验报告:熟悉使用Linux命令和剖析ps命令
- 姓名:傅伟杰
- 学号:201821121018
- 班级:计算1811
1. 实验环境介绍
给出实验环境:
- 操作系统:Ubuntu 18.04.3 LTS
- 平台:双操作系统(win10+Ubuntu 18.04.3)
2. 常用命令使用
进入特权模式——sudo su
打开文件——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. Options of different types may be freely mixed, but conflicts can appear. There are some synonymous options, which are functionally identical, due to the many standards and ps implementations that this ps is compatible with. Note that "ps -aux" is distinct from "ps aux". The POSIX and UNIX standards require that "ps -aux" print all processes owned by a user named "x", as well as printing all processes that would be selected by the -a option. If the user named "x" does not exist, this ps may interpret the command as "ps aux" instead and print a warning. This behavior is intended to aid in transitioning old scripts and habits. It is fragile, subject to change, and thus should not be relied upon. By default, ps selects all processes with the same effective user ID (euid=EUID) as the current user and associated with the same terminal as the invoker. It displays the process ID (pid=PID), the terminal associated with the process (tname=TTY), the cumulated CPU time in [DD-]hh:mm:ss format (time=TIME), and the executable name (ucmd=CMD). Output is unsorted by default.
ps命令有很多参数,运行命令,比如ps -ef,给出系统的返回结果:
下面是ps -ef返回结果(部分):UID PID PPID C STIME TTY TIME CMD root 1 0 0 17:26 ? 00:00:08 /sbin/init splash root 2 0 0 17:26 ? 00:00:00 [kthreadd] root 3 2 0 17:26 ? 00:00:00 [rcu_gp] root 4 2 0 17:26 ? 00:00:00 [rcu_par_gp] root 6 2 0 17:26 ? 00:00:00 [kworker/0:0H-kb] root 8 2 0 17:26 ? 00:00:00 [mm_percpu_wq] root 9 2 0 17:26 ? 00:00:00 [ksoftirqd/0] root 10 2 0 17:26 ? 00:00:06 [rcu_sched] root 11 2 0 17:26 ? 00:00:00 [migration/0] root 12 2 0 17:26 ? 00:00:00 [idle_inject/0] root 14 2 0 17:26 ? 00:00:00 [cpuhp/0] root 15 2 0 17:26 ? 00:00:00 [cpuhp/1] root 16 2 0 17:26 ? 00:00:00 [idle_inject/1] root 17 2 0 17:26 ? 00:00:00 [migration/1] root 18 2 0 17:26 ? 00:00:00 [ksoftirqd/1] root 20 2 0 17:26 ? 00:00:00 [kworker/1:0H-kb] root 21 2 0 17:26 ? 00:00:00 [cpuhp/2] root 22 2 0 17:26 ? 00:00:00 [idle_inject/2] root 23 2 0 17:26 ? 00:00:00 [migration/2] root 24 2 0 17:26 ? 00:00:00 [ksoftirqd/2] root 26 2 0 17:26 ? 00:00:00 [kworker/2:0H-kb] root 27 2 0 17:26 ? 00:00:00 [cpuhp/3] root 28 2 0 17:26 ? 00:00:00 [idle_inject/3] root 29 2 0 17:26 ? 00:00:00 [migration/3] root 30 2 0 17:26 ? 00:00:00 [ksoftirqd/3]
返回结果各个字段的解释:
UID: 指该程序的拥有者
PID:指该程序的ID
PPID: 指该程序父级程序的ID
C: 指CPU的占有率
STIME: 程序的启动时间
TTY: 指登录终端
TIME:指程序使用的CPU时间
CMD: 下达的指令
命令(ps -ef)的解释:
ps:将某个进程显示出来
-A:显示所有的进程-e:这个参数的含义所进行的效果与-A的效果相同
-f:显示(UID PID PPID C STIME)这几栏
下面是ps -aux的执行结果:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.1 0.1 225432 9132 ? Ss 17:26 0:10 /sbin/init splash root 2 0.0 0.0 0 0 ? S 17:26 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? I< 17:26 0:00 [rcu_gp] root 4 0.0 0.0 0 0 ? I< 17:26 0:00 [rcu_par_gp] root 6 0.0 0.0 0 0 ? I< 17:26 0:00 [kworker/0:0H-kb] root 8 0.0 0.0 0 0 ? I< 17:26 0:00 [mm_percpu_wq] root 9 0.0 0.0 0 0 ? S 17:26 0:00 [ksoftirqd/0] root 10 0.1 0.0 0 0 ? I 17:26 0:07 [rcu_sched] root 11 0.0 0.0 0 0 ? S 17:26 0:00 [migration/0] root 12 0.0 0.0 0 0 ? S 17:26 0:00 [idle_inject/0] root 14 0.0 0.0 0 0 ? S 17:26 0:00 [cpuhp/0] root 15 0.0 0.0 0 0 ? S 17:26 0:00 [cpuhp/1] root 16 0.0 0.0 0 0 ? S 17:26 0:00 [idle_inject/1] root 17 0.0 0.0 0 0 ? S 17:26 0:00 [migration/1] root 18 0.0 0.0 0 0 ? S 17:26 0:00 [ksoftirqd/1] root 20 0.0 0.0 0 0 ? I< 17:26 0:00 [kworker/1:0H-kb]
返回结果各个字段的解释(重复部分参考上诉ps -ef的解释):USER :用户名
ps -aux的命令解释:
%CPU :进程占用的CPU百分比
%MEM :占用内存的百分比
VSZ :该进程使用的虚拟內存量(KB)
RSS :该进程占用的固定內存量(KB)(驻留中页的数量)
STAT :进程的状态
START:该进程被触发启动时间
ps -aux是通过BSD的格式进行显示
4. 通过该实验产生新的疑问及解答
question1:初次使用ubuntu不知道如何使用屏幕截图?
answer1:通过上网查阅得知结果,设置了快捷键ctrl+ait+a进行截图,命令为 gnome -screenshot -ac,即可进行自由截图。
question2:用户名不符合要求,通过网络上的方法无法解决问题?
answer2:通过在设置里的About进行修改,将原本繁杂的主机名,修改成了名字。