OS第1次实验报告:熟悉使用Linux命令和剖析ps命令
- 姓名 郑楚杭
- 学号 201821121009
- 班级 计算1811
1. 实验环境介绍
给出实验环境:
- 操作系统:Ubuntu 18.04.4 LTS
- 平台:双系统
2. 常用命令使用
进入特权模式——sudo su:
进入某路径——cd+路径名称
3. 剖析ps命令
1)运行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=
2)ps
命令有很多参数,运行命令,比如ps -ef
,给出你系统的返回结果:
UID PID PPID C STIME TTY TIME CMD root 1 0 0 13:55 ? 00:00:23 /lib/systemd/systemd --system -- root 2 0 0 13:55 ? 00:00:00 [kthreadd] root 3 2 0 13:55 ? 00:00:00 [rcu_gp] root 4 2 0 13:55 ? 00:00:00 [rcu_par_gp] root 6 2 0 13:55 ? 00:00:00 [kworker/0:0H-kb] root 8 2 0 13:55 ? 00:00:04 [kworker/u16:0-e] root 9 2 0 13:55 ? 00:00:00 [mm_percpu_wq] root 10 2 0 13:55 ? 00:00:00 [ksoftirqd/0] root 11 2 0 13:55 ? 00:00:02 [rcu_sched] root 12 2 0 13:55 ? 00:00:00 [migration/0] root 13 2 0 13:55 ? 00:00:00 [idle_inject/0] root 14 2 0 13:55 ? 00:00:00 [cpuhp/0] root 15 2 0 13:55 ? 00:00:00 [cpuhp/1] root 16 2 0 13:55 ? 00:00:00 [idle_inject/1] root 17 2 0 13:55 ? 00:00:00 [migration/1] root 18 2 0 13:55 ? 00:00:00 [ksoftirqd/1] root 20 2 0 13:55 ? 00:00:00 [kworker/1:0H-kb] root 21 2 0 13:55 ? 00:00:00 [cpuhp/2] root 22 2 0 13:55 ? 00:00:00 [idle_inject/2] root 23 2 0 13:55 ? 00:00:00 [migration/2] root 24 2 0 13:55 ? 00:00:00 [ksoftirqd/2] root 26 2 0 13:55 ? 00:00:00 [kworker/2:0H-kb] root 27 2 0 13:55 ? 00:00:00 [cpuhp/3] root 28 2 0 13:55 ? 00:00:00 [idle_inject/3] root 29 2 0 13:55 ? 00:00:00 [migration/3] root 30 2 0 13:55 ? 00:00:00 [ksoftirqd/3]
- 命令中参数的含义(ps -ef)
-e :表示显示全部进程
-f :表示完整-格式,包括命令行
- 返回结果每个字段的含义
UID:说明该程序被谁拥有
PID:就是指该程序的 ID
PPID: 就是指该程序父级程序的 ID
C: 指的是 CPU 使用的百分比
STIME: 程序的启动时间
TTY: 指的是登录终端
TIME : 指程序使用掉 CPU 的时间
CMD:下达的指令
3)执行ps -aux命令的返回结果以及字段含义
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.6 0.1 225816 9744 ? Ss 13:55 0:25 /lib/systemd/sy root 2 0.0 0.0 0 0 ? S 13:55 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? I< 13:55 0:00 [rcu_gp] root 4 0.0 0.0 0 0 ? I< 13:55 0:00 [rcu_par_gp] root 6 0.0 0.0 0 0 ? I< 13:55 0:00 [kworker/0:0H-k root 9 0.0 0.0 0 0 ? I< 13:55 0:00 [mm_percpu_wq] root 10 0.0 0.0 0 0 ? S 13:55 0:00 [ksoftirqd/0] root 11 0.0 0.0 0 0 ? I 13:55 0:03 [rcu_sched] root 12 0.0 0.0 0 0 ? S 13:55 0:00 [migration/0] root 13 0.0 0.0 0 0 ? S 13:55 0:00 [idle_inject/0] root 14 0.0 0.0 0 0 ? S 13:55 0:00 [cpuhp/0] root 15 0.0 0.0 0 0 ? S 13:55 0:00 [cpuhp/1] root 16 0.0 0.0 0 0 ? S 13:55 0:00 [idle_inject/1] root 17 0.0 0.0 0 0 ? S 13:55 0:00 [migration/1] root 18 0.0 0.0 0 0 ? S 13:55 0:00 [ksoftirqd/1] root 20 0.0 0.0 0 0 ? I< 13:55 0:00 [kworker/1:0H-k root 21 0.0 0.0 0 0 ? S 13:55 0:00 [cpuhp/2] root 22 0.0 0.0 0 0 ? S 13:55 0:00 [idle_inject/2] root 23 0.0 0.0 0 0 ? S 13:55 0:00 [migration/2] root 24 0.0 0.0 0 0 ? S 13:55 0:00 [ksoftirqd/2]
- 命令中参数的含义(ps -aux)
-a :表示显示现行终端机下的所有程序,包括其他用户的程序
-u :表示以面向用户的格式显示程序状况
-x :表示显示所有程序,不以终端机区分
- 返回结果每个字段的含义
USER: 行程拥有者
PID: pid
%CPU: 占用的 CPU 使用率
%MEM: 占用的内存使用率
VSZ: 占用的虚拟内存大小
RSS: 占用的内存大小
TTY: 终端的次要装置号码 (minor device number of tty)
pts/0,1,2是标准输入,标准输出,标准出错
STAT: 该行程的状态,linux的进程有5种状态:
D 不可中断 uninterruptible sleep (usually IO)
R 运行 runnable (on run queue)
S 中断 sleeping
T 停止 traced or stopped
Z 僵死 a defunct (”zombie”) process
START: 行程开始时间
TIME: 执行的时间
COMMAND:所执行的指令
4. 通过该实验产生新的疑问及解答
1)初使用Ubuntu系统不知如何进行屏幕截图操作
查阅资料后得知可通过在终端输入命令行:gnome -screenshot -a进行截图操作,或是在系统设置中更改截图快捷键进行快捷截图。
2)修改用户名困难
设备名称无法修改导致在终端显示的用户名过长且不符合实验要求,后在系统设置—详细信息—About中成功修改了设备名称。
posted on 2020-03-05 15:23 EzforNiko+ 阅读(271) 评论(0) 编辑 收藏 举报