前两天更新显卡驱动,把系统搞崩了。
不得已重装系统,顺便简单记录下来。
系统设置
禁用 root 账户
1
2
| sudo usermod -s /usr/sbin/nologin root
sudo usermod -s /bin/false root
|
禁止 root 账户登录 ssh
1
2
| echo "PermitRootLogin no" >> /etc/ssh/sshd_config
sudo systemctl restart sshd
|
禁止使用密码登陆 ssh
# /etc/ssh/sshd_config
PasswordAuthentication no
PermitEmptyPasswords no
# /etc/ssh/sshd_config
Port 22222
1
| sudo systemctl restart sshd
|
优化 swap 频率
1
2
| echo "vm.swappiness=10" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
|
软件
必备软件
1
2
3
4
| sudo apt install ca-certificates -y
sudo apt install apt-transport-https -y
sudo apt install curl -y
sudo apt install wget -y
|
常用软件
1
2
| sudo apt install zsh -y
chsh -s /bin/zsh
|
1
2
3
| sudo apt install mosh -y
sudo apt install htop -y
sudo apt install iperf3 -y
|
1
2
3
4
5
| echo 'deb http://download.opensuse.org/repositories/shells:/fish:/release:/4/Debian_12/ /' | sudo tee /etc/apt/sources.list.d/shells:fish:release:4.list
curl -fsSL https://download.opensuse.org/repositories/shells:fish:release:4/Debian_12/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/shells_fish_release_4.gpg > /dev/null
sudo apt update
sudo apt install fish -y
chsh -s /usr/bin/fish
|
Flatpak
https://flatpak.org/setup/Debian
1
2
3
| sudo apt install flatpak
sudo apt install plasma-discover-backend-flatpak
flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
|
Keepassxc (flatpak)
密码、OTP、passkey、ssh-key 管理器
1
2
| flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
flatpak install --user flathub org.keepassxc.KeePassXC
|
- Keepassxc 开启 ssh-agent 功能。
- 设置 ssh 的 ssh-agent 自动启动 (kde system setting - Autostart)。
Syncthing
https://apt.syncthing.net
1
2
3
| sudo mkdir -p /etc/apt/keyrings
sudo curl -L -o /etc/apt/keyrings/syncthing-archive-keyring.gpg https://syncthing.net/release-key.gpg
echo "deb [signed-by=/etc/apt/keyrings/syncthing-archive-keyring.gpg] https://apt.syncthing.net/ syncthing stable" | sudo tee /etc/apt/sources.list.d/syncthing.list
|
1
2
| sudo apt update
sudo apt install syncthing -y
|
syncthing 配置目录: ~/.config/syncthing/
启用 syncthing 服务:
1
| sudo systemctl enable --now syncthing@<username>
|
Zerotier
安装
1
2
| curl -s 'https://raw.githubusercontent.com/zerotier/ZeroTierOne/main/doc/contact%40zerotier.com.gpg' | gpg --import && \
if z=$(curl -s 'https://install.zerotier.com/' | gpg); then echo "$z" | sudo bash; fi
|
加入网络
1
| zerotier-cli join <...>
|
Hugo
https://github.com/gohugoio/hugo/releases
安装 hugo_extended
1
2
3
| hugo_version=0.142.0
wget https://github.com/gohugoio/hugo/releases/download/v$hugo_version/hugo_extended_"$hugo_version"_linux-amd64.deb -O /tmp/hugo_extended.deb
sudo apt install /tmp/hugo_extended.deb
|
Sublime Text
1
2
| wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/sublimehq-archive.gpg > /dev/null
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
|
1
2
| sudo apt update
sudo apt install sublime-text -y
|
Thunderbird
https://www.thunderbird.net/en-US/thunderbird/all/
1
| flatpak install flathub org.mozilla.Thunderbird
|
VS Code
https://code.visualstudio.com/Download
Chrome
https://www.google.com/chrome/
开发环境
Git
Github Cli (gh)
1
2
3
4
5
6
7
8
| (type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y)) \
&& sudo mkdir -p -m 755 /etc/apt/keyrings \
&& out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
&& cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y
|
登陆 Github
GH 登陆、自动设置 github 的 ssh key
设置 https 凭据管理器
获取删库跑路权限
1
| gh auth refresh -h github.com -s delete_repo
|
常用 Git 设置
# ~/.gitconfig
[credential "https://github.com"]
helper =
helper = !/usr/bin/gh auth git-credential
[credential "https://gist.github.com"]
helper =
helper = !/usr/bin/gh auth git-credential
[user]
name = lixx
email = [email protected]
signingkey = 114514CFM29803FUCM9102385NV73848VN3402CQ
[commit]
gpgsign = true
[tag]
gpgsign = true
[core]
safecrlf = warn
autocrlf = input
editor = subl -w
[init]
defaultBranch = main
[pull]
ff = only
[alias]
up = "!git checkout master;git fetch upstream master;git reset --hard upstream/master"
Python
Pyenv
python 版本管理器和虚拟环境管理器 pyenv
1
| curl -fsSL https://pyenv.run | bash
|
添加 fish 配置
1
2
3
4
5
6
| # ~/.config/fish/config.fish
set -Ux PYENV_ROOT $HOME/.pyenv
set -U fish_user_paths $PYENV_ROOT/bin $fish_user_paths
pyenv init - fish | source
status --is-interactive; and source (pyenv virtualenv-init -|psub)
|
准备构建环境
https://github.com/pyenv/pyenv/wiki#suggested-build-environment
1
2
3
| sudo apt update; sudo apt install build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev curl git \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
|
构建安装 Python
https://github.com/pyenv/pyenv/wiki#how-to-build-cpython-for-maximum-performance
1
2
| PY_VERSION=3.11.11
env PROFILE_TASK='-m test.regrtest --pgo -j0' PYTHON_CONFIGURE_OPTS='--enable-optimizations --with-lto' PYTHON_CFLAGS='-march=native -mtune=native' pyenv install "$PY_VERSION"
|
pip 换源
https://mirrors.tuna.tsinghua.edu.cn/help/pypi/
全局更换
1
| pip config set global.extra-index-url "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple"
|
临时使用
1
| pip install -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
|
pipx
命令行工具管理器
1
2
| sudo apt install pipx
pipx ensurepath
|
添加 completions
1
| register-python-argcomplete --shell fish pipx > ~/.config/fish/completions/pipx.fish
|
poetry
依赖管理器
1
| pipx install poetry -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
|
添加 completions
1
| poetry completions fish > ~/.config/fish/completions/poetry.fish
|
poetry 换源
项目设置
1
2
| poetry source add --priority=primary mirrors https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/
poetry source add --priority=supplemental mirrors https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/
|
Node
fnm
安装 fnm
1
| curl -fsSL https://fnm.vercel.app/install | bash
|
添加 completions
1
| fnm completions --shell fish > "$HOME/.config/fish/completions/fnm.fish"
|
使用 fnm 安装 lts 版本 node
添加 shell 配置
fish
1
2
| # ~/.config/fish/config.fish
fnm env --use-on-cd --shell fish | source
|
zsh
1
2
| # ~/.zshrc
eval "$(fnm env --use-on-cd --shell zsh)"
|
pnpm
1
| wget -qO- https://get.pnpm.io/install.sh | sh -
|
添加 completions
1
| pnpm completion fish > ~/.config/fish/completions/pnpm.fish
|
切换淘宝源
全局设置
pnpm config set --global registry https://registry.npmmirror.com
或者
nrm use taobao
常用 npm 包
1
2
3
4
| pnpm add -g nrm
pnpm add -g serve
pnpm add -g http-server
pnpm add -g surge
|
常用 npmrc 配置
# ~/.npmrc
init-author-name=lixx
init-author-url=https://lixx.org/
init-version=0.0.0
init-license=MPL-2.0
strict-ssl=true
git-tag-version=true
message=release: %s
sign-git-commit=true
sign-git-tag=true
home=https://npmmirror.com
registry=https://registry.npmmirror.com/
JetBrains 系列软件
通过 “JetBrains ToolBox” 下载 JetBrains 系列软件
https://www.jetbrains.com/toolbox-app/
这玩意会自动在 /home/<username>/.local/share/JetBrains/Toolbox/
下蛋,不必手动安装到 bin/