- 考察点:Linux常用命令
- 难度: 简单
- 题目:在Linux命令中,ps -ef 与 ps -au 有什么区别,请详细说明
ps:每周一公布上周所有题目答案
ps:每周一公布上周所有题目答案
ps
命令是Process Status的缩写,用来列出系统中当前运行的进程。使用该命令可以确定有哪些进程正在运行和运行的状态、进程是否结束、进程有没有僵死、哪些进程占用了过多的资源等等。ps命令所列出的进行是当前进程的快照,也就是并不是动态的,而是执行该命令时那一时刻进行的状态。
-A
: 显示所有进程。a
: 显示一个终端的所有进程,除了会话引线u
: uid or username 选择有效的用户id或者是用户名-e
:此参数的效果和指定"A"参数相同。-f
: 全部列出,通常和其他选项联用。[root@xxxxx ~]# ps -au
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1103 0.0 0.0 110208 4 tty1 Ss+ 10月30 0:00 /sbin/agetty --noclear tty1 li
root 1104 0.0 0.0 110208 4 ttyS0 Ss+ 10月30 0:00 /sbin/agetty --keep-baud 11520
root 2051 0.0 0.0 3856 1904 ? Ss 12月25 0:00 bash
root 2081 0.0 0.1 18048 4948 ? S+ 12月25 0:00 mysql -uroot -px xxxx
root 3653 0.0 0.0 3856 1904 ? Ss 12月25 0:00 bash
root 3706 0.0 0.1 17748 4680 ? S+ 12月25 0:00 mysql -uroot -px xxxx
root 10323 0.0 0.0 3856 1904 ? Ss 12月25 0:00 bash
root 10352 0.0 0.1 17748 4688 ? S+ 12月25 0:00 mysql -uroot -px xxxx
root 15696 0.0 0.0 3856 1996 pts/0 Ss 11月19 0:00 /bin/bash
root 15803 0.0 0.1 18060 4872 pts/0 S+ 11月19 0:00 mysql -uroot -px xxxx
root 21417 0.0 0.0 3856 1896 ? Ss+ 12月11 0:00 bash
root 27197 0.1 0.0 116732 3164 pts/0 Ss 22:01 0:00 -bash
root 27397 0.0 0.0 155452 1876 pts/0 R+ 22:01 0:00 ps -au
[root@ytq-cloud ~]# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 10月30 ? 00:00:46 /usr/lib/systemd/systemd --switched-root --system
root 2 0 0 10月30 ? 00:00:00 [kthreadd]
root 4 2 0 10月30 ? 00:00:00 [kworker/0:0H]
root 6 2 0 10月30 ? 00:00:30 [ksoftirqd/0]
root 7 2 0 10月30 ? 00:00:06 [migration/0]
root 8 2 0 10月30 ? 00:00:00 [rcu_bh]
root 9 2 0 10月30 ? 00:14:28 [rcu_sched]
root 10 2 0 10月30 ? 00:00:00 [lru-add-drain]
...省略
ps -ef用于查看全格式的全部进程,ps -aux也是用于查看进程。
ps -ef和ps aux,这两者的输出结果差别不大,但是展示样式不一样
COMMADN列如果过长,aux会截断显示,而ef不会。