英文:
how to find owner of a process without ps
问题
Running nginx alpine image. ps is not installed and do not have permission to install ps using apt-get. I have the pid of process. Is there any way I can find out who the owner of process is ?
在这种情况下,我想找出谁在运行nginx主进程。
英文:
Running nginx alpine image. ps is not installed and do not have permission to install ps using apt-get. I have the pid of process. Is there any way I can find out who the owner of process is ?
In this case, I want to figure out who is running nginx master process.
答案1
得分: 6
使用 ls
命令在 proc 目录中查找进程所有者
ls -ld /proc/816
如果你有 stat
命令,你可以使用漂亮的格式显示只有所有者:
stat -c '%U' /proc/775
avahi
奖励:打印你的用户名而不查看 $USER
stat -c '%U' /proc/$$
英文:
Use ls
to find the process owner in the proc directory
ls -ld /proc/816
If you have stat
you can display just the owner with fancy formatting:
stat -c '%U' /proc/775
avahi
Bonus: print your user name without looking at $USER
stat -c '%U' /proc/$$
答案2
得分: 2
你可以在/proc/YOUR_PROCESS_ID/status
中找到与进程相关的所有信息,其中YOUR_PROCESS_ID
是你的进程的PID。
因此,你可以通过运行类似以下命令来获取进程的所有者:
cat /proc/YOUR_PROCESS_ID/status | grep "Uid" | cut -f 2 | id -nu
英文:
You can find all the information relative to a process in /proc/YOUR_PROCESS_ID/status
where YOUR_PROCESS_ID
is the PID of your process.
Therefore, you could get the owner of the process by simply running something like this:
cat /proc/YOUR_PROCESS_ID/status | grep "Uid" | cut -f 2 | id -nu
答案3
得分: 2
你可以使用 docker top 命令来获取有关在 Docker 容器内部运行的所有进程的详细信息
语法
docker top <容器ID或名称>
英文:
You can use docker top command to get details about all the processes running inside a docker container
Syntax
docker top <container ID or name>
答案4
得分: 0
如何从活动进程列表中检查?
top
如果要查找特定进程名称:
top | grep nginx
英文:
How about checking from active processes list?
top
If looking for specific process name:
top | grep nginx
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论