列出我的用户的所有进程名。
我可以用
ps aux | grep username但是输出就像:
maythux 18343 0.0 0.1 1070868 34504 ? Sl Jun03 0:07 empathy
maythux 21562 0.0 0.1 703716 32104 ? Sl Jun10 0:00 /usr/bin/python /usr/bin/blueman-applet
maythux 21574 0.0 0.0 53532 2408 ? S Jun10 0:00 /usr/bin/obex-data-server --no-daemon
maythux 25197 0.0 1.0 2199840 258576 ? Sl May27 0:24 remmina但我只想让输出看起来像:
empathy
blueman-applet
obex-data-serve
remmina那么,最简单的方法是什么呢?
发布于 2015-06-13 10:19:13
您可以轻松地使用ps命令本身来完成它,而无需任何其他工具:
ps -U user-name -o comm= 如果要对重复项进行排序和删除,可以这样做:
ps -U user-name -o comm= | sort | uniq下面是我输出的一个示例:
liferea
mission-control
nacl_helper
nautilus
nm-applet
notify-osd
nxclient.bin
nxnode.bin
obex-data-serve
okular
polkit-gnome-au发布于 2015-06-30 15:00:58
为了完成任务,还可以使用pgrep:
pgrep -lU foobar这将匹配用户foobar的真实用户ID。这将显示带有PID的输出。
如果只想要进程名,还需要删除重复项:
pgrep -lU foobar | cut -d' ' -f2 | sort -u ##Using RUID
pgrep -lu foobar | cut -d' ' -f2 | sort -u ##Using EUIDhttps://askubuntu.com/questions/635938
复制相似问题