Linux: 高效工具
linux环境配置
初始化步骤
sudo apt install git git clone https://gitee.com/karl1864/linux mkdir ~/.config cp -r zshrc ~/.zshrc cp -r ranger ~/.config/ ln -s ~/.tmux/.tmux.conf ~/.tmux.conf ln -s ~/linux/tmux.conf ~/.tmux.conf.local sudo apt install zsh chsh -s /usr/bin/zsh git clone https://gitee.com/mirrors/oh-my-zsh ~/.oh-my-zsh git clone https://github.com/gpakosz/.tmux ~/.tmux # 重启shell installzplug # zpluginstall
终端效率工具记录
tldr
命令的使用用例
- sudo apt install tldr
- tldr tldr
zshell
- Ctrl+R: 搜索命令历史
- Ctrl+U: 删除命令
- Ctrl+W: 删除一个词
- Ctrl+D: exit
- Ctrl+A: 回到行首
- Ctrl+E: 回到行末
ranger
文件管理
sudo apt install ranger ra ra path
lazygit
https://github.com/jesseduffield/lazygit
cat <<\EOF> /etc/yum.repos.d/copr.repo [copr:copr.fedorainfracloud.org:atim:lazygit] name=Copr repo for lazygit owned by atim baseurl=https://download.copr.fedorainfracloud.org/results/atim/lazygit/epel-7-$basearch/ type=rpm-md skip_if_unavailable=True gpgcheck=1 gpgkey=https://download.copr.fedorainfracloud.org/results/atim/lazygit/pubkey.gpg repo_gpgcheck=0 enabled=1 enabled_metadata=1 EOF yum install lazygit -y ?呼出帮助
- 时区选择 6 70
- sudo apt install golang
- go get github.com/jesseduffield/lazygit
- lg
tmux
- sudo apt install tmux
- retmux $name
expect
- sudo apt install expect
#!/bin/bash expect <<EOF set timeout 3600 spawn $* expect { "Username" { send "xxxuser\r"; exp_continue; } "Password" { send "xxxpass\r"; } } expect eof EOF
sudo
- sudo vim /etc/sudoers
- luwh ALL=(ALL) NOPASSWD: ALL
glances
- mkdir ~/.pip
- vim ~/.pip/pip.conf
[global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple [install] trusted-host = https://pypi.tuna.tsinghua.edu.cn
- sudo apt install python3-pip
- pip3 install glances
- iotop + htop
- tldr glances
lazydocker
- go get github.com/jesseduffield/lazydocker
- 类似lazygit的docker管理工具
- 我主要拿来查看当前docker状态
- github.com/jesseduffield/lazydocker
docker run --rm -it -v \ /var/run/docker.sock:/var/run/docker.sock \ -v /yourpath:/.config/jesseduffield/lazydocker \ lazyteam/lazydocker
docker
sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add - sudo add-apt-repository "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/ $(lsb_release -cs) stable" sudo apt update sudo apt install docker-ce sudo systemctl start docker sudo usermod -aG docker $(whoami)
ncdu
- sudo apt install ncdu
- 文件大小查看器
- 磁盘清理工具
- tldr ncdu
tig
- https://github.com/jonas/tig
- sudo apt install tig
- git 历史查看器
- tldr tig
tig --all #可以看到包括远程分支的情况 常用快捷命令 h 帮助 t
ack
- sudo apt install ack
- tldr ack
- 非侵入式着色器
ack –flush –passthru –color –color-match="red on_yellow blink italic underline bold" $keyword
- ack -g filename 搜索文件名
ag
https://github.com/ggreer/the_silver_searcher
ag > pt > ack > grep
- sudo apt install silversearcher-ag
- yum install the_silver_searcher
- grep的优化版
- tldr ag
bat
- sudo apt install bat
- cat的高亮版
zenity
- sudo apt install zenity
- 电脑给你发中断
- zenity –info –text="$1"
- zenity –question –text="番茄钟${total_min}分钟到了" –ok-label="跳过休息" –cancel-label="休息继续"
- zenity –question –text="番茄钟休息完毕" –ok-label="继续奋战" –cancel-label="算了算了"
fzf
- sudo apt install fzf
- 交互式grep
- 用法和grep一样
- tldr fzf
shc
- sudo apt install shc
- shell加密工具
- shc -f script
- shc –help
- tldr shc
colorls
- gem install colorls
- 华丽胡哨ls
Linux命令行多线程、断点续传下载工具
线程下载 运维工作中常会在linux命令行下载外网文件或内网进行大文件传输,经常使用的文本下载工具wget、curl,今天给大家推荐支持Linux命令行多线程、断点续传下载工具axel和myget。
1 安装axel
yum -y install epel-release yum install axel
参考选项
--max-speed=x #限速值最高速度 -s x Specify maximum speed (bytes per second) --num-connections=x -n x #连接数 Specify maximum number of connections --output=f #下载为本地文件 -o f Specify local output file --search[=x] #搜索镜像 -S [x] Search for mirrors and download from x servers --header=x -H x #添加头文件字符串 Add header string --user-agent=x #设置UA -U x Set user agent --no-proxy #不使用代理服务器 -N Just don't use any proxy server --quiet --quiet, -q No output to stdout. #静默模式,不输出到标准输出
axel -n 100 http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.2.2.0/ambari-2.2.2.0-centos7.tar.gz
其它安装
也可以安装yum-axelget插件,默认 yum使用单线程下载,安装该插件后,会使用多线程下载。
yum -y install yum-axelget
- myget 下载、安装
安装
wget http://myget.sourceforge.net/release/myget-0.1.2.tar.gz
tar zxf myget-0.1.2.tar.gz
cd myget-0.1.2
./configure && make && make install
选项参数
-b, --debug Show the debug message #看调试信息 -c, --count=num Set the retry count to [num], no limit when "0", the default is "99" #设置重试次数,0为无限,默认是99次。 -d, --directory=dir Set the local direcotry to [dir], the default is "." #指定下载本地目录,默认是当前目录 -f, --file=file Rename the file to [file] #重命名下载到本地的文件名 -h, --help A brief summary of all the options #简短的帮助摘要 -i, --interval=num Set the ftp retry interval to [num] seconds, the default is "5" #设置ftp重试间隔,单位s,默认5秒 -n, --number=num Use [num] connections instead of the default (4) #指定连接数,默认4 -r, --referer=URL Include `Referer: [URL]' header in HTTP request. #包含请求头 Referer -t, --timeout=num Set the connection timeout to [num] seconds, the default is "30" #设置连接超时时间,默认30秒 -v, --version Show the version of the myget and exit #查看版本信息 -x, --proxy=URL Set the proxy [URL] #设置代理
mytget -n 10 http://url/iso/Centos/x86_64/CentOS-6.4-x86_64-bin-DVD1.iso Begin to download: CentOS-6.4-x86_64-bin-DVD1.iso
- 断点续传
三个工具都支持,但wget需要增加-c参数,axel、myget再次执行命令即可。
综上对比推荐大家工作中使用axel或myget提高效率,个人比较喜欢axel。
注意内网传输根据隧道带宽进行限速,别影响线上生产服务数据传输。