Linux 小连招

Table of content:

实用脚本

安装docker

  • 国内
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
  • 国外
curl -sSL https://get.daocloud.io/docker | sh

安装Neo4j

参考 官方文档: Neo4j

mkdir -p /etc/apt/keyrings
wget -O - https://debian.neo4j.com/neotechnology.gpg.key | gpg --dearmor -o /etc/apt/keyrings/neotechnology.gpg
echo 'deb [signed-by=/etc/apt/keyrings/neotechnology.gpg] https://debian.neo4j.com stable latest' | tee -a /etc/apt/sources.list.d/neo4j.list
apt-get update
apt-get install neo4j

Gost

创建代理

  • 下载
wget https://github.com/ginuerzh/gost/releases/download/v2.11.5/gost-linux-amd64-2.11.5.gz
gzip -d gost-linux-amd64-2.11.5.gz
mv gost-linux-amd64-2.11.5 gost
chmod +x gost
  • 运行
./gost -L admin:123456@:9999 socks5://:9999

btop

超帅又实用的系统监控工具; 实时显示 CPU / 内存 / 磁盘 / 网络和进程的使用情况和性能指标。

apt install btop

运行直接输入 btop 即可

菜单menu的快捷键是m, 里面还有丰富的主题, 赞

Swap

针对学生党买不起大内存, 可以通过增加swap来提升性能
原理是划出虚拟内存, 性能很差, 至少不爆内存了

  • 安装
# 创建swap文件
sudo fallocate -l 4G /swapfile
# 设置权限
sudo chmod 600 /swapfile
# 将文件设置为swap
sudo mkswap /swapfile
# 启用swap
sudo swapon /swapfile
# 将swap文件添加到/etc/fstab以便开机自动启用
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
  • 检查
# 查看swap状态  
swapon --show
# 或者直接看内存使用情况
free -h
  • 设定Swap使用优先级
# 设置swap使用优先级为10,数值越小优先级越高
sudo sysctl vm.swappiness=60
# 检查当前swap使用优先级
cat /proc/sys/vm/swappiness

代理

原生的话,它会根据apt版本有变化,所以不如只用docker简单又方便。

docker rm -f v2raya 2>/dev/null || true

mkdir -p /etc/v2raya

docker run -d \
  --restart=always \
  --privileged \
  --network=host \
  --name v2raya \
  -e V2RAYA_ADDRESS=127.0.0.1:2017 \
  -e V2RAYA_LOG_FILE=/tmp/v2raya.log \
  -e V2RAYA_V2RAY_BIN=/usr/local/bin/xray \
  -e V2RAYA_NFTABLES_SUPPORT=off \
  -e IPTABLES_MODE=legacy \
  -v /lib/modules:/lib/modules:ro \
  -v /etc/resolv.conf:/etc/resolv.conf \
  -v /etc/v2raya:/etc/v2raya \
  mzz2017/v2raya

然后查看运行状态

docker ps
docker logs -f v2raya

然后这个面板可以通过ssh隧道来查看

ssh -i ~\.ssh\xxx.pem -L 2017:127.0.0.1:2017 root@xxx.xxx.xxx.xxx

trouble shooting

系统没有使用 systemd 作为初始化系统

  • 报错信息:

    System has not been booted with systemd as init system (PID 1). Can't operate.
    Failed to connect to bus: Host is down
    
  • 操作:

    # 备份旧的下载源
    mv /etc/apt/sources.list /etc/apt/sources.list.old
    # 创建新的下载源
    vim /etc/apt/sources.list
    

    vim中填写

    deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
    deb-src https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
    
    deb https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
    deb-src https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
    
    deb https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
    deb-src https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
    
    deb https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
    deb-src https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
    

    输入完成后依次输入: Esc -> :wq -> Enter

    最后: sudo apt update

美化

oh-my-zsh

sudo apt-get install zsh
command -v zsh | sudo tee -a /etc/shells
chsh -s $(which zsh)
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

插件配置

主题

jonathan 主题

ZSH_THEME="jonathan"
ZSH_THEME="gnzh"

zsh-autosuggestions

  1. Clone this repository into $ZSH_CUSTOM/plugins (by default ~/.oh-my-zsh/custom/plugins)

    git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
    
  2. Add the plugin to the list of plugins for Oh My Zsh to load (inside ~/.zshrc):

    plugins=( 
        # other plugins...
        zsh-autosuggestions
    )
    
  3. Start a new terminal session.

zsh-syntax-highlighting

Simply clone this repository and source the script:

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
echo "source ${(q-)PWD}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc

Then, enable syntax highlighting in the current interactive shell:

source ./zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

If git is not installed, download and extract a snapshot of the latest development tree from:

https://github.com/zsh-users/zsh-syntax-highlighting/archive/master.tar.gz

Note the source command must be at the end of ~/.zshrc.


zhyDaDa

Linuxstudy

863 Words

0001-01-01 08:00 +0800