linux ps afx tty,理解 ps 参数 tty, a

感受:unp的命令,实践出真知啊》

unp原书源:

We can also use the ps command to check the status and relationship of these processes.

linux % ps -t pts/6 -o pid,ppid,tty,stat,args,wchan

PID  PPID TT       STAT COMMAND          WCHAN

22038 22036 pts/6    S    -bash            wait4

17870 22038 pts/6    S    ./tcpserv01      wait_for_connect

19315 17870 pts/6    S    ./tcpserv01      tcp_data_wait

19314 22038 pts/6    S    ./tcpcli01 127.0 read_chan

(We have used very specific arguments to ps to only show us the information that pertains to this discussion.) In this output, we ran the client and server from the same window (pts/6, which stands for pseudo-terminal number 6). The PID and PPID columns show the parent and child relationships. We can tell that the first tcpserv01 line is the parent and the second tcpserv01 line is the child since the PPID of the child is the parent's PID. Also, the PPID of the parent is the shell (bash).

问题当我键入后,失败:

os66@liuliu-os66:~/Downloads/fscap$ ps -t pts/6 -o pid,ppid,tty,stat,args,wchan

ERROR: TTY could not be found.

改变命令后:

os66@liuliu-os66:~/Downloads/fscap$ ps a-o pid,ppid,tty,stat,args,wchan

PID  PPID TT       STAT COMMAND                     WCHAN

993     1 tty4     Ss+  /sbin/getty -8 38400 tty4   n_tty_read

995     1 tty5     Ss+  /sbin/getty -8 38400 tty5   n_tty_read

1003     1 tty2     Ss+  /sbin/getty -8 38400 tty2   n_tty_read

1004     1 tty3     Ss+  /sbin/getty -8 38400 tty3   n_tty_read

1006     1 tty6     Ss+  /sbin/getty -8 38400 tty6   n_tty_read

1189  1171 tty7     Ss+  /usr/bin/X :0 -br -verbose  poll_schedule_timeout

1706     1 tty1     Ss+  /sbin/getty -8 38400 tty1   n_tty_read

14776  2844 pts/2    Ss   bash                        wait

14926 14776 pts/2    S+   FSCapture.exe               pipe_wait

15106  2844 pts/1    Ss   bash                        wait

15189  2844 pts/3    Ss   bash                        wait

15237  2844 pts/4    Ss   bash                        wait

15289 15189 pts/3    S+   /bin/bash                   n_tty_read

15333 15289 pts/3    S    ./S01                       inet_csk_wait_for_connect

15335 15106 pts/1    S+   ./C01 127.0.0.1             n_tty_read

15336 15333 pts/3    S    ./S01                       sk_wait_data

15358 15237 pts/4    R+   ps a -o pid,ppid,tty,stat,a -

小结:

我使用的终端不一定是 tty…

其中,参数a意思:all w/ tty, including other users

后续工作ps 的参数很多,请慢慢品味:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值