linux常用命令总结(持续更新)

硬盘满了怎么办

查看硬盘占用

[root@iZd4l01sl2kkco2rhiznjjZ 10.252.161.192]# df -lh
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        99G   18G   77G  19% /
devtmpfs        7.8G     0  7.8G   0% /dev
tmpfs           7.8G     0  7.8G   0% /dev/shm
tmpfs           7.8G  772K  7.8G   1% /run
tmpfs           7.8G     0  7.8G   0% /sys/fs/cgroup
tmpfs           1.6G     0  1.6G   0% /run/user/0
tmpfs           1.6G     0  1.6G   0% /run/user/1001
/dev/vdb1       493G  8.4G  459G   2% /app

查看本目录各文件夹占用空间

[root@iZd4l01sl2kkco2rhiznjjZ log]# du -h --max-depth=1
8.0K    ./10.252.161.187
2.9M    ./127.0.0.1
4.2M    ./10.252.161.192
16K     ./iZd4l01sl2kkco2rhiznjjZ
7.1M    .


挂载硬盘

mount /dev/vdb1  /app  将/dev/vdb1  硬盘挂载到/app 目录

端口占用查看

如果看不到进程id 可能是权限不够,用sudo

netstat -aon|findstr "8081"
tasklist|findstr "9088"
taskkill /T /F /PID 9088

netstat -tunlp|grep


[root@iZd4l01sl2kkco2rhiznjjZ log]# netstat -tunlp|grep 80
tcp6       0      0 :::9080                 :::*                    LISTEN      749816/./gintest
udp6       0      0 fe80::216:3eff:fe01:123 :::*                                1108/ntpd

访问URL

[scapp@iZd4l01sl2kkco2rhiznj9Z ~]$ curl -I -L  http://10.252.161.178:8989
HTTP/1.1 200 OK
Content-Type: application/octet-stream;charset=UTF-8
Content-Length: 57
-- 不使用证书访问 https 地址
 curl -I -L -k --tlsv1  https://idm.sinopec.com

挂载数据盘

在没有分区和格式化数据盘之前,使用 “df –h”(回车)命令,是无法看到数据盘的 得使用fdisk -l命令查看

[root@iZ1pg01g9j9z62f3ieiyu0Z ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        7.8G     0  7.8G   0% /dev
tmpfs           7.8G     0  7.8G   0% /dev/shm
tmpfs           7.8G  620K  7.8G   1% /run
tmpfs           7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/vda1        99G   12G   82G  13% /
tmpfs           1.6G     0  1.6G   0% /run/user/1001
[scapp@iZ1pg01g9j9z62f3ieiyu0Z ~]$ sudo fdisk -l

Disk /dev/vda: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000afe3a

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048   209713151   104855552   83  Linux

Disk /dev/vdb: 161.1 GB, 161061273600 bytes, 314572800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

显示有一个/dev/vdb的硬盘 161 G

直接挂载报如下错误

mkdir /app
[root@iZ1pg01g9j9z62f3ieiyu0Z ~]# mount /dev/vdb  /app
mount: /dev/vdb is write-protected, mounting read-only
mount: unknown filesystem type '(null)'

需要格式化命令然后进行挂载,即可挂载成功

mkfs -t ext4 /dev/vdb 
mount /dev/vdb  /app

永久挂载在/etc/fstab添加

/dev/vdb1     /app     ext4               defaults           1 1

保存后 执行

  mount -a

linux抓包

安装tcpdump

yum install -y   tcpdump 

抓取ens33 网卡的数据包,并将抓取结果写入到dumpfile.pcap 文件

tcpdump -i ens33  -w dumpfile.pcap
tcpdump src host 100.24.92.81 and port 80 and tcp 
tcpdump src host 100.24.92.81 and port 80 and tcp -w 81284.cap

安装tshark

 yum install -y wireshark
 tshark -D --查看网卡列表
tshark -i ens33 -f '(ip dst host 192.168.47.100) and (tcp dst port 80)'
tshark -i ens33 -f 'ip dst host 192.168.47.100'
tshark -i ens33 -f 'tcp dst port 80'
tshark -i ens33 -f '(ip dst host 192.168.47.100 or 192.168.47.2) '
tshark -i ens33 -f '(ip host 192.168.47.100 ) '

split文件分割

当日志文件太大不封边阅读操作时,可以使用split 命令进行文件分割
split -l 10 filename将文件分割为10行大小的文件

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

catch that elf

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值