type
Post
status
Published
date
Oct 10, 2023
slug
linuxcommoncmand
summary
掌握常用命名,应用任何场合
tags
Linux
开发
category
技术学习
icon
password
Link

参考链接

 
 
 

详细说明

 
notion image
 

grep

 
grep是一个非常有用的命令,用于在文件中搜索指定的模式或字符串。以下是grep命令的一些常用选项和用法:
  1. 基本用法:grep pattern file
    1. 在指定文件中搜索匹配指定模式(pattern)的行,并将其打印出来。
  1. 忽略大小写:grep -i pattern file
    1. 忽略模式匹配时的大小写。
  1. 显示行号:grep -n pattern file
    1. 在匹配的行前面显示行号。
  1. 显示匹配的上下文:grep -C num pattern file
    1. 在匹配的行上下文中显示指定行数(num)的内容。
  1. 只显示匹配的文件名:grep -l pattern file
    1. 只显示包含匹配的文件名,而不显示具体匹配的行内容。
  1. 递归搜索目录:grep -r pattern directory
    1. 在指定目录及其子目录中递归搜索匹配的模式。
  1. 排除指定文件类型:grep --exclude=pattern file
    1. 排除指定文件类型的搜索。可以使用通配符来指定多个文件类型。
  1. 反向匹配:grep -v pattern file
    1. 显示不匹配指定模式的行。
  1. 使用正则表达式:grep -E "pattern" file
    1. 使用扩展的正则表达式进行匹配。
  1. 从标准输入读取:grep pattern
    1. 从标准输入中读取内容,并搜索匹配指定模式的行。
# 基本使用 grep yoursearchkeyword f.txt #文件查找 grep 'KeyWord otherKeyWord' f.txt cpf.txt #多文件查找, 含空格加引号 grep 'KeyWord' /home/admin -r -n #目录下查找所有符合关键字的文件 grep 'keyword' /home/admin -r -n -i # -i 忽略大小写 grep 'KeyWord' /home/admin -r -n --include *.{vm,java} #指定文件后缀 grep 'KeyWord' /home/admin -r -n --exclude *.{vm,java} #反匹配 # cat + grep cat f.txt | grep -i keyword # 查找所有keyword且不分大小写 cat f.txt | grep -c 'KeyWord' # 统计Keyword次数 # seq + grep seq 10 | grep 5 -A 3 #上匹配 seq 10 | grep 5 -B 3 #下匹配 seq 10 | grep 5 -C 3 #上下匹配,平时用这个就妥了
 
 

awk

awk是一个强大的文本处理工具,用于提取、处理和格式化文本数据。它以行为单位处理文本,并允许用户定义处理规则。以下是awk命令的一些常用选项和用法:
  1. 基本用法:awk 'pattern {action}' file
    1. 根据指定的模式(pattern)执行相应的动作(action)来处理文件中的每一行。
  1. 以空格或制表符为分隔符:awk '{print 1,1,2}' file
    1. 默认情况下,awk使用空格或制表符作为字段分隔符。可以使用1、1、2等变量来引用行中的不同字段,并将其打印出来。
  1. 自定义分隔符:awk -F',' '{print 1,1,2}' file
    1. 使用-F选项可以自定义字段分隔符,如逗号(,)。
  1. 显示特定行:awk 'NR==5' file
    1. 使用NR变量可以指定要处理的行号,如NR==5表示只处理第5行。
  1. 使用条件:awk '3 > 10 {print 1}' file
    1. 使用条件语句来过滤行,如$3 > 10表示第三个字段大于10时执行动作。
  1. 计算总和或平均值:awk '{sum += $1} END {print sum}' file
    1. 可以使用变量和END语句来计算总和或平均值等聚合操作。
  1. 自定义输出格式:awk '{printf "%s\t%s\n", 1,1,2}' file
    1. 使用printf函数可以自定义输出的格式,如制定字段的宽度或格式。
  1. 使用正则表达式:awk '/pattern/ {print $0}' file
    1. 可以使用正则表达式来匹配行,如/pattern/表示匹配包含指定模式的行。
  1. 使用函数:awk 'BEGIN {print toupper("hello")}' file
    1. 可以使用内置函数来进行字符串操作、数学计算等,如toupper函数将字符串转换为大写。
  1. 多个文件处理:awk 'FNR==1 {print "------", FILENAME, "------"} {print}' file1 file2
    1. 可以同时处理多个文件,FNR==1表示处理每个文件的第一行。
这只是awk命令的一些常见选项和用法。awk非常灵活
 
# 基本使用 awk '{print $4,$6}' f.txt awk '{print NR,$0}' f.txt cpf.txt awk '{print FNR,$0}' f.txt cpf.txt awk '{print FNR,FILENAME,$0}' f.txt cpf.txt awk '{print FILENAME,"NR="NR,"FNR="FNR,"$"NF"="$NF}' f.txt cpf.txt echo 1:2:3:4 | awk -F: '{print $1,$2,$3,$4}' # 匹配 awk '/ldb/ {print}' f.txt #匹配ldb awk '!/ldb/ {print}' f.txt #不匹配ldb awk '/ldb/ && /LISTEN/ {print}' f.txt #匹配ldb和LISTEN awk '$5 ~ /ldb/ {print}' f.txt #第五列匹配ldb
 

sed

sed是一个流编辑器,用于对文本进行转换、替换和处理。它基于行进行操作,并且可以根据指定的规则对文本进行修改。以下是sed命令的一些常用选项和用法:
  1. 基本用法:sed 's/pattern/replacement/' file
    1. 使用s命令(替换命令)替换文件中匹配指定模式(pattern)的文本为指定的替换内容(replacement)。
  1. 全局替换:sed 's/pattern/replacement/g' file
    1. 使用g选项进行全局替换,即替换每一行中所有匹配的文本。
  1. 指定行范围:sed '3,7s/pattern/replacement/' file
    1. 使用行范围来指定替换的范围,如3,7表示从第3行到第7行进行替换。
  1. 只显示匹配的行:sed -n '/pattern/p' file
    1. 使用-n选项和p命令来只显示匹配模式的行。
  1. 删除行:sed '3d' file
    1. 使用d命令来删除指定行,如3d表示删除第3行。
  1. 插入行:sed '3i\New line' file
    1. 使用i命令在指定行之前插入新行,如3i\New line表示在第3行之前插入"New line"。
  1. 追加行:sed '3a\New line' file
    1. 使用a命令在指定行之后追加新行,如3a\New line表示在第3行之后追加"New line"。
  1. 替换行:sed '3c\New line' file
    1. 使用c命令替换指定行,如3c\New line表示将第3行替换为"New line"。
  1. 使用正则表达式:sed 's/pattern/replacement/I' file
    1. 可以使用正则表达式进行模式匹配,如I选项表示忽略大小写。
  1. 从文件读取命令:sed -f script.sed file
    1. 可以将sed命令保存到脚本文件中,并使用-f选项读取脚本文件进行处理
# 文本打印 sed -n '3p' xxx.log #只打印第三行 sed -n '$p' xxx.log #只打印最后一行 sed -n '3,9p' xxx.log #只查看文件的第3行到第9行 sed -n -e '3,9p' -e '=' xxx.log #打印3-9行,并显示行号 sed -n '/root/p' xxx.log #显示包含root的行 sed -n '/hhh/,/omc/p' xxx.log # 显示包含"hhh"的行到包含"omc"的行之间的行 # 文本替换 sed -i 's/root/world/g' xxx.log # 用world 替换xxx.log文件中的root; s==search 查找并替换, g==global 全部替换, -i: implace # 文本插入 sed '1,4i hahaha' xxx.log # 在文件第一行和第四行的每行下面添加hahaha sed -e '1i happy' -e '$a new year' xxx.log #【界面显示】在文件第一行添加happy,文件结尾添加new year sed -i -e '1i happy' -e '$a new year' xxx.log #【真实写入文件】在文件第一行添加happy,文件结尾添加new year # 文本删除 sed '3,9d' xxx.log # 删除第3到第9行,只是不显示而已 sed '/hhh/,/omc/d' xxx.log # 删除包含"hhh"的行到包含"omc"的行之间的行 sed '/omc/,10d' xxx.log # 删除包含"omc"的行到第十行的内容 # 与find结合 find . -name "*.txt" |xargs sed -i 's/hhhh/\hHHh/g' find . -name "*.txt" |xargs sed -i 's#hhhh#hHHh#g' find . -name "*.txt" -exec sed -i 's/hhhh/\hHHh/g' {} \; find . -name "*.txt" |xargs cat
 

tail

tail命令用于显示文件的末尾内容,默认显示文件的最后10行。以下是tail命令的一些常用选项和用法:
  1. 基本用法:tail file
    1. 显示文件的最后10行内容。
  1. 显示指定行数:tail -n num file
    1. 使用-n选项可以指定要显示的行数,如tail -n 20 file表示显示文件的最后20行。
  1. 实时追踪文件:tail -f file
    1. 使用-f选项可以实时追踪文件的变化,当文件内容发生变化时,tail会自动显示新增的内容。
  1. 显示文件的末尾字节数:tail -c num file
    1. 使用-c选项可以指定要显示的字节数,如tail -c 100 file表示显示文件的最后100个字节。
  1. 显示文件的末尾区块:tail -b num file
    1. 使用-b选项可以指定要显示的区块数量,每个区块大小为512字节。
  1. 不显示文件名:tail -q file
    1. 使用-q选项可以在显示多个文件内容时,不显示文件名。
  1. 显示文件的末尾时间戳:tail -t file
    1. 使用-t选项可以在显示文件内容时,显示每行的时间戳信息。
  1. 以逆序显示文件内容:tail -r file
    1. 使用-r选项可以以逆序的方式显示文件内容,即从末尾到开头。
  1. 同时显示文件名:tail -v file
    1. 使用-v选项可以在显示多个文件内容时,显示文件名。
  1. 显示文件的末尾区块大小:tail --max-unchanged-stats=num file
    1. 使用--max-unchanged-stats选项可以指定当文件内容没有变化时,显示的区块大小。
 
# 基本使用 tail -f xxx.log # 循环监听文件 tail -300f xxx.log #倒数300行并追踪文件 tail +20 xxx.log #从第 20 行至文件末尾显示文件内容 # tailf使用 tailf xxx.log #等同于tail -f -n 10 打印最后10行,然后追踪文件
 

find

find命令用于在指定目录下查找文件和目录,并可以根据不同的条件进行筛选。以下是find命令的一些常用选项和用法:
  1. 基本用法:find path
    1. 在指定的路径(path)下递归查找所有文件和目录。
  1. 按名称查找:find path -name "pattern"
    1. 使用-name选项按名称查找文件和目录,pattern可以是文件名、通配符或正则表达式。
  1. 按类型查找:find path -type type
    1. 使用-type选项按类型查找文件和目录,type可以是f(文件)、d(目录)、l(符号链接)等。
  1. 按大小查找:find path -size [+|-]n[c|k|M|G]
    1. 使用-size选项按大小查找文件,n表示大小,+表示大于,-表示小于,c表示字节,k表示KB,M表示MB,G表示GB。
  1. 按时间查找:find path -mtime n
    1. 使用-mtime选项按修改时间查找文件,n表示天数,+表示n天前,-表示n天内。
  1. 按权限查找:find path -perm mode
    1. 使用-perm选项按权限查找文件,mode表示权限模式。
  1. 按所有者查找:find path -user username
    1. 使用-user选项按文件所有者查找文件,username表示用户名。
  1. 按组查找:find path -group groupname
    1. 使用-group选项按文件所属组查找文件,groupname表示组名。
  1. 执行命令:find path -exec command {} ;
    1. 使用-exec选项执行指定的命令,{}表示匹配到的文件或目录。
  1. 限制搜索深度:find path -maxdepth n
    1. 使用-maxdepth选项限制搜索的深度,n表示深度。
 
sudo -u admin find /home/admin /tmp /usr -name \*.log(多个目录去找) find . -iname \*.txt(大小写都匹配) find . -type d(当前目录下的所有子目录) find /usr -type l(当前目录下所有的符号链接) find /usr -type l -name "z*" -ls(符号链接的详细信息 eg:inode,目录) find /home/admin -size +250000k(超过250000k的文件,当然+改成-就是小于了) find /home/admin f -perm 777 -exec ls -l {} \; (按照权限查询文件) find /home/admin -atime -1 1天内访问过的文件 find /home/admin -ctime -1 1天内状态改变过的文件 find /home/admin -mtime -1 1天内修改过的文件 find /home/admin -amin -1 1分钟内访问过的文件 find /home/admin -cmin -1 1分钟内状态改变过的文件 find /home/admin -mmin -1 1分钟内修改过的文件
 

pgm

批量查询vm-shopbase满足条件的日志
pgm -A -f vm-shopbase 'cat /home/admin/shopbase/logs/shopbase.log.2017-01-17|grep 2069861630'
 
 

ifconfig

# 查看网络接口属性 [root@netserver ~]# ifconfig br-1f81488160da: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 172.19.0.1 netmask 255.255.0.0 broadcast 172.19.255.255 ether 02:42:94:63:65:fb txqueuelen 0 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 br-71ba0f08bb5b: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 172.18.0.1 netmask 255.255.0.0 broadcast 172.18.255.255 ether 02:42:ca:f5:d3:5b txqueuelen 0 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255 ether 02:42:6f:a1:24:c0 txqueuelen 0 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.137.5 netmask 255.255.255.0 broadcast 192.168.137.255 inet6 fe80::b9c5:3ac:cc73:5a5e prefixlen 64 scopeid 0x20<link> ether 00:15:5d:0b:01:08 txqueuelen 1000 (Ethernet) RX packets 290934 bytes 59950777 (57.1 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 178647 bytes 32218708 (30.7 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 10765085 bytes 72986737319 (67.9 GiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 10765085 bytes 72986737319 (67.9 GiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

iptables 查看防火墙

[root@netserver ~]# iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED ACCEPT all -- anywhere anywhere INPUT_direct all -- anywhere anywhere INPUT_ZONES_SOURCE all -- anywhere anywhere INPUT_ZONES all -- anywhere anywhere DROP all -- anywhere anywhere ctstate INVALID REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
 

route 查看路由表

[root@netserver ~]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.137.1 0.0.0.0 UG 100 0 0 eth0 172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0 172.18.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-71ba0f08bb5b 172.19.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-1f81488160da 192.168.137.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0 [root@netserver ~]#
 

netstat

# 查看所有监听接口 [root@netserver ~]# netstat -lntp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:10240 0.0.0.0:* LISTEN 2048/nginx: master tcp 0 0 127.0.0.1:9121 0.0.0.0:* LISTEN 2058/redis_exporter tcp 0 0 127.0.0.1:8098 0.0.0.0:* LISTEN 2035/puma 6.4.0 (un tcp 0 0 127.0.0.1:9090 0.0.0.0:* LISTEN 2057/prometheus tcp 0 0 127.0.0.1:9187 0.0.0.0:* LISTEN 2051/postgres_expor tcp 0 0 127.0.0.1:9093 0.0.0.0:* LISTEN 2054/alertmanager tcp 0 0 127.0.0.1:9100 0.0.0.0:* LISTEN 2052/node_exporter tcp 0 0 127.0.0.1:9229 0.0.0.0:* LISTEN 2046/gitlab-workhor tcp 0 0 127.0.0.1:9168 0.0.0.0:* LISTEN 2043/ruby tcp 0 0 127.0.0.1:8082 0.0.0.0:* LISTEN 2295/sidekiq_export tcp 0 0 127.0.0.1:9236 0.0.0.0:* LISTEN 2091/gitaly tcp 0 0 0.0.0.0:11284 0.0.0.0:* LISTEN 1862/python3 tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1077/sshd tcp 0 0 127.0.0.1:8150 0.0.0.0:* LISTEN 2029/gitlab-kas tcp 0 0 127.0.0.1:8151 0.0.0.0:* LISTEN 2029/gitlab-kas tcp 0 0 127.0.0.1:8153 0.0.0.0:* LISTEN 2029/gitlab-kas tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1438/master tcp 0 0 127.0.0.1:8154 0.0.0.0:* LISTEN 2029/gitlab-kas tcp 0 0 127.0.0.1:8155 0.0.0.0:* LISTEN 2029/gitlab-kas tcp 0 0 127.0.0.1:8092 0.0.0.0:* LISTEN 2293/sidekiq 6.5.12 tcp 0 0 0.0.0.0:8060 0.0.0.0:* LISTEN 2048/nginx: master tcp6 0 0 :::9094 :::* LISTEN 2054/alertmanager tcp6 0 0 ::1:9168 :::* LISTEN 2043/ruby tcp6 0 0 :::21 :::* LISTEN 1081/vsftpd tcp6 0 0 :::22 :::* LISTEN 1077/sshd tcp6 0 0 ::1:25 :::* LISTEN 1438/master # 查看所有已建立连接 [root@netserver ~]# netstat -antp Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:10240 0.0.0.0:* LISTEN 2048/nginx: master tcp 0 0 127.0.0.1:9121 0.0.0.0:* LISTEN 2058/redis_exporter tcp 0 0 127.0.0.1:8098 0.0.0.0:* LISTEN 2035/puma 6.4.0 (un tcp 0 0 127.0.0.1:9090 0.0.0.0:* LISTEN 2057/prometheus tcp 0 0 127.0.0.1:9187 0.0.0.0:* LISTEN 2051/postgres_expor tcp 0 0 127.0.0.1:9093 0.0.0.0:* LISTEN 2054/alertmanager tcp 0 0 127.0.0.1:9100 0.0.0.0:* LISTEN 2052/node_exporter tcp 0 0 127.0.0.1:9229 0.0.0.0:* LISTEN 2046/gitlab-workhor tcp 0 0 127.0.0.1:9168 0.0.0.0:* LISTEN 2043/ruby tcp 0 0 127.0.0.1:8082 0.0.0.0:* LISTEN 2295/sidekiq_export tcp 0 0 127.0.0.1:9236 0.0.0.0:* LISTEN 2091/gitaly tcp 0 0 0.0.0.0:11284 0.0.0.0:* LISTEN 1862/python3 tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1077/sshd tcp 0 0 127.0.0.1:8150 0.0.0.0:* LISTEN 2029/gitlab-kas tcp 0 0 127.0.0.1:8151 0.0.0.0:* LISTEN 2029/gitlab-kas tcp 0 0 127.0.0.1:8153 0.0.0.0:* LISTEN 2029/gitlab-kas tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1438/master tcp 0 0 127.0.0.1:8154 0.0.0.0:* LISTEN 2029/gitlab-kas tcp 0 0 127.0.0.1:8155 0.0.0.0:* LISTEN 2029/gitlab-kas tcp 0 0 127.0.0.1:8092 0.0.0.0:* LISTEN 2293/sidekiq 6.5.12 tcp 0 0 0.0.0.0:8060 0.0.0.0:* LISTEN 2048/nginx: master tcp 0 0 127.0.0.1:8098 127.0.0.1:48908 TIME_WAIT - tcp 0 0 127.0.0.1:43168 127.0.0.1:9090 ESTABLISHED 2057/prometheus tcp 0 0 127.0.0.1:9100 127.0.0.1:38444 ESTABLISHED 2052/node_exporter tcp 0 0 127.0.0.1:34596 127.0.0.1:9121 ESTABLISHED 2057/prometheus tcp 0 0 127.0.0.1:57458 127.0.0.1:9187 ESTABLISHED 2057/prometheus tcp 0 0 127.0.0.1:9187 127.0.0.1:57458 ESTABLISHED 2051/postgres_expor tcp 0 0 127.0.0.1:8098 127.0.0.1:48916 TIME_WAIT - tcp 0 0 127.0.0.1:37766 127.0.0.1:9229 ESTABLISHED 2057/prometheus tcp 0 0 127.0.0.1:38444 127.0.0.1:9100 ESTABLISHED 2057/prometheus tcp 0 0 127.0.0.1:9121 127.0.0.1:34596 ESTABLISHED 2058/redis_exporter tcp 0 0 127.0.0.1:38118 127.0.0.1:8082 ESTABLISHED 2057/prometheus tcp 0 0 127.0.0.1:8098 127.0.0.1:48914 TIME_WAIT - tcp 0 0 127.0.0.1:8098 127.0.0.1:48912 TIME_WAIT - tcp 0 0 127.0.0.1:54696 127.0.0.1:9236 ESTABLISHED 2057/prometheus tcp 0 0 127.0.0.1:8082 127.0.0.1:38118 ESTABLISHED 2295/sidekiq_export tcp 0 0 127.0.0.1:44360 127.0.0.1:8060 ESTABLISHED 2057/prometheus tcp 0 36 192.168.137.5:22 192.168.137.1:54896 ESTABLISHED 27491/sshd: root@pt tcp 0 0 127.0.0.1:9090 127.0.0.1:43168 ESTABLISHED 2057/prometheus tcp 0 0 127.0.0.1:8060 127.0.0.1:44360 ESTABLISHED 2134/nginx: worker tcp 0 0 192.168.137.5:33078 106.75.107.68:443 FIN_WAIT2 - tcp 0 0 127.0.0.1:9229 127.0.0.1:37766 ESTABLISHED 2046/gitlab-workhor tcp 0 0 127.0.0.1:9236 127.0.0.1:54696 ESTABLISHED 2091/gitaly tcp6 0 0 :::9094 :::* LISTEN 2054/alertmanager tcp6 0 0 ::1:9168 :::* LISTEN 2043/ruby tcp6 0 0 :::21 :::* LISTEN 1081/vsftpd tcp6 0 0 :::22 :::* LISTEN 1077/sshd tcp6 0 0 ::1:25 :::* LISTEN 1438/master tcp6 0 0 ::1:9168 ::1:49422 ESTABLISHED 2043/ruby tcp6 0 0 ::1:49412 ::1:9168 ESTABLISHED 2057/prometheus tcp6 0 0 ::1:9168 ::1:49412 ESTABLISHED 2043/ruby tcp6 0 0 ::1:9168 ::1:49432 ESTABLISHED 2043/ruby tcp6 0 0 ::1:49422 ::1:9168 ESTABLISHED 2057/prometheus tcp6 0 0 ::1:49432 ::1:9168 ESTABLISHED 2057/prometheus
 

ps 查看进程

[root@netserver ~]# ps -ef|grep nginx root 2032 2004 0 1月26 ? 00:00:00 runsv nginx root 2041 2032 0 1月26 ? 00:00:00 svlogd -tt /var/log/gitlab/nginx root 2048 2032 0 1月26 ? 00:00:00 nginx: master process /opt/gitlab/embedded/sbin/gitlab-web -p /var/opt/gitlab/nginx gitlab-+ 2132 2048 0 1月26 ? 00:00:00 nginx: worker process gitlab-+ 2133 2048 0 1月26 ? 00:00:00 nginx: worker process gitlab-+ 2134 2048 0 1月26 ? 00:00:03 nginx: worker process gitlab-+ 2135 2048 0 1月26 ? 00:00:11 nginx: worker process gitlab-+ 2136 2048 0 1月26 ? 00:00:04 nginx: cache manager process root 6347 27502 0 14:59 pts/0 00:00:00 grep --color=auto nginx [root@netserver ~]#
 

top 查询内存占用

【Docker】zookeeper概要与部署【Docker】CloudBeaver概要与部署