这里记录一些平时收集的一些工具或有趣的东西
2048-cli
终端中的 2048
dnf install 2048-cli
MapSCII
在终端显示世界地图
telnet mapscii.me
neofetch
命令行系统信息工具
apt-get update
apt-get install -y neofetch
neofetch
star war
一段 22 分钟长的 ASCII 动画
telnet towel.blinkenlights.nl
nyancat
终端中的 Nyancat
git clone https://github.com/klange/nyancat.git
cd nyancat
make && cd src
./nyancat
yes
yes命令在命令行中输出指定的字符串,直到yes进程被杀死。不带任何参数输入yes命令默认的字符串就是y。
yes hahaa
yes yes | xxx.sh
lolcat
彩色输出
gem install lolcat
echo "test" | lolcat
fish
一个挺好用的 shell 环境
apt-add-repository ppa:fish-shell/release-3
apt-get update
apt-get install -y fish
oh-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
themes
-
https://github.com/robbyrussell/oh-my-zsh/wiki/themes
下载完放置在 ~/.oh-my-zsh/themes 目录目录下,并在配置文件 .zshrc 中进行指定.
vim ~/.zshrc ZSH_THEME="<指定你的主题>"
powerline-shell
增强美化 shell 的工具
依赖 python 环境
pip install powerline-shell
- fish
vim ~/.config/fish/config.fish function fish_prompt powerline-shell --shell bare $status end
starship
轻量级、反应迅速,可定制的高颜值终端!
curl -fsSL https://starship.rs/install.sh | bash
将初始化脚本添加到您的 shell 的配置文件
# Bash
echo "eval \"\$(starship init bash)\"" >> ~/.bashhrc
# Fish
echo "starship init fish | source" >> ~/.config/fish/config.fish
# Zsh
echo "eval \"\$(starship init zsh)\"" >> ~/.zshrc
mosh
使用 UDP 传输的 Shell
apt install mosh
mosh --ssh="ssh -p 2222" root@host
duf
显示磁盘使用状态
wget https://github.com/muesli/duf/releases/download/v0.7.0/duf_0.7.0_linux_amd64.deb
dpkg -i duf_0.7.0_linux_amd64.deb
duf
glances
top/htop 的替代品
curl -L https://bit.ly/glances | /bin/bash
glances
inxi
显示系统和硬件信息
apt-get install inxi
inxi -F
# -A 显示音频 声卡相关信息
# -b 输出基本信息
# -c [0-32] 不同的配色
# -C 显示完整的 CPU 信息
# -d 显示光驱和硬盘相关信息
# -D 显示硬盘相关信息
# -F 完整报告
# -G 显卡
# -i WAN IP
# -I processes, uptime, memory, shell type etc
# -m RAM data
# -M machine data 主板,BIOS etc
# -p 完整分区信息
# -S 系统信息,hostname,kernel,桌面环境,发行版等等
# -u 分区 UUID
btop
wget https://github.com/aristocratos/btop/releases/download/v1.2.0/btop-x86_64-linux-musl.tbz
tar -xjvf btop-x86_64-linux-musl.tbz
bash install.sh
btop
BestTrace
路由跟踪程序
cd /home && mkdir tmp && cd tmp
wget https://cdn.ipip.net/17mon/besttrace4linux.zip
unzip besttrace4linux.zip
chmod +x besttrace
mv besttrace /usr/local/bin
cd /home && rm -rf /home/tmp
# 安装完成后,就可以用指令 besttrace IP/域名 来追踪路由了
Fast
Fast 是 Netflix 提供的服务。它的网址是 Fast.com,同时它有一个可通过 npm 安装的命令行工具:
npm install --global fast-cli
```bash
```bash
fast # 该命令返回你的网络下载速度
fast -u # 获取上传速度
httpie
命令行下的 HTTP 客户端
yum install -y httpie
或
apt-get install -y httpie
http httpie.org
iPerf
iPerf 是测试网速的工具
# debian
apt install -y iperf
# centos
wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm
rpm -Uvh rpmforge-release-1.5.3-1.el7.rf.x86_64.rpm
yum update
yum install -y iperf
安装完成后,你需要在同一网络上的两台计算机上使用它(两台都必须安装 iPerf)。指定其中一台作为服务器。
在服务端启动 iperf
iperf -s
它会等待来自客户端的传入连接。将另一台计算机作为为客户端并运行此命令
iperf -c <服务端IP>
只需几秒钟即可完成测试,然后返回传输大小和计算出的带宽。
speedtest-cli
Speedtest.net 提供一个命令行版本——speedtest-cli,能够在终端中简单快速的测试出 linux 的网速
wget https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py
chmod a+rx speedtest.py
mv speedtest.py /usr/local/bin/speedtest-cli
chown root:root /usr/local/bin/speedtest-cli
speedtest-cli
或
pip install speedtest-cli
speedtest-cli
gping
图形化的 ping 工具
echo "deb http://packages.azlux.fr/debian/ buster main" | sudo tee /etc/apt/sources.list.d/azlux.list
wget -qO - https://azlux.fr/repo.gpg.key | sudo apt-key add -
sudo apt update
sudo apt install gping
nethogs
查看每个进程流量
apt install nethogs
nethogs
ab
ab 是 apache 的压力测试工具
安装
apt install -y apache2-utils
yum install -y httpd-tools
wrk
压测工具
git clone --depth 1 https://github.com/wg/wrk.git
cd wrk && make
cp wrk /usr/local/bin/
wrk
wrk -t12 -c1000 -d15s http://127.0.0.1
websocat
nc 的 WebSocket 版
mono
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/debian wheezy main" | tee /etc/apt/sources.list.d/mono-xamarin.list
echo "deb http://download.mono-project.com/repo/debian wheezy-apache24-compat main" | tee -a /etc/apt/sources.list.d/mono-xamarin.list
echo "deb http://download.mono-project.com/repo/debian wheezy-libjpeg62-compat main" | tee -a /etc/apt/sources.list.d/mono-xamarin.list
apt-get update
apt-get install -y mono-devel mono-complete referenceassemblies-pcl ca-certificates-mono
base64
base64 # 编码
test # 输入内容
Ctrl+D # 结束,输出
base64 -d # 解码
dGVzdAo=
Ctrl+D # 结束,输出
echo "str" | base64 -w 0
echo "c3RyCg==" | base64 -d
这个傻逼工具会默认每 76 个字符换行,格式化输出,用 -w 0 关闭
expand
将 TAB 转换为空格
expand test.txt
unexpand
将空格转换为 TAB
unexpand test.txt
sttr
cross-platform, cli app to perform various operations on string
sttr md5 "Hello World"
sttr base64-encode image.jpg
echo "Hello World" | sttr md5
cat file.txt | sttr md5
seq
seq 命令用于生成某个范围内的整数
seq [选项]... [首数] [增量] 尾数
seq 10 # 输出1-10的所有整数
seq 3 5 # 输出3-5的所有整数
seq 1 2 5 # 1-5,增量为2
seq -f "id:%06g" 1 2 5 # 以特定格式输出
seq -w 1 101 # 使所有数据等宽
seq -w -s ' ' 99 101 # 以空格分隔所有的数据
choose
cut 命令的替代品, 用来选中指定的栏位。
cat test.txt | choose 0
choose 0 -i test.txt
csvtk
命令行下处理 CSV/TSV格式
dsq
一个命令行工具,可以对 JSON、CSV、Excel 等格式的文件执行 SQL 查询语句。
yq
像 jq 一样对 yaml,json,xml 使用 yq
go install github.com/mikefarah/yq/v4@latest
tee test.yaml <<-'EOF'
volumes:
beehive-conf:
driver: local
services:
- beehive
EOF
yq '.volumes.beehive-conf' test.yaml
yq '.services' test.yaml
xmllint
解析 xml 格式
sudo apt-get install libxml2-utils
xmllint --xpath "//book[@id=2]/name/text()" sample.xml
xpath
解析 xml 格式
xpath -e '//book/name/text()' sample.xml
jq
该工具帮助阅读 json 格式的数据
apt-get install -y jq
JsonData='[
{"Book":"PHP 7"},
{"Publication":"Apress"},
{"Book":"React 16 Essentials"},
{"Publication":"Packt"}
]'
echo "${JsonData}" | jq '.'
cat test.json | jq '.[].ip+":"'
cat test.json | jq '.[].port'
cat craw1.json | jq '.req_list[].url'
cat test.json | jq '.' -r # 不带双引号
cat chaos-bugbounty-list.json | jq -r '.programs[] | select(.bounty == true) | .domains' | sort -u | cut -d '"' -f2 > urls.txt
-
相关教程
- https://justcode.ikeepstudying.com/2018/02/shell%EF%BC%9A%E6%97%A0%E6%AF%94%E5%BC%BA%E5%A4%A7%E7%9A%84shell%E4%B9%8Bjson%E8%A7%A3%E6%9E%90%E5%B7%A5%E5%85%B7jq-linux%E5%91%BD%E4%BB%A4%E8%A1%8C%E8%A7%A3%E6%9E%90json-jq%E8%A7%A3%E6%9E%90-json/
- https://mozillazg.com/2018/01/jq-use-examples-cookbook.html
- https://www.jianshu.com/p/6de3cfdbdb0e
-
在线调试
jo
生成json格式数据的小工具
wget https://github.com/jpmens/jo/releases/download/1.6/jo-1.6.tar.gz
tar xvzf jo-1.6.tar.gz
cd jo-1.6
autoreconf -i
./configure
make check
make install
jo name=Jane
seq 1 10 | jo -a
jo time=$(date +%s) dir=$HOME
jo -p -a spring summer winter
jd
json 比较工具
go install github.com/josephburnett/jd@latest
jd a.json b.json
gron
json 数据格式化
go install github.com/tomnomnom/gron@latest
gron test.json
jless
命令行的json查看工具
htmlq
像 jq 一样对 html 使用 yq
imcat
在终端显示任何图片
git clone https://github.com/stolk/imcat.git
make
./imcat xxx.png
Termtosvg
将你在 Linux 终端中操作录制成 SVG 动画
pip3 install termtosvg pyte python-xlib svgwrite
termtosvg
# 按下 CTRL+D 或输入 exit 来停止录制。录制完后,输出文件会以一个独一无二的名字被保存在 /tmp 文件夹中。
gimp
GIMP(全称 Gnu 图像处理程序)是一款免费的、跨平台的开源图像处理程序。
add-apt-repository ppa:otto-kesselgulasch/gimp
apt-get update
apt-get install -y gimp # 安装 gimp
gimp # 启动 gimp
asciinema
pip3 install asciinema
apt-get install asciinema
yum install asciinema
dnf install asciinema
asciinema rec
zbarimg
命令行解析二维码
apt install zbar-tools
zbarimg xxx.png
montage
将多个小图片拼成一张图
apt install imagemagick
montage xxx.jpg -tile 8x15 -geometry 200x100+0+0 output.jpg
gaps
修复、还原图片
gaps --image=output.jpg --generations=40 --population=120 --size=100
gaps -image=flag.jpg -generations=50 -population=120 -size=50
bc
任意精度计算器
bc # 进入交互模式,输入 quit 退出
# e.g.
echo "15+5" | bc
echo "10^10" | bc
echo "sqrt(100)" | bc
echo 'scale=2; (2.777 - 1.4744)/1' | bc # scale=2 设小数位,2 代表保留两位:
rlwrap
解决各类 shell 中无法上下左右的问题
apt install rlwrap
rlwrap [Command]
trash-cli
回收站的命令行界面
pip3 install trash-cli
tr
命令行届的翻译
# 转换大小写
echo "abc" | tr a-z A-Z
echo "abc" | tr [:lower:] [:upper:]
# 将空白转换成 TABs
echo "a b" | tr [:space:] '\t'
# 转换括号
echo "{abc}" | tr "{}" "()"
# 删除 -d 指定的字符集
echo "abc" | tr -d 'a'
# 删除数字
echo "123abc123" | tr -d [:digit:]
# 删除连续空白
echo "emmmmmmmmmm no" | tr -s [:space:] ' '
# 删除空行
cat test.txt | tr -s '\n'
# squeeze repeats
echo "abbbbccccbd" | tr -s a-z A-Z
# 删除除了数字之外的内容
echo "my id is 123" | tr -cd [:digit:]
# 将不是 SET1 中的内容,替换为 SET2 中内容
echo 'abc123' | tr -c [:digit:] x
xclip
在 Linux 命令行中复制粘贴
xclip file_name # 将文件的内容复制到剪贴板
hexyl
命令行十六进制查看器
apt install hexyl
hexyl a.png
DeepL
非常好用的翻译软件
yarn global add deepl-translator-cli
deepl translate -t 'DE' 'How do you do?'
translate-shell
wget git.io/trans
chmod +x ./trans
./trans 'Saluton, Mondo!'
anew
cat newthings.txt | anew things.txt
cat newthings.txt | anew things.txt > 1.txt
ranger
linux 文件管理工具 ranger, 具有 Vim 式的操作方式.
apt install ranger && pip install ranger-fm
ranger
# 使用 h,j,k,l 来进行光标的移动, 来穿越在不同的文件夹中
# q 退出
# S 来进行当前光标所在的文件夹中 exit 命令重新回到 ranger 程序当中去
使用 ranger --copy-config=all
将在 ~/.config/ranger
中生成一系列配置文件, 其中 ranger 主要有 4 个配置文件.
- rc.conf 常用于设置选项和绑定快捷键.(最常用)
- scope.sh 常用于设置文件的预览方式.
- rifle.conf 常用于设置使用那个软件来打开文件.
- commands.py python 文件, 增强和改进 ranger 的各种功能.
exa
ls 的替代品
# fefora
dnf install exa
# debian
apt install exa
exa -l -F
broot
类似 ranger 的树形图目录查看工具
br -s
bat
cat 的替代品
# fefora
dnf install bat
# debian
wget https://github.com/sharkdp/bat/releases/download/v0.19.0/bat_0.19.0_amd64.deb
dpkg -i bat_0.19.0_amd64.deb
- https://github.com/dshearer/jobber
- https://github.com/rundeck/rundeck
- https://github.com/shunfei/cronsun
wait-for
监测服务是否可用
./wait-for www.eficode.com:80 -- echo "Eficode site is up"
Eficode site is up
wait-for-it
监测服务是否可用
./wait-for-it.sh -t 0 db:3306 -- echo "mysql is up"
./wait-for-it.sh -t 0 rabbitmq:5672 -- echo "rabbitmq is up"
yes
帮你自动回答命令行提示
yes | rm -i *.test
yes n | rm -i *.test
usql
多合一命令行下数据库管理工具
GO111MODULE=on go install -tags 'all' github.com/xo/usql@latest
# 或
go install github.com/xo/usql@master
# connect to a postgres database
$ usql pg://user:pass@host/dbname
$ usql pgsql://user:pass@host/dbname
$ usql postgres://user:pass@host:port/dbname
$ usql pg://
$ usql /var/run/postgresql
$ usql pg://user:pass@host/dbname?sslmode=disable # Connect without SSL
# connect to a mysql database
$ usql my://user:pass@host/dbname
$ usql mysql://user:pass@host:port/dbname
$ usql my://
$ usql /var/run/mysqld/mysqld.sock
# connect to a sqlserver database
$ usql sqlserver://user:pass@host/instancename/dbname
$ usql ms://user:pass@host/dbname
$ usql ms://user:pass@host/instancename/dbname
$ usql mssql://user:pass@host:port/dbname
$ usql ms://
# connect to a sqlserver database using Windows domain authentication
$ runas /user:ACME\wiley /netonly "usql mssql://host/dbname/"
# connect to a oracle database
$ usql or://user:pass@host/sid
$ usql oracle://user:pass@host:port/sid
$ usql or://
# connect to a cassandra database
$ usql ca://user:pass@host/keyspace
$ usql cassandra://host/keyspace
$ usql cql://host/
$ usql ca://
# connect to a sqlite database that exists on disk
$ usql dbname.sqlite3
# NOTE: when connecting to a SQLite database, if the "<driver>://" or
# "<driver>:" scheme/alias is omitted, the file must already exist on disk.
#
# if the file does not yet exist, the URL must incorporate file:, sq:, sqlite3:,
# or any other recognized sqlite3 driver alias to force usql to create a new,
# empty database at the specified path:
$ usql sq://path/to/dbname.sqlite3
$ usql sqlite3://path/to/dbname.sqlite3
$ usql file:/path/to/dbname.sqlite3
# connect to a adodb ole resource (windows only)
$ usql adodb://Microsoft.Jet.OLEDB.4.0/myfile.mdb
$ usql "adodb://Microsoft.ACE.OLEDB.12.0/?Extended+Properties=\"Text;HDR=NO;FMT=Delimited\""
# connect with ODBC driver (requires building with odbc tag)
$ cat /etc/odbcinst.ini
[DB2]
Description=DB2 driver
Driver=/opt/db2/clidriver/lib/libdb2.so
FileUsage = 1
DontDLClose = 1
[PostgreSQL ANSI]
Description=PostgreSQL ODBC driver (ANSI version)
Driver=psqlodbca.so
Setup=libodbcpsqlS.so
Debug=0
CommLog=1
UsageCount=1
# connect to db2, postgres databases using ODBC
$ usql odbc+DB2://user:pass@localhost/dbname
$ usql odbc+PostgreSQL+ANSI://user:pass@localhost/dbname?TraceFile=/path/to/trace.log
croc
Easily and securely send things from one computer to another
A : send file
croc send xxx.txt
Code is: xxxx-xxxx
B : receive file
croc xxxx-xxxx
magic-wormhole
get things from one computer to another, safely
fq
jq for binary formats
fq . file.mp3