cc你cc

导航

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

 


  • 姓名  彭晨
  • 学号  201821121039
  • 班级  计算1812

1. 实验环境介绍

  • 操作系统:Microsoft Windows [版本 10.0.18362.657]
  • 平台:Cygwin
  • 用户名:PengChen

 

      

 

 

  • 2. 常用命令使用

    简单使用 ls -ls,pwd,man,help几个命令,如下(help命令截取部分):

  •  

     

     

     

     

    3. 剖析ps命令

    运行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 processes.

    By default, ps shall select all processes with the same effective user ID as the current user and the same controlling terminal as the invoker.

    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 terminals. 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 ar‐
    gument 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 specification shall be interpreted as the <space>-separated concatenation 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 systems,
    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 login names are given in userlist. The application shall ensure that the userlist is a sin‐
    gle argument in the form of a <blank> or <comma>-separated list. In the listing, the numerical user ID shall be written unless the −f option is used,
    in which case the login name shall be written.

  • 运行命令"ps aux"的返回结果:

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

          -e : 显示所有进程信息。

          -f :使用完整的(full)格式显示进程信息。

    解释返回结果每个字段的含义:

      UID :启动该进程的用户ID号。

      PID :进程ID号。

      PPID :该进程的父进程ID号。

      PGID :进程组ID。

      C :CPU使用的资源百分比。

      STIME :进程启动时间。

      WINPID :windows下的pid。

      TTY :启动进程的终端名。

      TIME :该进程使用CPU的累计时间。

      COMMAND :进程所运行的命令。

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

    怎么把用户名改为自己的名字?

    首先需要使用mkpasswd -l > /etc/passwd 语句创建,然后笔记本打开cygwin目录下的/etc/passwd文件,将用户名改为自己名字的拼音;接着在home目录下建立相应的名字拼音。这样用户名就修改好了。

     

posted on 2020-03-07 17:46  cc你cc  阅读(202)  评论(0编辑  收藏  举报