Linux工具-rsync
参考文献
rsync
rsync用于在两个远程计算机之间同步文件和文件夹.它仅通过传输源和目标之间的差异来提供快速的增量文件传输.
rsync可用于镜像数据,增量备份,在系统之间复制文件,可替代scp,sftp和cp日常等使用的命令.
用法
rsync语法有三种,分别是本地到本地形式Local to Local,本地到远程Local to Remote,远程到本地Remote to Local
123Local to Local: rsync [OPTION]... [SRC]... DESTLocal to Remote: rsync [OPTION]... [SRC]... [USER@]HOST:DESTRemote to Local: rsync [OPTION]... [USER@]HOST:SRC... [DEST]
-a/--archive存档模式,等效于-rlptgoD.此选项指示rsync递归同步目录,传输特殊设备和块设备,保留符号链接,组,所有权和权限等.
-z/--compress,此选项将强制rsync在数据发送给目标计算机之前对数据进行压缩. ...
Linux工具-nmap
参考文献
nmap
端口扫描基础
许多传统的端口扫描器只列出所有端口是开放还是关闭的, Nmap的信息粒度比它们要细得多。 它把端口分成六个状态: open(开放的),closed(关闭的),filtered(被过滤的), unfiltered(未被过滤的), open|filtered(开放或者被过滤的),或者closed|filtered(关闭或者被过滤的)。
Nmap所识别的6个端口状态
状态
说明
open(开放的)
应用程序正在该端口接收TCP 连接或者UDP报文。发现这一点常常是端口扫描 的主要目标。安全意识强的人们知道每个开放的端口 都是攻击的入口。攻击者或者入侵测试者想要发现开放的端口。 而管理员则试图关闭它们或者用防火墙保护它们以免妨碍了合法用户。 非安全扫描可能对开放的端口也感兴趣,因为它们显示了网络上那些服务可供使用
closed(关闭的)
关闭的端口对于Nmap也是可访问的(它接受Nmap的探测报文并作出响应), 但没有应用程序在其上监听。 它们可以显示该IP地址上(主机发现,或者ping扫描)的主机正在运行up 也对部分操作系统探测有 ...
Linux工具-crontab
参考文献
Linux Timed Tasks Crontab
crontab
crond是linux下的一个守护进程,用于定期执行某些任务或等待某些事件被处理,类似于windows下的计划任务,当操作系统安装完成后,会默认安装这个服务工具,并会自动启动crond进程,crond进程每分钟会定期检查是否有任务需要执行,如果有任务就会自动执行.如果有任务要执行,就会自动执行. /etc目录下有一个crontab文件,它是系统任务调度的配置文件
1234567891011121314151617# /etc/crontab: system-wide crontab# Unlike any other crontab you don't have to run the `crontab'# command to install the new version when you edit this file# and files in /etc/cron.d. These files also have username fields,# that none of t ...
Linux工具-certbot
参考文献
https://certbot.eff.org/instructions?ws=nginx&os=ubuntufocal
https://eff-certbot.readthedocs.io/en/stable/using.html
ssl 证书;certbot+nginx+docker
docker部署certbot与nginx来获取ssl证书添加https及自动更新
letsencrypt证书-管理工具certbot
certbot
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849# certbot --help- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - certbot [SUBCOMMAND] [options] [-d DOMAIN] [-d DOMAIN] ...Certbot can obtain and i ...
Linux工具-nsenter
参考文献
nsenter Command Examples in Linux
nsenter
nsenter 是一个 Linux 实用程序,允许您在正在运行的进程的命名空间中运行命令。命名空间是 Linux 内核的一项功能,可为进程提供隔离的环境,并被 Docker 等容器技术用来创建隔离的容器。
使用 nsenter,您可以在正在运行的进程的命名空间中运行命令,从而有效地允许您访问该进程的环境。这对于各种任务都很有用,例如调试进程、检查容器的文件系统或使用类似 chroot 的操作更改进程的根目录。
nsenter 对于管理 Docker 容器特别有用,因为它允许您进入容器的命名空间并执行操作,就像您在容器本身内部一样。这对于排除容器问题或执行维护任务而无需启动新容器特别有帮助。
使用说明
12345678910111213141516171819202122232425262728# nsenter --help用法: nsenter [选项] [<程序> [<参数>...]]以其他程序的名字空间运行某个程序。选项: -a, --all ...
Linux工具-技巧篇
参考文献
你可能不知道的SHELL
示例
12# 在远程机器上运行一段脚本。这条命令最大的好处就是不用把脚本拷到远程机器上ssh user@server bash < /path/to/local/script.sh
12# 显示ascii码表man ascii
12# 这行脚本能输出你最常用的十条命令history | awk '{CMD[$2]++;count++;} END { for (a in CMD )print CMD[a] " " CMD[a]/count*100 "% " a }' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n10
12# Marix的屏幕效果tr -c "[:digit:]" " " < /dev/urandom | dd cbs=$COLUMNS conv=unblock | ...
Linux工具-资源监控篇
参考文献
你可能不知道的SHELL
系统信息
12345678910111213141516# cat /etc/issueUbuntu 20.04.6 LTS \n \l# cat /etc/os-releaseNAME="Ubuntu"VERSION="20.04.6 LTS (Focal Fossa)"ID=ubuntuID_LIKE=debianPRETTY_NAME="Ubuntu 20.04.6 LTS"VERSION_ID="20.04"HOME_URL="https://www.ubuntu.com/"SUPPORT_URL="https://help.ubuntu.com/"BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/priv ...
Linux工具-网络篇
参考文献
你可能不知道的SHELL
全球免费公共 DNS 解析服务器 IP 地址列表推荐 (解决无法上网/加速/防劫持)
linux dig 命令
route
1234567891011121314151617181920# routeKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Ifacedefault _gateway 0.0.0.0 UG 100 0 0 eth0172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0172.18.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-f049d4c62b6c172.19.0.0 0.0.0.0 255.25 ...
Linux工具-awk
参考文献
AWK 简明教程
AWK
awk是逐行处理的,逐行处理的意思就是说,当awk处理一个文本时,会一行一行进行处理,处理完当前行,再处理下一行,awk默认以”换行符”为标记,识别每一行,也就是说,awk跟我们人类一样,每次遇到”回车换行”,就认为是当前行的结束,新的一行的开始,awk会按照用户指定的分割符去分割当前行,如果没有指定分割符,默认使用空格作为分隔符。
内建变量
变量
说明
$0
当前记录(这个变量中存放着整个行的内容)
$1~$n
当前记录的第n个字段,字段间由FS分隔
FS
输入字段分隔符 默认是空格或Tab
NF
Number of Field,当前行的字段的个数(即当前行被分割成了几列),字段数量
NR
行号,当前处理的文本行的行号
FNR
各个文件自己的行号
RS
输入的记录分隔符, 默认为换行符
OFS
输出字段分隔符, 默认也是空格
ORS
输出的记录分隔符,默认为换行符
FILENAME
当前输入文件的名字
ARGC
命令行参数的个数
ARGV
数组,保存的是命令行所在给定的各个参数
...
Linux工具-sed
参考文献
sed
sed 会根据脚本命令来处理文本文件中的数据,这些命令要么从命令行中输入,要么存储在一个文本文件中,此命令执行数据的顺序如下:
每次仅读取一行内容;
根据提供的规则命令匹配并修改数据.注意,sed 默认不会直接修改源文件数据,而是会将数据复制到缓冲区中,修改也仅限于缓冲区中的数据;
将执行结果输出.
当一行数据匹配完成后,它会继续读取下一行数据,并重复这个过程,直到将文件中所有数据处理完毕.
12345678910111213141516171819202122232425262728293031323334353637➜ ~ sedUsage: sed [OPTION]... {script-only-if-no-other-script} [input-file]... -n, --quiet, --silent suppress automatic printing of pattern space -e script, --expression=script a ...