通过 docker 启动的线程无法被 kill 命令杀掉。如果要取消这个进程,则只能关闭此容器。
[内容] Linux 当前网络流量的查看
内容一:查看此时的瞬间网络流量
# ip -s -h link
内容二:持续查看某张网卡的网络流量
# iftop -nN -i eth0
(补充:这里以持续查看名为 eth0 网卡的流量为例)
[排错] Linux 解决出现 “Read-only file system” 的目录
报错代码
Read-only file system
可尝试的解决方法一:重新挂载此目录
# mount -o remount rw /run
(补充:这里以重新挂载 /run 目录并给此目录添加读和写权限为例)
可尝试的解决方法二:修复出现此问题的分区
可尝试的解决方法二:分析
非正常关机可能造成文件系统受损,系统重启后,受损的分区自动挂载后就会变成只读。此时修复这个分区则可能修复这个问题
可尝试的解决方法二:解决方法
# fsck.ext4 -y /dev/sda1
(补充:这里以修复分区格式为 ext4 的分区 /dev/sda1 为例)
[步骤] Linux 关机前执行脚本
步骤一:创建要被管理的脚本
# vim /root/12456.sh
创建以下内容:
#!/bin/bash
for i in {1..5}
do
echo $i
done
(补充:这里以创建 /etc/root/for.sh 脚本为例)
步骤二:创建 systemctl 的管理文件
# vim /etc/systemd/system/12456.service
创建以下内容:
[Unit]
Description=12345
After=getty@tty1.service display-manager.service plymouth-start.service
Before=systemd-poweroff.service systemd-halt.service
DefaultDependencies=no
[Service]
ExecStart=/root/12456.sh
Type=forking
[Install]
WantedBy=poweroff.target
WantedBy=reboot.target
WantedBy=halt.target
(补充:这里以创建 /etc/systemd/system/12456.service 来管理 ExecStart=/root/12456.sh 为例)
步骤三:加载刚刚创建的 systemctl 管理文件
# systemctl daemon-reload
步骤四:给 systemctl 的管理文件添加执行权限
# chmod u+x /etc/systemd/system/12456.service
步骤五:设置关机前执行脚本
5.1 设置关闭系统前执行此脚本
# ln -s /usr/lib/systemd/system/12456.service /usr/lib/systemd/system/halt.target.wants/
5.2 设置关闭电源前执行此脚本
# ln -s /usr/lib/systemd/system/12456.service /usr/lib/systemd/system/poweroff.target.wants/
5.3 设置重启先执行此脚本
# ln -s /usr/lib/systemd/system/12456.service /usr/lib/systemd/system/reboot.target.wants/
[命令] Linux 命令 gzip (打包、解包、压缩和解压文件或目录,压缩包以 xz 作为后缀)
内容一:gzip 命令简介
1.1 gzip 命令的格式
# gzip <option> <file>
1.2 gunzip 命令的常用选项
1) -c or –stdout, write on standard output, keep original files unchanged
2) -d or –decompress, decompress
3) -f or –force, force overwrite of output file and compress links
4) -h or –help, give this help
5) -k or –keep, keep (don’t delete) input files
6) -l or –list, list compressed file contents
7) -n or –no-name, do not save or restore the original name and timestamp
8) -N or –name, save or restore the original name and timestamp
9) -q or –quiet, suppress all warnings
10) -r or –recursive or –rsyncable, operate recursively on directories
11) -t or –test, test compressed file integrity
12) -1 or –fast, compress faster
13) -9 or –best, compress better
内容二:gzip 命令的使用案例
2.1 案例一:压缩文件
# gzip test.txt
(补充:这里以压缩文件 test.txt 为例)
2.2 案例二:解压文件
# gzip -d test.txt.xz
(补充:这里以解压文件 test.txt.zx 为例)