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

  • 姓名:许德阳
  • 学号:201821121045
  • 班级:计算1812

1. 实验环境介绍

实验环境:

  • 操作系统:Microsoft Windows(版本10.0.18362.657)
  • 平台: Cygwin

 

 

2. 常用命令使用

ls -ls

 

man

 

 

help

 

 

 

3. 剖析ps命令

(1)man ps

使用方法:

PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux
implementation of this interface may differ (consult the corresponding
Linux manual page for details of Linux behavior), or the interface may
not be implemented on Linux.

NAME
ps — report process status

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.)

−g grouplist
Write information for processes whose session leaders are
given in grouplist. The application shall ensure that the
grouplist is a single argument in the form of a <blank> or
<comma>-separated list.

−G grouplist
Write information for processes whose real group ID numbers
are given in grouplist. The application shall ensure that
the grouplist is a single argument in the form of a <blank>
or <comma>-separated list.

−l Generate a long listing. (See STDOUT for the contents of a
long listing.)

−n namelist
Specify the name of an alternative system namelist file in
place of the default. The name of the default file and the
format of a namelist file are unspecified.

−o format Write information according to the format specification given
in format. This is fully described in the STDOUT section.
Multiple −o options can be specified; the format specifica‐
tion shall be interpreted as the <space>-separated concate‐
nation of all the format option-arguments.

−p proclist
Write information for processes whose process ID numbers are
given in proclist. The application shall ensure that the
proclist is a single argument in the form of a <blank> or
<comma>-separated list.

−t termlist
Write information for processes associated with terminals
given in termlist. The application shall ensure that the
termlist is a single argument in the form of a <blank> or
<comma>-separated list. Terminal identifiers shall be given
in an implementation-defined format. On XSI-conformant sys‐
tems, they shall be given in one of two forms: the device's
filename (for example, tty04) or, if the device's filename
starts with tty, just the identifier following the characters
tty (for example, "04").

−u userlist
Write information for processes whose user ID numbers or lo‐
gin names are given in userlist. The application shall en‐
sure that the userlist is a single argument in the form of a
<blank> or <comma>-separated list. In the listing, the nu‐
merical user ID shall be written unless the −f option is
used, in which case the login name shall be written.

−U userlist
Write information for processes whose real user ID numbers or
login names are given in userlist. The application shall
ensure that the userlist is a single argument in the form of
a <blank> or <comma>-separated list.

 

 

(2)运行并解释ps命令参数:

    1. 运行ps:

   2.运行ps -ef:

 

 参数的含义:

 参数-e能够显示用户的所有进程;
 参数-f能够显示进程的UID、PID和STIME。

每个字段的含义

UID:用户ID 

PID:进程ID

PPID:父进程ID

STIME:进程启动到现在的时间

TTY:终端的次要装置号码

COMMAND:命令的名字

 3.运行ps -aux:

参数含义:

a:显示终端机下的所有程序,包括其他用户的程序

u:以用户为主的格式显示程序状况

x:显示所有程序

每个字段的含义

UID:用户ID 

PID:进程ID

PPID:父进程ID

PGID:进程组ID

TTY:终端的次要装置号码

STIME:进程启动到现在的时间

COMMAND:命令的名字

WINPID:windows下的PID规则

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

1.在改名问题上一开始我的用户名为lenovo,我尝试去更改了系统的用户名,但是没用。之后通过同学的帮助,在Cygwin中输入mkpasswd -| > /etc/passwd,即可在Cygwin目录里的etc找到passwd打开将其中有你原用户名的一行,即我的lenovo全部改为xudeyang,之后保存打开Cygwin就改名成功了。

2.每次输入相同的命令,所得的UID,PID等都有改变,但程度非常细微。每次命令程序的进程具有兼容性。

3.在一开始,输入man ps时出现没有ps的手册目录条,通过在usr的share中删除原有的man并加入新的包并改名为man,之后即可。

 

posted on 2020-03-05 23:11  xudeyang  阅读(180)  评论(0编辑  收藏  举报