码迷,mamicode.com
首页 > 系统相关 > 详细

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

时间:2020-03-05 20:47:20      阅读:95      评论:0      收藏:0      [点我收藏+]

标签:使用   mkpasswd   lin   log   oci   with   str   解答   The   

  • 姓名:徐思婕
  • 学号:201821121004
  • 班级:计算1811

1. 实验环境介绍

给出实验环境:

  • 操作系统:Microsoft Windows [版本 10.0.18363.657]
  • 平台:Cygwin

用户名设为自己名字的拼音:

         技术图片

 

2. 常用命令使用

  • man

          技术图片

  • help

          技术图片

  • ls -a

          技术图片

  • ls -al

          技术图片 

 

3. 剖析ps命令

  • 运行man ps,将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.)

       −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.
  • ps命令有很多参数,运行命令ps -ef,给出你系统的返回结果:

          技术图片 

  • 解释ps -ef命令中参数的含义:

    -e:将所有信息写入进程;

    -f:生成完整的列表。

  • 解释返回结果每个字段的含义:
     UID:用户ID
PID:进程ID
PPID:父进程ID
C:CPU占用资源百分比
STIME:系统启动时间
TTY:终端的次要装置号码
COMMAND:执行的命令
  • 给出ps aux执行结果,解释命令中的参数:

          技术图片      

  • 解释ps aux命令中参数的含义:

     a:为终端相关的所有进程写入信息

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

     x:显示所有程序,不以终端机来区分

  • 对执行结果,每个字段进行解释:

      PGID:进程组ID

            COMMAND:所执行的指令

 

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

  • 如何修改cygwin的用户名:

          在cygwin中输入命令mkpasswd -l > /etc/passwd 生成password文件。在ect目录中找到这个文件并打开,将最后一行中的三处默认用户名更改为xusijie。接着在cygwin的   home目录下面建立目录xusijie,启动cygwin进入以后,用户名就更改完成了。                                                                                                                                                                    技术图片

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

标签:使用   mkpasswd   lin   log   oci   with   str   解答   The   

原文地址:https://www.cnblogs.com/hhh1360/p/12417193.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!