1. 修改主机名
hostnamectl set-hostname 新的主机名
或者直接 vi /etc/hosts
, 将 127.0.1.1 旧主机名, 改为 127.0.1.1 新主机名,如果完全是自己装的系统,可以在装机步骤就填好了主机名信息,省略次步骤。
127.0.0.1 localhost127.0.1.1 epyc.yourdomain.com epyc
2. 更改镜像源(国外服务器省略这一步)
cat << EOF > /etc/apt/sources.listdeb http://mirrors.tuna.tsinghua.edu.cn/debian bookworm main contrib non-freedeb-src http://mirrors.tuna.tsinghua.edu.cn/debian bookworm main contrib non-free
deb http://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmwaredeb-src http://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
deb http://mirrors.tuna.tsinghua.edu.cn/debian bookworm-updates main contrib non-freedeb-src http://mirrors.tuna.tsinghua.edu.cn/debian bookworm-updates main contrib non-freeEOF
然后执行 apt update
和 apt upgrade
。
3. 配置 ssh
添加 ssh public keys 到 /root/.ssh/authorized_keys
。
PubkeyAuthentication yesPermitRootLogin prohibit-password
重启 systemctl reload sshd
。
4. 安装 zsh & oh-my-zsh
apt updateapt install -y zsh wget curl git vim fzf screen tmux coreutils findutils tar gzip bzip2 xz-utils iproute2 net-tools openssh-client traceroute gnupg2 util-linux parted dosfstools e2fsprogs rsyslog strace zip unzip p7zip-full less cron at ntpdate sudo dnsutils btop vnstat dufchsh -s $(which zsh)yes | sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
5. 配置 .zshrc
cat << 'EOF' > .zshrc# export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:$PATH
export ZSH="$HOME/.oh-my-zsh"# See https://github.com/ohmyzsh/ohmyzsh/wiki/ThemesZSH_THEME="aussiegeek"DISABLE_UPDATE_PROMPT=trueplugins=(git z zsh-autosuggestions fzf)source $ZSH/oh-my-zsh.sh
export LANG=en_US.UTF-8export LANGUAGE="en_US"export LC_ALL=en_US.UTF-8export LS_OPTIONS='--color=auto'alias vi="vim"### Fix slowness of pastes with zsh-syntax-highlighting.zshpasteinit() { OLD_SELF_INSERT=${${(s.:.)widgets[self-insert]}[2,3]} zle -N self-insert url-quote-magic # I wonder if you'd need `.url-quote-magic`?}
pastefinish() { zle -N self-insert $OLD_SELF_INSERT}zstyle :bracketed-paste-magic paste-init pasteinitzstyle :bracketed-paste-magic paste-finish pastefinish### Fix slowness of pastesEOFsource ~/.zshrc
6. 配置 .vimrc
cat << EOF > .vimrcset encoding=utf-8set fileencoding=utf-8set termencoding=utf-8set numberset cursorlineset autoindentset smartindentset tabstop=2set shiftwidth=2set expandtabset ignorecaseset smartcaseset hlsearchset incsearchsyntax onset background=darkcolorscheme elflordset timeoutlen=500set updatetime=300EOF
7. 配置 .screenrc & .tmux.conf
cat << EOF > .screenrcstartup_message offhardstatus alwayslastlinehardstatus string '%{= g}[%{W}%n:%t%{g}] [%{B}%c %{g}]'EOF
cat << EOF > .tmux.confunbind C-bset -g prefix C-abind C-a send-prefix
set-option -g status-bg colour9set-option -g status-fg colour46
bind-key -n M-Up select-pane -Ubind-key -n M-Down select-pane -Dbind-key -n M-Left select-pane -Lbind-key -n M-Right select-pane -R
bind-key -n M-0 select-window -t 0bind-key -n M-1 select-window -t 0bind-key -n M-2 select-window -t 1bind-key -n M-3 select-window -t 2
set -g mouse on
set -g status-left-length 30set -g status-right-length 30
set -g pane-border-style fg=brightblackset -g pane-active-border-style fg=brightgreen
bind -r < resize-pane -L 2bind -r > resize-pane -R 2bind -r + resize-pane -U 1bind -r - resize-pane -D 1
bind | split-window -hbind - split-window -vunbind '"'unbind %
setw -g mode-keys vibind -T copy-mode-vi v send-keys -X begin-selectionbind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xclip -selection clipboard -i"
set -g history-limit 10000EOF
8. 时区问题
使用 timedatectl
检查时区,修改成 Asia/Shanghai
:
$ timedatectl Local time: Sat 2024-12-28 20:24:18 EST Universal time: Sun 2024-12-29 01:24:18 UTC RTC time: Sun 2024-12-29 01:24:17 Time zone: US/Eastern (EST, -0500)System clock synchronized: no NTP service: n/a RTC in local TZ: no
$ timedatectl set-timezone Asia/Shanghai
$ ls -l /etc/localtimelrwxrwxrwx 1 root root 35 Dec 29 09:24 /etc/localtime -> ../usr/share/zoneinfo/Asia/Shanghai
$ cat /etc/timezoneUS/Eastern$ vi /etc/timezone # 修改为 Asia/Shanghai$ dpkg-reconfigure -f noninteractive tzdata
Current default time zone: 'Asia/Shanghai'Local time is now: Sun Dec 29 09:26:23 CST 2024.Universal Time is now: Sun Dec 29 01:26:23 UTC 2024.
安装 ntp 等工具:
apt install chrony -ysystemctl enable chrony.servicesystemctl start chrony.servicesystemctl status chrony.servicechronyc tracking
然后再用 timedatectl status
检查:
$ timedatectl status Local time: Wed 2025-01-01 22:01:28 CST Universal time: Wed 2025-01-01 14:01:28 UTC RTC time: Wed 2025-01-01 14:01:28 Time zone: Asia/Shanghai (CST, +0800)System clock synchronized: yes NTP service: active RTC in local TZ: no
9 可能会出现的 locale 问题
使用 locale
检查 LANGUAGE=en_US
LANG=en_US.UTF-8
等。
$ localelocale: Cannot set LC_CTYPE to default locale: No such file or directorylocale: Cannot set LC_MESSAGES to default locale: No such file or directorylocale: Cannot set LC_ALL to default locale: No such file or directoryLANG=en_US.UTF-8LANGUAGE=en_USLC_CTYPE="en_US.UTF-8"LC_NUMERIC="en_US.UTF-8"LC_TIME="en_US.UTF-8"LC_COLLATE="en_US.UTF-8"LC_MONETARY="en_US.UTF-8"LC_MESSAGES="en_US.UTF-8"LC_PAPER="en_US.UTF-8"LC_NAME="en_US.UTF-8"LC_ADDRESS="en_US.UTF-8"LC_TELEPHONE="en_US.UTF-8"LC_MEASUREMENT="en_US.UTF-8"LC_IDENTIFICATION="en_US.UTF-8"LC_ALL=en_US.UTF-8
使用 cat /etc/locale.gen
检查 locale 配置文件,确保文件中包含以下行,并且没有被注释:
en_US.UTF-8 UTF-8
如果被注释掉了,则使用编辑器编辑取消它的注释。然后使用命令 locale-gen
生成缺失的 locale 数据。运行后,应该会看到类似以下输出:
Generating locales (this might take a while)... en_US.UTF-8... doneGeneration complete.
为了确保设置生效,重新运行配置工具 dpkg-reconfigure locales
,在弹出的界面中,选择 en_US.UTF-8 (用空格键选中),然后确认。