Logo

Some Tips

Apr 14 · 1 min

Linux Tips

vim 关闭 visual 模式

echo "set mouse-=a" >> ~/.vimrc

zsh 以及 oh-my-zsh的配置安装

安装 zsh和 oh-my-zsh

apt -y install zsh
bash -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

安装 zsh-autosuggestions 和 zsh-syntax-highlighting

git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting

修改.zshrc

# 在 ~/.zshrc 中添加或修改以下内容:
ZSH_THEME="agnoster"
plugins=(
        git
        zsh-autosuggestions
        zsh-syntax-highlighting
)

修改默认的终端为zsh

# 切换到zsh
source ~/.zshrc
# 修改默认使用的终端
chsh -s $(which zsh)

bash 和 zsh 添加 kubectl 自动补全

# bash临时添加kubectl的自动补全
source <(kubectl completion bash)
# bash永久添加kubectl的自动补全
echo "source <(kubectl completion bash)" >> ~/.bashrc

# zsh临时添加kubectl的自动补全
source <(kubectl completion zsh)
# zsh永久添加kubectl的自动补全
echo '[[ $commands[kubectl] ]] && source <(kubectl completion zsh)' >> ~/.zshrc

Debian12 自动化安装

  • 默认不创建非 root 用户
  • 仍需要手动进行硬盘分区
  • 自动化安装配置文件:下载链接

Debian12 初始化修改

修改默认软件源

# 备份默认软件源
mv /etc/apt/sources.list /etc/apt/sources.list.old
# 替换为新的软件源
cat > /etc/apt/sources.list << EOF
deb https://mirrors.aliyun.com/debian/ bookworm main contrib non-free non-free-firmware
deb-src https://mirrors.aliyun.com/debian/ bookworm main contrib non-free non-free-firmware

deb https://mirrors.aliyun.com/debian/ bookworm-updates main contrib non-free non-free-firmware
deb-src https://mirrors.aliyun.com/debian/ bookworm-updates main contrib non-free non-free-firmware

deb https://mirrors.aliyun.com/debian/ bookworm-backports main contrib non-free non-free-firmware
deb-src https://mirrors.aliyun.com/debian/ bookworm-backports main contrib non-free non-free-firmware

deb https://mirrors.aliyun.com/debian-security/ bookworm-security main contrib non-free non-free-firmware
deb-src https://mirrors.aliyun.com/debian-security/ bookworm-security main contrib non-free non-free-firmware
EOF

添加docker源并安装

# 添加软件源
apt-get install ca-certificates curl
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
chmod a+r /etc/apt/keyrings/docker.asc

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://mirrors.aliyun.com/docker-ce/linux/debian \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  tee /etc/apt/sources.list.d/docker.list > /dev/null

# 安装docker
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y

配置静态IP

vim /etc/network/interfaces

auto ens33
iface ens33 inet static
address 192.168.2.2
netmask 255.255.255.0
gateway 192.168.2.1

systemctl restart networking.service
>