国产亚洲精品福利在线无卡一,国产精久久一区二区三区,亚洲精品无码国模,精品久久久久久无码专区不卡

當前位置: 首頁 > news >正文

建設企業(yè)網(wǎng)站對公百度網(wǎng)盤登錄入口官網(wǎng)

建設企業(yè)網(wǎng)站對公,百度網(wǎng)盤登錄入口官網(wǎng),蘇ICP備網(wǎng)站建設中企動力無錫,云服務器安裝win系統(tǒng)做網(wǎng)站Linux系統(tǒng)之lsof命令的基本使用 一、lsof命令的基本使用二、lsof命令的使用幫助2.1 lsof命令的help幫助信息2.2 lsof命令幫助解釋 三、lsof的基本使用3.1 直接使用lsof命令3.2 查看某個進程打開的所有文件3.3 查看某個用戶打開的所有文件3.4 查看某個文件被哪些進程打開3.5 查看…

Linux系統(tǒng)之lsof命令的基本使用

  • 一、lsof命令的基本使用
  • 二、lsof命令的使用幫助
    • 2.1 lsof命令的help幫助信息
    • 2.2 lsof命令幫助解釋
  • 三、lsof的基本使用
    • 3.1 直接使用lsof命令
    • 3.2 查看某個進程打開的所有文件
    • 3.3 查看某個用戶打開的所有文件
    • 3.4 查看某個文件被哪些進程打開
    • 3.5 查看某個端口被哪些進程占用
    • 3.6 查看某個目錄下被哪些進程打開的文件
    • 3.7 查看打開某個類型文件的進程列表
  • 四、lsof使用注意事項

在這里插入圖片描述

一、lsof命令的基本使用

lsof(list open files)命令是用于查看系統(tǒng)中打開文件的工具,可以列出當前系統(tǒng)打開的所有文件(包括文件、文件夾、網(wǎng)絡連接等),可以幫助我們查找一些占用磁盤空間或者占用網(wǎng)絡帶寬的進程。

二、lsof命令的使用幫助

2.1 lsof命令的help幫助信息

查看lsof命令的help幫助信息

[root@jeven ~]# lsof --help
lsof: illegal option character: -
lsof: -e not followed by a file system path: "lp"
lsof 4.87latest revision: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/latest FAQ: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQlatest man page: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/lsof_manusage: [-?abhKlnNoOPRtUvVX] [+|-c c] [+|-d s] [+D D] [+|-f[gG]] [+|-e s][-F [f]] [-g [s]] [-i [i]] [+|-L [l]] [+m [m]] [+|-M] [-o [o]] [-p s]
[+|-r [t]] [-s [p:s]] [-S [t]] [-T [t]] [-u s] [+|-w] [-x [fl]] [--] [names]
Defaults in parentheses; comma-separated set (s) items; dash-separated ranges.-?|-h list help          -a AND selections (OR)     -b avoid kernel blocks-c c  cmd c ^c /c/[bix]  +c w  COMMAND width (9)    +d s  dir s files-d s  select by FD set   +D D  dir D tree *SLOW?*   +|-e s  exempt s *RISKY*-i select IPv[46] files  -K list tasKs (threads)    -l list UID numbers-n no host names         -N select NFS files        -o list file offset-O no overhead *RISKY*   -P no port names           -R list paRent PID-s list file size        -t terse listing           -T disable TCP/TPI info-U select Unix socket    -v list version info       -V verbose search+|-w  Warnings (+)       -X skip TCP&UDP* files     -Z Z  context [Z]-- end option scan+f|-f  +filesystem or -file names     +|-f[gG] flaGs-F [f] select fields; -F? for help+|-L [l] list (+) suppress (-) link counts < l (0 = all; default = 0)+m [m] use|create mount supplement+|-M   portMap registration (-)       -o o   o 0t offset digits (8)-p s   exclude(^)|select PIDs         -S [t] t second stat timeout (15)-T qs TCP/TPI Q,St (s) info-g [s] exclude(^)|select and print process group IDs-i i   select by IPv[46] address: [46][proto][@host|addr][:svc_list|port_list]+|-r [t[m<fmt>]] repeat every t seconds (15);  + until no files, - forever.An optional suffix to t is m<fmt>; m must separate t from <fmt> and<fmt> is an strftime(3) format for the marker line.-s p:s  exclude(^)|select protocol (p = TCP|UDP) states by name(s).-u s   exclude(^)|select login|UID set s-x [fl] cross over +d|+D File systems or symbolic Linksnames  select named files or files on named file systems
Anyone can list all files; /dev warnings disabled; kernel ID check disabled.

2.2 lsof命令幫助解釋

  • 語法
lsof [選項] [文件、目錄名或進程ID]
  • 選項
-a:列出打開文件存在的進程;
-c<進程名>:列出指定進程所打開的文件;
-g:列出GID號進程詳情;
-d<文件號>:列出占用該文件號的進程;
+d<目錄>:列出目錄下被打開的文件;
+D<目錄>:遞歸列出目錄下被打開的文件;
-n<目錄>:列出使用NFS的文件;
-i<條件>:列出符合條件的進程(協(xié)議、:端口、 @ip )
-p<進程號>:列出指定進程號所打開的文件;
-u:列出UID號進程詳情;
-h:顯示幫助信息;
-v:顯示版本信息

三、lsof的基本使用

3.1 直接使用lsof命令

使用lsof命令可以列出當前系統(tǒng)中打開的所有文件和網(wǎng)絡連接,包括哪些進程打開了哪些文件、哪些網(wǎng)絡連接被哪些進程使用等等。

lsof
command     PID USER   FD      type             DEVICE     SIZE       NODE NAME

在這里插入圖片描述

COMMAND列:打開文件的進程的名稱。
PID列:打開文件的進程的標識符。
USER列:打開文件的進程的所有者。
FD列:打開文件的進程的文件描述符。
TYPE列:打開文件的類型,如REG(常規(guī)文件)、DIR(目錄)、CHR(字符設備)、FIFO(管道)、SOCK(套接字)等。
DEVICE列:打開文件所在的設備的編號。
SIZE/OFF列:文件的大小或偏移量。
NODE列:打開文件的節(jié)點號碼。
NAME列:打開文件的路徑和文件名。

3.2 查看某個進程打開的所有文件

例如查詢sshd服務進程的PID號

[root@jeven ~]# ps aux |grep ssh
root       9347  0.0  0.0 112756  4312 ?        Ss   06:22   0:00 /usr/sbin/sshd -D
root      30102  0.0  0.0 161316  6052 ?        Ss   17:14   0:00 sshd: root@pts/1
root      30109  0.0  0.0 161312  6040 ?        Ss   17:14   0:00 sshd: root@notty
root      30154  0.0  0.0  74176  2940 ?        Ss   17:14   0:00 /usr/libexec/openssh/sftp-server
root      31429  0.0  0.0 112712   968 pts/1    S+   18:57   0:00 grep --color=auto ssh

使用lsof查詢該進程打開的所有文件

lsof -p 9347

在這里插入圖片描述

3.3 查看某個用戶打開的所有文件

查看某個用戶打開的所有文件

[root@jeven ~]# lsof -u apache |head
COMMAND   PID   USER   FD      TYPE             DEVICE SIZE/OFF     NODE NAME
httpd   31674 apache  cwd       DIR              253,0      278       64 /
httpd   31674 apache  rtd       DIR              253,0      278       64 /
httpd   31674 apache  txt       REG              253,0   527736  8888916 /usr/sbin/httpd
httpd   31674 apache  mem       REG              253,0    37216  9300529 /usr/lib64/libnss_sss.so.2
httpd   31674 apache  mem       REG              253,0   105824  8467438 /usr/lib64/libresolv-2.17.so
httpd   31674 apache  mem       REG              253,0    31408  8467426 /usr/lib64/libnss_dns-2.17.so
httpd   31674 apache  mem       REG              253,0    61624  8467428 /usr/lib64/libnss_files-2.17.so
httpd   31674 apache  mem       REG              253,0    27720 51070491 /usr/lib64/httpd/modules/mod_cgi.so
httpd   31674 apache  mem       REG              253,0    68192  8541901 /usr/lib64/libbz2.so.1.0.6

3.4 查看某個文件被哪些進程打開

查看某個文件被哪些進程打開

[root@jeven ~]# lsof /usr/sbin/httpd
COMMAND   PID   USER  FD   TYPE DEVICE SIZE/OFF    NODE NAME
httpd   31673   root txt    REG  253,0   527736 8888916 /usr/sbin/httpd
httpd   31674 apache txt    REG  253,0   527736 8888916 /usr/sbin/httpd
httpd   31675 apache txt    REG  253,0   527736 8888916 /usr/sbin/httpd
httpd   31676 apache txt    REG  253,0   527736 8888916 /usr/sbin/httpd
httpd   31677 apache txt    REG  253,0   527736 8888916 /usr/sbin/httpd
httpd   31678 apache txt    REG  253,0   527736 8888916 /usr/sbin/httpd

3.5 查看某個端口被哪些進程占用

查看所有網(wǎng)絡連接

lsof -i

查看某個端口被哪些進程占用

[root@jeven ~]# lsof  -i :22
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
sshd     9347 root    3u  IPv4  59897      0t0  TCP *:ssh (LISTEN)
sshd     9347 root    4u  IPv6  59899      0t0  TCP *:ssh (LISTEN)
sshd    30102 root    3u  IPv4 259806      0t0  TCP jeven.dhcp-route:ssh->DESKTOP-R1B8FG7.dhcp-route:58104 (ESTABLISHED)
sshd    30109 root    3u  IPv4 258689      0t0  TCP jeven.dhcp-route:ssh->DESKTOP-R1B8FG7.dhcp-route:58107 (ESTABLISHED)

3.6 查看某個目錄下被哪些進程打開的文件

查看某個目錄下被哪些進程打開的文件

[root@jeven ~]# lsof +D /tmp
COMMAND     PID     USER   FD   TYPE             DEVICE SIZE/OFF      NODE NAME
fastgithu  8959     root  mem-R  REG              253,0     4096   1017250 /tmp/.dotnet/shm/global/FastGithub
fastgithu  8959     root    8u  unix 0xffff930eaf1e5800      0t0     52317 /tmp/dotnet-diagnostic-8959-1410-socket
fastgithu  8959     root  108r   DIR              253,0       20 219680441 /tmp/.dotnet/shm
fastgithu  8959     root  109uR  REG              253,0     4096   1017250 /tmp/.dotnet/shm/global/FastGithub
postmaste  9582 postgres    9u  unix 0xffff930d35c18800      0t0     66632 /tmp/.s.PGSQL.5432
X          9603     root    8u  unix 0xffff930d32916000      0t0     65977 /tmp/.X11-unix/X0
gnome-ses 12391      gdm   13u  unix 0xffff930d2c1e7c00      0t0     69454 /tmp/.ICE-unix/12391

3.7 查看打開某個類型文件的進程列表

查看打開某個類型文件的進程列表

[root@jeven ~]# lsof -t /usr/sbin/httpd
31673
31674
31675
31676
31677
31678

四、lsof使用注意事項

  • 需要root權限才能使用lsof命令。

  • lsof命令需要一定時間才能完成掃描,因此不應在生產(chǎn)環(huán)境下濫用。

  • 使用lsof命令時應確保使用的是最新版本,以防止出現(xiàn)已知的bug。

  • 使用時應仔細查看命令輸出,尤其是對于打開套接字的程序及其連接,以避免意外暴露敏感信息。

  • lsof命令的掃描范圍包括所有已打開的文件和網(wǎng)絡套接字,因此執(zhí)行時可能會對系統(tǒng)性能產(chǎn)生一定的影響,如果對性能敏感,應考慮使用其他更輕量級的工具。

  • 在使用lsof命令時,應確保已經(jīng)對電腦進行了必要的安全保護,以避免受到黑客攻擊或數(shù)據(jù)泄露。

http://m.aloenet.com.cn/news/33858.html

相關文章:

  • 在線設計平臺有什么用長春seo網(wǎng)站優(yōu)化
  • 做ppt找素材的網(wǎng)站網(wǎng)絡營銷包括幾個部分
  • 企業(yè)網(wǎng)站優(yōu)化電話黑帽友情鏈接
  • 四川省建設廳網(wǎng)站官網(wǎng)建立網(wǎng)站需要多少錢
  • 成都的網(wǎng)站建設開發(fā)公司怎么優(yōu)化關鍵詞
  • 專做蔬菜大棚的網(wǎng)站推廣策劃方案
  • 創(chuàng)建門戶網(wǎng)站網(wǎng)絡營銷的特點有哪些
  • 網(wǎng)站上的qq咨詢怎么做seo在線外鏈
  • 寧波網(wǎng)站推廣廠家郴州網(wǎng)絡推廣公司排名
  • 濟南網(wǎng)站建設代理銷售系統(tǒng)
  • 深圳商城網(wǎng)站哪家做的好外貿(mào)全網(wǎng)營銷推廣
  • 網(wǎng)站備案核實企業(yè)軟文范例
  • 什么響應式網(wǎng)站網(wǎng)站推廣工具有哪些
  • 濮陽市網(wǎng)站建設商業(yè)公司的域名
  • 互助資金盤網(wǎng)站開發(fā)杭州免費網(wǎng)站制作
  • 麗水專業(yè)網(wǎng)站制作公司dw網(wǎng)頁制作教程
  • 做網(wǎng)站要在阿里云上買幾個貢獻互聯(lián)網(wǎng)輿情信息
  • 網(wǎng)站開發(fā) 文件架構圖優(yōu)化大師使用方法
  • 代碼做網(wǎng)站的軟件市場營銷主要學什么
  • 杭州做網(wǎng)站好的公司跨境電商平臺有哪些?
  • 免費做電子目錄的網(wǎng)站百度云網(wǎng)盤搜索引擎入口
  • 網(wǎng)站改版申請制作網(wǎng)頁教程
  • 青海網(wǎng)站建設價格低seo神器
  • 一個電商網(wǎng)站開發(fā)需要多久嘉興seo優(yōu)化
  • 湖北網(wǎng)站建設服務公司免費cms建站系統(tǒng)
  • 個人網(wǎng)站建設如何賺錢軟文營銷ppt
  • 重慶網(wǎng)站營銷美國疫情最新消息
  • 日本可以做的h游戲視頻網(wǎng)站龍巖網(wǎng)站推廣
  • 掃wordpress后臺seo優(yōu)化或網(wǎng)站編輯
  • 如何做教育網(wǎng)站點金推廣優(yōu)化公司