0
点赞
收藏
分享

微信扫一扫

Linux查看文件被哪个进程占用(fuser、lsof、pidof)

minute_5 2022-01-20 阅读 121
linux进程

一、fuser  

<0>.查看某个进程的pid
# fuser /usr/bin/pulseaudio 
/usr/bin/pulseaudio: 11206e

<1>.查看当前目录正在被哪些进程在使用
# fuser -uv .
用户     进程号 权限   命令
/home/test:       test    3022 ..c.. (test)gnome-session-b
                  test    3053 ..c.. (test)dbus-daemon

<2>.查看/lib/x86_64-linux-gnu/libc-2.27.so正在被哪些进程在使用
# fuser -uv /lib/x86_64-linux-gnu/libc-2.27.so
用户     进程号 权限   命令
/lib/x86_64-linux-gnu/libc-2.27.so:
                     test    2983 ....m (test)systemd
                     test    3022 ....m (test)gnome-session-b
                     test    3047 ....m (test)fcitx
                     test    3053 ....m (test)dbus-daemon
                     test    3073 ....m (test)dbus-daemon

<3>.查看/proc这个目录有哪些进程在使用
# fuser -uv /proc
                     用户     进程号 权限   命令
/proc:               root     kernel mount (root)/proc
                     test    8736 f.... (test)nacl_helper
                     test    8739 f.... (test)chrome
                     test    8789 f.... (test)chrome
                     test   10621 f.... (test)Typora
                     test   10654 f.... (test)Typora

<4>.那些进程在进行/proc文件系统的读取
# fuser -muv /proc
                     用户     进程号 权限   命令
/proc:               root     kernel mount (root)/proc
                     test    2983 f.... (test)systemd
                     test    3258 f.... (test)gvfs-udisks2-vo
                     test    3369 f.... (test)gsd-housekeepin
                     test    4185 f.... (test)gnome-software
                     test    4754 f.... (test)gvfsd-trash
                     test    8735 .rc.. (test)chrome
                     test    8736 frc.. (test)nacl_helper

<5>.杀死/home占用home目录的所有进程
# fuser -mki /home



二、lsof

1.查看那些进程占用/lib/x86_64-linux-gnu/libc-2.27.so
# lsof |grep /lib/x86_64-linux-gnu/libc-2.27.so

三、pidof

1.查看某个进程的pid
# pidof pulseaudio 
11206
举报

相关推荐

0 条评论