fuser 概述

fuser命令是用来显示所有正在使用着指定的file, file system 或者 sockets的进程信息。

例一:

#fuser –m –u /mnt/usb1 
/mnt/usb1:  1347c(root)  1348c(guido)  1349c(guido)

在例子一中,使用了-m和-u选项,用来查找所有正在使用/mnt/usb1的所有进程的PID已经该进程的OWNER,如1347c(root),其中1347是进程PID,root是该进程的OWNER。

fuser会显示正在使用指定的file,file system 或者 sockets的进程的PID。在默认的显示模式下,每个文件名之后会跟随一个字符,用来指示当前的访问类型。

如下所示:

c current directory.e executable being run.f open file.F open file for writing.r root directory.m mmap'ed file or shared library

同时fuser 可以用来查找哪些进程正在使用指定的network port。

[root@bl25p-19 /]# fuser -v -n tcp 111

USER        PID   ACCESS   COMMAND 
111/tcp:             rpc        2848   F....         portmap

fuser 的返回值:

fuser如果没有找到任何进程正在使用指定的file, filesystem 或 socket, 或者在查找过程中发生了fatal error,则返回non-zero 值。

fuser如果找到至少一个进程正在使用指定的file, filesystem 或 socket,则返回zero。

fuser 常用场景

fuser通常被用在诊断系统的“resource busy”问题,通常是在你希望umount指定的挂载点得时候遇到。 如果你希望kill所有正在使用某一指定的file, file system or sockets的进程的时候,你可以使用-k option。

fuser –k /path/to/your/filename

这时fuser会向所以正在使用/path/to/your/filename的进程发送SIGKILL。如果你希望在发送之前得到提示,可以使用-i 选项。

fuser –k –i /path/to/your/filename

fuser的其他有用的参数

-k 
kills all process accessing a file. For example fuser -k /path/to/your/filename kills all processes accessing this directory without confirmation. Use -i for confirmation
-i 
interactive mode. Prompt before killing process
-v 
verbose.
-u 
append username
-a 
display all files
-m 
name specifies a file on a mounted file system or a block device that is mounted. All processes accessing files on that file system are listed. If a directory file is specified, it is automatically changed to name/. to use any file system that might be mounted on that directory.

fuser 命令概述的更多相关文章

  1. fuser 命令小结

    fuser 概述 fuser命令是用来显示所有正在使用着指定的file, file system 或者 sockets的进程信息. 例一: #fuser –m –u /mnt/usb1 /mnt/us ...

  2. #linux包之psmisc之fuser命令

    概述 [root@localhost ~]# rpm -qf /sbin/fuserpsmisc-22.6-15.el6_0.1.x86_64 先说 fuser的作用,fuser能识别出正在对某个文件 ...

  3. yum 安装fuser命令

    yum install -y psmisc 转自:https://www.cnblogs.com/saneri/p/5465718.html 有时候我们需要umount某个挂载目录时会遇到如下问题: ...

  4. fuser命令找到占用资源的进程

    fuser 概述 fuser命令是用来显示所有正在使用着指定的file, file system 或者 sockets的进程信息. 例一: #fuser –m –u /mnt/usb1 /mnt/us ...

  5. fuser命令使用心得

    fuser命令可用于查看正使用指定file, file system, socket port的进程信息.使用-k参数可将这些进程杀掉,-i则在杀掉进程前给出提示 例子: [root@bogon ~] ...

  6. Linux学习笔记之三————Linux命令概述

    一.引言 很多人可能在电视或电影中看到过类似的场景,黑客面对一个黑色的屏幕,上面飘着密密麻麻的字符,梆梆一顿敲,就完成了窃取资料的任务. Linux 刚出世时没有什么图形界面,所有的操作全靠命令完成, ...

  7. Linux运维之如何查看目录被哪些进程所占用,lsof命令、fuser命令

    之前将一块硬盘挂载到某个目录下,但是现在我想卸载掉这块硬盘,无论如何都umount不了,有些同学可能说需要加上 -f 参数强制卸载,理论上是可以的,但是在我这里依然不起作用,比如: [root@:vg ...

  8. fuser命令

    fuser命令 http://blog.itpub.net/27573546/viewspace-765240/

  9. Linux的fuser命令解析

    fuser命令是用来显示所有正在使用着指定的file, file system 或者 sockets的进程信息. 例一: #fuser –m –u /mnt/usb1 /mnt/usb1: 1347c ...

随机推荐

  1. 理解shared_ptr<T> ---2

    1.引用计数字段不能放在资源管理类中.我们的解决办法是,把引用计数和资源绑在一起,进行二次封装.但是这样存在一个大问题,不同类型的资源管理类不能兼容.也就是说,shared_ptr<Dog> ...

  2. BAPI_ACC_DOCUMENT_POST Enter rate / GBP rate type M for Error SG105

    Folks, I was wondering if I could get a bit of help here as I've been racking my brains on it for ag ...

  3. 学习笔记之SQL Programming DB2

    http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp If you intend to update a column or ...

  4. 用C# sqlserver实现增删改查

    using System.Data;using System.Data.SqlClient;//先打开两个类库文件SqlConnection con = new SqlConnection(); // ...

  5. mysql之sql语句细节问题汇总

    一.mysql count distinct null 使用注意事项 1  用一个例子来讲解一个问题,现在又一个库表hello,表内容如下: id     name 1      Null 2     ...

  6. Android(java)学习笔记118:类继承的注意事项

    /* 继承的注意事项: A:子类只能继承父类所有非私有的成员(成员方法和成员变量) B:子类不能继承父类的构造方法,但是可以通过super(马上讲)关键字去访问父类构造方法. C:不要为了部分功能而去 ...

  7. Pester: Unit Testing for PowerShell

    Pester is a BDD inspired testing framework for PowerShell just like Jasmine is on the JavaScript sid ...

  8. NUMA CPU optimization

    technologies:  OS, CPU cache, numa structure, memory access

  9. 210 - Concurrency Simulator(WF1991, deque, 模拟)

    题目有点长,理解题花了不少时间 粘下别人的翻译~ 你的任务是模拟n个程序(按输入顺序编号为1~n)的并行执行.每个程序包含不超过25条语句,格式一共有5种: var=constant(赋值): pri ...

  10. CENTOS install summary

    1 centos6.5 before version : first :ultraISO write into u disk,second: copy source iso file into u d ...