随笔分类 -  Linux系统基础及管理

摘要:# cat check_env.sh #!/bin/bash # echo " 检查CPU " ansible all -m shell -a "cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c" echo " 检查内存 " ansible 阅读全文
posted @ 2023-03-15 08:53 Varden
摘要:生活在 Bash shell 中,熟记以下快捷键,将极大的提高你的命令行操作效率。 1. 编辑命令 Ctrl + a :移到命令行首 < 常用命令 Ctrl + e :移到命令行尾 < 常用命令 Ctrl + f :按字符前移(右向) Ctrl + b :按字符后移(左向) Alt + f :按单词 阅读全文
posted @ 2022-04-08 00:15 Varden
摘要:参考:https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-debian-10 警告:虽然通常建议对使用传统旋转硬盘驱动器的系统进行交换,但对 SSD 使用交换可能会导致硬件随着时间的推移出现退化问题。出于 阅读全文
posted @ 2021-10-15 09:36 Varden
摘要:选项说明 常用选项: -z, --gzip: 使用gzip工具(解)压缩,后缀一般为.gz -c, --create: tar打包,后缀一般为.tar -f, --file=: 后面立刻接打包或压缩后得到的文件名 -x, --extract: 解包命令,与 -c 对应 -p: 保留备份数据的原本权限 阅读全文
posted @ 2021-08-24 14:02 Varden
摘要:同步命令 # rsync -vzrtopg --progress hadoop@192.168.5.172::hadoop /usr/local/hadoop/etc/hadoop #在服务端touch一个文件,同步后就会出现 使用crontab实现定时自动同步功能 # vim /etc/rsync 阅读全文
posted @ 2021-08-24 11:40 Varden
摘要:主要配置文件 # vim /etc/default/rsync RSYNC_ENABLE=true # cp /usr/share/doc/rsync/examples/rsyncd.conf /etc/ 配置文件内容解释 # sample rsyncd.conf configuration fil 阅读全文
posted @ 2021-08-24 11:28 Varden
摘要:# date -s "2017-08-23 17:18:00" ## 修改系统时间 # hwclock -w ## 修改硬件时钟 # hwclock -r ## 查看硬件时钟 阅读全文
posted @ 2021-08-24 08:36 Varden
摘要:使用 nohup 运行命令可以使命令永久的执行下去直至命令退出,和用户终端没有关系。 例如,我们断开 SSH 连接都不会影响他的运行,注意了 nohup 没有后台运行的意思, 加上 & 才是后台运行。 nohup COMMAND & 这样就能使命令永久的在后台执行直至退出。 操作示例: # nohu 阅读全文
posted @ 2021-08-24 08:33 Varden
摘要:PS: cron 默认发送的邮件和任务输出的信息会占用大量本地磁盘空间,实际环境中必须合理配置定时任务。 禁止 cron 发送邮件 执行 crontab -e 编辑模式修改或注释以下行: MAILTO="" ## 指定邮箱发送位置 任务输出重定向 执行 crontab -e 在任务命令末尾加上以下内 阅读全文
posted @ 2021-08-24 08:23 Varden
摘要:``` find /nfs/backup/*.sql -type f -ctime +N | xargs rm -f ``` 阅读全文
posted @ 2021-08-24 08:11 Varden
摘要:动态查看进程的内存使用量 top -d 1 -p <pid> [,pid ...] ## -d设置为delay 1s,默认是delay 3s PS: 如果想根据内存使用量进行排序,可以shift + m(Sort by memory usage)。 静态查看 pmap命令 pmap <pid> ps 阅读全文
posted @ 2021-08-24 08:02 Varden
摘要:示例: # netstat -ant | awk '/^tcp/ {++S[$NF]} END {for(a in S) print (a,S[a])}' # ss -s 输出信息: LISTEN 44 CLOSE_WAIT 57 TIME_WAIT 3 ESTABLISHED 1275 TCP连接 阅读全文
posted @ 2021-08-23 17:37 Varden
摘要:取文件第一行: head -1 /var/lib/mysql/binlog.index 取文件第二行: head -2 /var/lib/mysql/binlog.index | tail -n 1 取文件倒数第一行: tail /var/lib/mysql/binlog.index -n 1 取文 阅读全文
posted @ 2021-08-23 17:19 Varden
摘要:rsync -P --rsh=ssh home.tar 192.168.205.34:/tmp/home.tar 阅读全文
posted @ 2021-08-23 17:16 Varden
摘要:使用内存前10: # ps aux | sort -k4nr | head -n 10 使用CPU前10: # ps aux | sort -k3nr | head -n 10 查看内存和应用名: # ps -aux | sort -k4nr | head -n 10 | tr -s ' '| cu 阅读全文
posted @ 2021-08-23 17:11 Varden
摘要:列出所有端口 (包括监听和未监听的) 列出所有端口 netstat -a 列出所有 tcp 端口 netstat -at 列出所有 udp 端口 netstat -au 列出所有处于监听状态的 Sockets 只显示监听端口 netstat -l 只列出所有监听 tcp 端口 netstat -lt 阅读全文
posted @ 2021-08-23 16:56 Varden
摘要:gzip 是 Linux 系统中经常用来对文件进行压缩和解压缩的命令,通过此命令压缩得到的新文件,其扩展名通常标记为“.gz”。 再强调一下,gzip 命令只能用来压缩文件,不能压缩目录,即便指定了目录,也只能压缩目录内的所有文件。 gzip 命令的基本格式如下: # gzip [选项] 源文件 命 阅读全文
posted @ 2021-08-23 16:45 Varden
摘要:# /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 阅读全文
posted @ 2021-08-23 16:38 Varden
摘要:nc -ul 6000 # 在一台主机上运行作为服务端 nc -u <host_ip> 6000 # 在另一台主机上连接 nc -vuz <host_ip> 1194 # 测试目标端口是否正常 nc -vu <host_ip> 1194 # 向UDP端口发送消息 tcpdump -i eth0 -s 阅读全文
posted @ 2021-08-23 15:59 Varden
摘要:# apt install iputils-arping # 安装工具 # arping -h # 获取帮助信息 Usage: arping [options] <destination> Options: -f quit on first reply 等到第一个回复就退出 -q be quiet 阅读全文
posted @ 2021-08-23 15:49 Varden