Linux/Unix_极客玩家大白

Linux/Unix

2022/03/08

类 Unix 系统下的一些常用命令和用法。

实用命令

fuser

查看文件被谁占用。

1
fuser -u .linux.md.swp

id

查看当前用户、组 id。

lsof

查看打开的文件列表。

An open file may be a regular file, a directory, a block special file, a character special file, an executing text reference, a library, a stream or a network file (Internet socket, NFS file or UNIX domain socket.) A specific file or all the files in a file system may be selected by path.

查看网络相关的文件占用

1
lsof -i

查看端口占用

1
lsof -i tcp:5037

查看某个文件被谁占用

1
lsof .linux.md.swp

查看某个用户占用的文件信息

1
lsof -u bravo

-u 后面可以跟 uid 或 login name。

查看某个程序占用的文件信息

1
lsof -c Vim

注意程序名区分大小写。

版权声明

  • 本文作者:极客玩家大白
  • 本文链接:https://geekplayers.com/wiki/linux/
  • 郑重声明:本文为博主原创或经授权转载的文章,欢迎转载,但转载文章之后必须在文章页面明显位置注明出处,否则保留追究法律责任的权利。如您有任何疑问或者授权方面的协商,请留言。


一个有故事的程序员

(转载本站文章请注明作者和出处 极客玩家大白

点击了解 :.NET技术人的网站