OS第1次实验报告:熟悉使用Linux命令和剖析ps命令
- 姓名:黄财泽
- 学号:201821121014
- 班级:计算1811
1. 实验环境介绍
实验环境:
- 操作系统:Ubuntu 16.04
- 平台: 双操作系统
2. 常用命令使用
进入特权模式:
建立文件:
查看当前目录:
3. 剖析ps命令
- 运行
man ps
,将ps
使用方法拷贝过来:
EXAMPLES To see every process on the system using standard syntax: ps -e ps -ef ps -eF ps -ely To see every process on the system using BSD syntax: ps ax ps axu To print a process tree: ps -ejH ps axjf To get info about threads: ps -eLf ps axms To get security info: ps -eo euser,ruser,suser,fuser,f,comm,label ps axZ ps -eM To see every process running as root (real & effective ID) in user format: ps -U root -u root u To see every process with a user-defined format: ps -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm ps axo stat,euid,ruid,tty,tpgid,sess,pgrp,ppid,pid,pcpu,comm ps -Ao pid,tt,user,fname,tmout,f,wchan Print only the process IDs of syslogd: ps -C syslogd -o pid= Print only the name of PID 42: ps -q 42 -o comm=
执行ps -ef
,给出你系统的返回结果:
UID PID PPID C STIME TTY TIME CMD root 1 0 0 17:42 ? 00:00:01 /sbin/init splash root 2 0 0 17:42 ? 00:00:00 [kthreadd] root 4 2 0 17:42 ? 00:00:00 [kworker/0:0H] root 5 2 0 17:42 ? 00:00:00 [kworker/u16:0] root 6 2 0 17:42 ? 00:00:00 [mm_percpu_wq] root 7 2 0 17:42 ? 00:00:00 [ksoftirqd/0] root 8 2 0 17:42 ? 00:00:00 [rcu_sched] root 9 2 0 17:42 ? 00:00:00 [rcu_bh] root 10 2 0 17:42 ? 00:00:00 [migration/0] root 11 2 0 17:42 ? 00:00:00 [watchdog/0] root 12 2 0 17:42 ? 00:00:00 [cpuhp/0] root 13 2 0 17:42 ? 00:00:00 [cpuhp/1] root 14 2 0 17:42 ? 00:00:00 [watchdog/1] root 15 2 0 17:42 ? 00:00:00 [migration/1] root 16 2 0 17:42 ? 00:00:00 [ksoftirqd/1] root 18 2 0 17:42 ? 00:00:00 [kworker/1:0H] root 19 2 0 17:42 ? 00:00:00 [cpuhp/2] root 20 2 0 17:42 ? 00:00:00 [watchdog/2] root 21 2 0 17:42 ? 00:00:00 [migration/2] root 22 2 0 17:42 ? 00:00:00 [ksoftirqd/2] root 24 2 0 17:42 ? 00:00:00 [kworker/2:0H] root 25 2 0 17:42 ? 00:00:00 [cpuhp/3] root 26 2 0 17:42 ? 00:00:00 [watchdog/3] root 27 2 0 17:42 ? 00:00:00 [migration/3] root 28 2 0 17:42 ? 00:00:00 [ksoftirqd/3] root 30 2 0 17:42 ? 00:00:00 [kworker/3:0H] root 31 2 0 17:42 ? 00:00:00 [cpuhp/4] root 32 2 0 17:42 ? 00:00:00 [watchdog/4] root 33 2 0 17:42 ? 00:00:00 [migration/4]
UID :程序被该 UID 所拥有
PID :就是这个程序的 ID
PPID :则是其上级父程序的ID
C :CPU使用的资源百分比
STIME :系统启动时间
TTY :登入者的终端机位置
TIME :使用掉的CPU时间。
CMD :所下达的是什么指令
解释参数含义:
-e :显示所有进程。
-f :全格式
执行ps -aux系统的返回的结果
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.0 185448 6020 ? Ss 17:42 0:01 /sbin/init spla root 2 0.0 0.0 0 0 ? S 17:42 0:00 [kthreadd] root 4 0.0 0.0 0 0 ? S< 17:42 0:00 [kworker/0:0H] root 5 0.0 0.0 0 0 ? S 17:42 0:00 [kworker/u16:0] root 6 0.0 0.0 0 0 ? S< 17:42 0:00 [mm_percpu_wq] root 7 0.0 0.0 0 0 ? S 17:42 0:00 [ksoftirqd/0] root 8 0.0 0.0 0 0 ? S 17:42 0:00 [rcu_sched] root 9 0.0 0.0 0 0 ? S 17:42 0:00 [rcu_bh] root 10 0.0 0.0 0 0 ? S 17:42 0:00 [migration/0] root 11 0.0 0.0 0 0 ? S 17:42 0:00 [watchdog/0] root 12 0.0 0.0 0 0 ? S 17:42 0:00 [cpuhp/0] root 13 0.0 0.0 0 0 ? S 17:42 0:00 [cpuhp/1] root 14 0.0 0.0 0 0 ? S 17:42 0:00 [watchdog/1] root 15 0.0 0.0 0 0 ? S 17:42 0:00 [migration/1] root 16 0.0 0.0 0 0 ? S 17:42 0:00 [ksoftirqd/1] root 18 0.0 0.0 0 0 ? S< 17:42 0:00 [kworker/1:0H] root 19 0.0 0.0 0 0 ? S 17:42 0:00 [cpuhp/2] root 20 0.0 0.0 0 0 ? S 17:42 0:00 [watchdog/2] root 21 0.0 0.0 0 0 ? S 17:42 0:00 [migration/2] root 22 0.0 0.0 0 0 ? S 17:42 0:00 [ksoftirqd/2] root 24 0.0 0.0 0 0 ? S< 17:42 0:00 [kworker/2:0H] root 25 0.0 0.0 0 0 ? S 17:42 0:00 [cpuhp/3] root 26 0.0 0.0 0 0 ? S 17:42 0:00 [watchdog/3] root 27 0.0 0.0 0 0 ? S 17:42 0:00 [migration/3] root 28 0.0 0.0 0 0 ? S 17:42 0:00 [ksoftirqd/3] root 30 0.0 0.0 0 0 ? S< 17:42 0:00 [kworker/3:0H] root 31 0.0 0.0 0 0 ? S 17:42 0:00 [cpuhp/4] root 32 0.0 0.0 0 0 ? S 17:42 0:00 [watchdog/4] root 33 0.0 0.0 0 0 ? S 17:42 0:00 [migration/4]
USER:进程拥有者
PID:pid
%CPU:占用的CPU的使用率
#MEM:占用的记忆体使用率
VSZ:占用的虚拟记忆体大小
RSS:占用的记忆体大小
TTY:终端的次要装置号码
STAT:该行程的状态,linux的进程有5种状态
- D 不可中断
-R 运行runnable
-S中断Sleeping
-T停止traced or stopped
-Z 僵死
START:形成开始时间
TIME:执行时间
COMMAND:所执行的指令
4. 通过该实验产生新的疑问及解答
疑问:Ubuntu系统截图怎么使用
解答:使用 shift+prt sc sysrq键可以进行区域截图