OS第1次实验报告:熟悉使用Linux命令和剖析ps命令
姓名:蔡婷婷 学号:201821121003 班级:计算1811
1. 实验环境介绍
给出实验环境:
- 操作系统:Windows 10 专业版
- 平台:Cygwin
带自己名字的命令行窗口截图:
2. 常用命令使用
按照PPT,练习常用命令使用。
3. 剖析ps命令
(1)运行man ps:
SYNOPSIS
ps [−aA] [−defl] [−g grouplist] [−G grouplist]
[−n namelist] [−o format]... [−p proclist] [−t termlist]
[−u userlist] [−U userlist]
DESCRIPTION
The ps utility shall write information about processes, subject to
having appropriate privileges to obtain information about those pro‐
cesses.
By default, ps shall select all processes with the same effective user
ID as the current user and the same controlling terminal as the in‐
voker.
OPTIONS
The ps utility shall conform to the Base Definitions volume of
POSIX.1‐2008, Section 12.2, Utility Syntax Guidelines.
The following options shall be supported:
−a Write information for all processes associated with termi‐
nals. Implementations may omit session leaders from this
list.
−A Write information for all processes.
−d Write information for all processes, except session leaders.
−e Write information for all processes. (Equivalent to −A.)
−f Generate a full listing. (See the STDOUT section for the
contents of a full listing.)
(2)运行ps命令(显示当前系统进程信息):
$ ps
PID PPID PGID WINPID TTY UID STIME COMMAND
718 717 718 10684 pty0 197609 22:42:55 /usr/bin/bash
748 718 748 3064 pty0 197609 23:19:44 /usr/bin/ps
717 1 717 880 ? 197609 22:42:54 /usr/bin/mintty
(3)运行ps -ef命令(显示系统所有进程):
$ ps -ef
UID PID PPID TTY STIME COMMAND
caitingt 718 717 pty0 22:42:55 /usr/bin/bash
caitingt 749 718 pty0 23:25:16 /usr/bin/ps
caitingt 717 1 ? 22:42:54 /usr/bin/mintty
参数的含义:
e:为所有过程编写信息。
f:生成完整的列表。
(4)运行ps aux命令:
$ ps aux
PID PPID PGID WINPID TTY UID STIME COMMAND
718 717 718 10684 pty0 197609 22:42:55 /usr/bin/bash
750 718 750 576 pty0 197609 23:35:22 /usr/bin/ps
717 1 717 880 ? 197609 22:42:54 /usr/bin/mintty
参数的含义:
a:为与终端关联的所有进程写入信息。实现可能会从该列表中省略会话领导人。
u:以用户为主的格式来显示程序状况。
x:显示所有程序,不以终端机来区分
(5)运行ps defl命令:
$ ps defl
PID PPID PGID WINPID TTY UID STIME COMMAND
718 717 718 10684 pty0 197609 22:42:55 /usr/bin/bash
751 718 751 11048 pty0 197609 23:53:23 /usr/bin/ps
717 1 717 880 ? 197609 22:42:54 /usr/bin/mintty
参数的含义:
d:为所有流程编写信息,会话负责人除外。
e:为所有过程编写信息。
f:生成完整的列表。
l:生成一个长列表。
(6)字段的含义:
UID:用户ID
PID:进程ID
PPID:父进程ID
PGID:进程组ID号
TTY:终端的次要装置号码
COMMAND:所执行的命令
4. 通过该实验产生新的疑问及解答
(1)问题:修改用户名时在cygwin/etc中未找到passwd文件?
解决:执行命令$mkpasswd -l>/etc/passwd,创建passwd文件,在passwd文件中把原来的用户名改为自己的想要的用户名caitingting,并在home目录下创建caitingting目录。