可以使用:ps -fe|grep filename,
也可以使用:fuser filename查看
然后可以看这个进程跟哪里东西有关联专,使用了哪些端口属
只查看该进程:ps -ef | grep ID
查看该进程打开的文件:lsof -p ID
查看内存分配:lcat /proc/ID/maps
查看堆栈:pstack 11ID
查看发出的系统调用:strace -p ID
查看调用库函数:ltrace -p ID
『贰』 如何查看linux进程占用的内容
1.只查看该进程:ps
-ef
|
grep
11345
2.查看该进程打开的文件:专lsof
-p
11345
3.查看内存分配:lcat
/proc/11345/maps
4.查看堆栈:pstack
11345
5.查看发出的系统属调用:strace
-p
11345
6.查看调用库函数:ltrace
-p
11345
『叁』 linux 怎么查看segmentation fault堆栈
gdb ExeName
(gdb)core core.xx
(gdb)bt
core mp 一般是在segmentation fault(段来错误)的情源况下产生的文件,需要通过ulimit来设置才会得到的。关于Linux命令的介绍,看看《linux就该这么学》,具体关于这一章地址3w(dot)linuxprobe/chapter-02(dot)html.
『肆』 linux ps命令显示一个特定的进程信息,如下说明
ps
ps(即进程状态)命令用于提供有关当前正在运行的进程的信息,包括其进程标识号(PID)。
进程,也称为任务,是程序的执行(即,运行)实例。系统为每个进程分配一个唯一的PID。
ps的基本语法是
ps [options]
当没有任何选项使用ps时,它会发送到标准输出,默认情况下是显示监视器,系统上当前至少有两个进程的四项信息:shell和ps。shell是一个程序,它在类Unix操作系统中提供传统的纯文本用户界面,用于发出命令并与系统交互,默认情况下在Linux上是bash。ps本身是一个进程,一旦显示输出它就会死掉(即终止)。
使用ps获取有关系统当前进程的更完整信息的常用方便方法是使用以下方法:
ps -aux | less
ps显示的进程可以限制为属于任何给定用户的进程,方法是通过grep(一种用于搜索文本的过滤器)输出输出。例如,属于具有用户名adam的用户的进程可以使用以下内容显示:
ps -ef | grep adam
Linux 下 取进程占用 cpu 最高的前10个进程
ps aux|head -1;ps aux|grep -v PID|sort -rn -k +3|head
linux 下 取进程占用内存(MEM)最高的前10个进程
ps aux|head -1;ps aux|grep -v PID|sort -rn -k +4|head
其中rsz是是实际内存
$ ps -e -o 'pid,comm,args,pcpu,rsz,vsz,stime,user,uid'
$ ps -e -o 'pid,comm,args,pcpu,rsz,vsz,stime,user,uid' | grep oracle | sort -nrk5
其中rsz为实际内存,上例实现按内存排序,由大到小
5个命令检查Linux中内存使用情况,含PS
『伍』 Linux 怎么查看一个进程的堆栈
方法一:pstack pid
NAME
pstack - print a stack trace of a running process
SYNOPSIS
pstack pid
DESCRIPTION
pstack attaches to the active process named by the pid on the command line, and prints out an execution stack trace. If ELF symbols exist in the binary (usually the case
unless you have run strip(1)), then symbolic addresses are printed as well.
If the process is part of a thread group, then pstack will print out a stack trace for each of the threads in the group.
SEE ALSO
nm(1), ptrace(2), gdb(1)
方法二:gstack pid
NAME
gstack - print a stack trace of a running process
SYNOPSIS
gstack pid
DESCRIPTION
gstack attaches to the active process named by the pid on the command line, and prints out an execution stack trace. If ELF symbols exist in the binary (usually the case
unless you have run strip(1)), then symbolic addresses are printed as well.
If the process is part of a thread group, then gstack will print out a stack trace for each of the threads in the group.
SEE ALSO
nm(1), ptrace(2), gdb(1)
方法三:
使用gdb 然后 进程ID,然后再使用命令 thread apply all bt。
方法一和方法二一样,方法三可以查看更多的信息。
『陆』 linux 查看文件被哪个进程打开
可以使用:ps -fe|grep filename,
也可以使用:fuser filename查看
然后可以看这个进程跟哪里东西有关联,使用了哪些端口
只查看该进程:ps -ef | grep ID
查看该进程打开的文件:lsof -p ID
查看内存分配:lcat /proc/ID/maps
查看堆栈:pstack 11ID
查看发出的系统调用:strace -p ID
查看调用库函数:ltrace -p ID
『柒』 linux查看文件被哪个进程占用
可以使用ps -fe|grep filename,也可以使用fuser filename查看
1.只查看该进程:ps -ef | grep 11345
2.查看该进程打开版的文件:lsof -p 11345
3.查看内存权分配:lcat /proc/11345/maps
4.查看堆栈:pstack 11345
5.查看发出的系统调用:strace -p 11345
6.查看调用库函数:ltrace -p 11345