ps 명령어를 수행하면 user name이 짤려서 출력 되어 grep을 하면 원하는 결과가 나오지 않는다.
[root@junsu-desktop ~]docker_host# cat /etc/passwd
aaaaaaaaaaaaaaaaaa:x:1002:1002::/home/aaaaaaaaaaaaaaaaaa:/bin/sh
[root@junsu-desktop ~]docker_host# ps -ef |grep top
aaaaaaa+ 2653915 2653912 0 01:39 pts/3 00:00:00 top
root 2653924 2653776 0 01:39 pts/2 00:00:00 grep --color=auto top
ps 결과 출력 포맷 변경
ps -eo 옵션을 사용하여 유저명이 짤리지 않게 출력 합니다.
[root@junsu-desktop ~]docker_host# ps -eo uname |grep aa
aaaaaaaaaaaaaaaaaa
유저명이 짤리지 않고 ps -ef와 동일한 결과를 만들어 보겠습니다.
[root@junsu-desktop ~]docker_host# ps -ef |more
UID PID PPID C STIME TTY TIME CMD
[root@junsu-desktop ~]docker_host# ps -eo uname:20,pid,ppid,c,sz,stime,tty,cmd
USER PID PPID C SZ STIME TT CMD
root 1 0 0 42453 10월02 ? /sbin/init splash
root 2 0 0 0 10월02 ? [kthreadd]
root 3 2 0 0 10월02 ? [rcu_gp]
root 4 2 0 0 10월02 ? [rcu_par_gp]
[root@junsu-desktop ~]docker_host# ps -eo uname:20,pid,ppid,c,sz,stime,tty,cmd |grep top
avahi 912 1 0 2168 10월02 ? avahi-daemon: running [junsu-desktop.local]
aaaaaaaaaaaaaaaaaa 2653915 2653912 0 3570 01:39 pts/3 top
root 2654968 2653776 0 2590 01:54 pts/2 grep --color=auto top