lsof and dynamic array in bash/shell
https://unix.stackexchange.com/questions/171519/lsof-warning-cant-stat-fuse-gvfsd-fuse-file-system
FUSE and its access rights
lsof
by default checks all mounted file systems
including FUSE - file systems implemented in user
space which have special access rights in Linux.
As you can see in this answer on Ask
Ubuntu a mounted GVFS
file system (special case of FUSE) is normally accessible only
to the user which mounted it (the owner of gvfsd-fuse
).
Even root
cannot access it. To override this
restriction it is possible to use mount options allow_root
and allow_other
. The option must be also enabled
in the FUSE daemon which is described for example in this answer ...but
in your case you do not need to (and should not) change the
access rights.
Excluding file systems from lsof
In your case lsof
does not need to check the GVFS
file systems so you can exclude the stat()
calls
on them using the -e
option (or you can just
ignore the waring):
lsof -e /run/user/1000/gvfs
Checking certain files by lsof
You are using lsof
to get information about all processes running on your system and only then you filter the complete output using grep
. If you want to check just certain files and the related processes use the -f
option without a value directly following it then specify a list of files after the "end of options" separator --
. This will be considerably faster.
lsof -e /run/user/1000/gvfs -f -- /tmp/report.csv
General solution
To exclude all mounted file systems on which stat()
fails you can run something like this (in bash
):
x=(); for a in $(mount | cut -d' ' -f3); do test -e "$a" || x+=("-e$a"); done
lsof "${x[@]}" -f -- /tmp/report.csv
Or to be sure to use stat()
(test -e
could be implemented a different way):
x=(); for a in $(mount | cut -d' ' -f3); do stat --printf= "$a" 2>/dev/null || x+=("-e$a"); done
lsof
always tries to obtain some basic information about all filesystems, even if the arguments happen to imply that no result will come from a particular filesystem. If it's unable to access a filesystem (specifically, to call stat
at its mount point, as the message says), it complains.
As root, you would normally have permission to access filesystems. However, due to the inner workings of FUSE, root does not automatically have all powers on a FUSE filesystem. This isn't a security feature (root can become the user who owns the filesystem and get access that way), it's a technical limitation.
GVFS-FUSE is a FUSE interface to GVFS, which is a mechanism that allows Gnome applications to access virtual filesystems implemented by Gnome plugins: GVFS grants non-Gnome applications access to these virtual filesystems via the regular filesystem interface.
-- 刘林强 136-1133-1997
liulinqiang@unipus.cn
北京外研在线教育科技有限公司
外语教学与研究出版社
lsof and dynamic array in bash/shell的更多相关文章
- linux bash shell & lsof & grep & ps
linux bash shell & lsof & grep & ps lsof list all open files # lsof & grep $ lsof -P ...
- 第四章:更多的bash shell命令
第四章:更多的bash shell命令 监测程序 ps (其他ps内容见#1 ) Unix风格的ps命令参数 参数 描述 -A 显示所有进程 -N 显示与指定参数不符的所有进程 -a 显示除控制进程( ...
- 系统管理中 bash shell 脚本常用方法总结
在日常系统管理工作中,需要编写脚本来完成特定的功能,编写shell脚本是一个基本功了!在编写的过程中,掌握一些常用的技巧和语法就可以完成大部分功能了,也就是2/8原则 1. 单引号和双引号的区别 单引 ...
- Linux 常用命令解析和Bash Shell使用示例脚本演示
摘要 Linux命令是基于文本格式输入输出的一种程序,依照Unix哲学中强调的程序功能简单,输入宽松,输出严谨,各种程序组合能够具有更强大的功能,而具有这样的灵活性的主要原因是Linux规定程序 ...
- 《Linux命令行与shell脚本编程大全》- 读书笔记2 - 更多的bash shell命令
更多的bash shell命令 想检测进程,需要熟悉ps命令的用法.ps命令好比工具中的瑞士军刀,它能输出运行在系统上的所有程序的许多信息.默认情况下,ps命令只会显示运行在当前控制台下的属于当前用户 ...
- 鸟哥的Linux私房菜——第十四章:Bash Shell
视频链接:http://www.bilibili.com/video/av10094012/ 本章目录: 1. Bash shell1.1 什么是 shell ? (我们通过shell与Kernel核 ...
- linux 9 -- 交互式使用Bash Shell
二十二. 交互式使用Bash Shell: 1. 用set命令设置bash的选项: 下面为set主要选项的列表及其表述: 选项名 开关缩写 描述 allexport -a 打开此开关 ...
- bash shell
Linux的shell 与windows只有一种批处理脚本不同,由于早年的Unix年代,发展者众,出现了各种不同的distribution,因此也随着不同的distribution出现了各自的shel ...
- Bash Shell内建命令和保留字
Bash Shell内建命令和保留字命令含义!保留字,逻辑非:不做任何事,只做参数展开.读取文件并在shell中执行它alias设置命令或命令行别名bg将作业置于后台运行bind将关键字序列与read ...
随机推荐
- 如何解决:对应的服务器 tls 为 tls 1.0,小程序要求的TLS版本必须大于等于1.2问题
微信小程序 TLS 版本必须大于等于1.2问题解决 此问题最近在微信小程序开发中,比较常见. 在解决这个问题之前,我们需要了解一下,当前的系统环境是否支持TLS1.2以上,可以参考一下表格: 请先确认 ...
- sublime text 3 环境变量的配置、安装Package Control、汉化和注册
1.在运行里输入sysdm.cpl打开环境变量设置界面,输入sublime的安装目录,分号和之前的隔开 2.下载好Package Control,解压重命名为package control 下载地址: ...
- vue2.0 实现click点击当前li,动态切换class
1,文件内容 ----//为item添加不存在的属性,需要使用vue提供的Vue.set( object, key, value )方法. 看详解:https://cn.vuejs.org/v2/a ...
- Ramda函数式编程之PHP
0x00 何为函数式编程 网上已经有好多详细的接受了,我认为比较重要的有: 函数是"第一等公民",即函数和其它数据类型一样处于平等地位 使用"表达式"(指一个单 ...
- 【emWin】例程二十六:窗口对象——Listbox
简介: 列表框用于选择列表的一个元素.创建的列表框可以没有环绕的框架窗口,或者作为 FRAMEWIN 小工具的子窗口建立列表框中的项目被选定后,会突出显示. 触摸校准(上电可选择是否进入校准界面) 示 ...
- centos 扩容
1. 查看挂载点信息: [root@localhost]# df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/mapper/centos-root 18G 15G 2.9G 84% / ...
- js 规范
1.原型链的弊端是不支持多重继承.记住,原型链会用另一类型的对象重写类的 prototype 属性 2.注意:调用 ClassA 的构造函数,没有给它传递参数.这在原型链中是标准做法.要确保构造函数没 ...
- 初试 Kubernetes 集群中使用 Traefik 反向代理
初试 Kubernetes 集群中使用 Traefik 反向代理 2017年11月17日 09:47:20 哎_小羊_168 阅读数:12308 版权声明:本文为博主原创文章,未经博主允许不得转 ...
- Spring配置-数据库连接池proxool[转]
数据库连接是一种关键的有限的昂贵的资源,这一点在多用户的网页应用程序中体现得尤为突出.对数据库连接的管理能显著影响到整个应用程序的伸缩性和健壮性,影响到程序的性能指标.数据库连接池正是针对这个问题提出 ...
- 小程序返回顶部top滚动
wxjs const app = getApp(); Page({ data:{ // top标签显示(默认不显示) backTopValue:false }, // 监听滚动条坐标 onPageSc ...