吐槽

linux下常用指令汇总

  • 解压与压缩
###########解压
tar -xvf file.tar //解压 tar包
tar -xzvf file.tar.gz //解压tar.gz
tar -xjvf file.tar.bz2 //解压 tar.bz2
tar -xZvf file.tar.Z //解压tar.Z
unrar e file.rar //解压rar
unzip file.zip //解压zip

###########压缩
tar -cvf jpg.tar *.jpg //将目录里所有jpg文件打包成tar.jpg
tar -czf jpg.tar.gz *.jpg //将目录里所有jpg文件打包成jpg.tar后,并且将其用gzip压缩,生成一个gzip压缩过的包,命名为jpg.tar.gz
tar -cjf jpg.tar.bz2 *.jpg //将目录里所有jpg文件打包成jpg.tar后,并且将其用bzip2压缩,生成一个bzip2压缩过的包,命名为jpg.tar.bz2
tar -cZf jpg.tar.Z *.jpg //将目录里所有jpg文件打包成jpg.tar后,并且将其用compress压缩,生成一个umcompress压缩过的包,命名为jpg.tar.Z
rar a jpg.rar *.jpg //rar格式的压缩,需要先下载rar for linux
zip jpg.zip *.jpg //zip格式的压缩,需要先下载zip for linux
  • 防火墙设置
###(–permanent永久生效,没有此参数重启后失效)
firewall-cmd --zone=public --add-port=80/tcp --permanent 
firewall-cmd --reload
firewall-cmd --zone=public --query-port=80/tcp
##删除
firewall-cmd --zone= public --remove-port=80/tcp --permanent
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT
service iptables save
  • 防火墙设置
###(–permanent永久生效,没有此参数重启后失效)
firewall-cmd --zone=public --add-port=80/tcp --permanent 
firewall-cmd --reload
firewall-cmd -–zone= public --query-port=80/tcp
##删除
firewall-cmd --zone= public --remove-port=80/tcp --permanent
  • 更改端口与ssh认证rsa密钥
vim /etc/ssh/sshd_config
##更改port,更改允许rsa ssh
service sshd restart
ssh-keygen
#或者建立文件夹,自己拷贝id_rsa.pub 文件进去
mkdir ~/.ssh
#通过sftp拷贝id_rsa.pub
cd .ssh
cat id_rsa.pub >> authorized_keys
chmod 600 authorized_keys
chmod 700 ~/.ssh
vim /etc/ssh/sshd_config 
   RSAAuthentication yes
   PubkeyAuthentication yes
  • 安装pyenv
##pyenv 依赖
yum install readline readline-devel readline-static -y
yum install openssl openssl-devel openssl-static -y
yum install sqlite-devel -y
yum install bzip2-devel bzip2-libs -y
yum install zlib-devel bzip2-devel sqlite sqlite-devel openssl-devel gcc -y
##debian 系列
apt-get install make build-essential libssl-dev zlib1g-dev libbz2-dev libsqlite3-dev
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
exec "$SHELL"
##debian 将.bash_profile换成.bashrc
  • go-ss一键安装
wget --no-check-certificate -O shadowsocks-go.sh https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-go.sh
chmod +x shadowsocks-go.sh
./shadowsocks-go.sh 2>&1 | tee shadowsocks-go.log
###卸载
./shadowsocks-go.sh uninstall
###配置
/etc/shadowsocks/config.json
  • bbr一键安装
wget --no-check-certificate https://github.com/teddysun/across/raw/master/bbr.sh && chmod +x bbr.sh && ./bbr.sh
uname -r
sysctl net.ipv4.tcp_available_congestion_control
sysctl net.ipv4.tcp_congestion_control
sysctl net.core.default_qdisc
lsmod | grep bbr
  • vps测试
wget -qO- bench.sh | bash
  • 非root源码安装软件
./configure --prefix=/pathtoapp --with-app=/pathtootherapp
make 
make install
另外推荐linuxbrew包管理器
sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
test -d ~/.linuxbrew && PATH="$HOME/.linuxbrew/bin:$HOME/.linuxbrew/sbin:$PATH"
test -r ~/.bashrc && echo "export PATH='$(brew --prefix)/bin:$(brew --prefix)/sbin'":'"$PATH"' >>~/.bashrc
brew install zsh