1. 背景
最近又开了一个Ubuntu的云主机,需要在上面安装一些常用软件。想到以后还要经常重装Ubuntu系统,每次都重复地安装相同的软件环境,太枯燥了。于是决定趁着这次机会,把常用基础软件的安装写成脚本,一劳永逸。
需要安装的基础软件主要有以下若干:
- zsh
- tmux
- nvim
- ubuntu远程桌面环境
rustdesk
- TimeShift(教程):软件快照备份及恢复。
- Elastic Stack(过往博文专门涉及此项,参见·待定·)
rustdesk可以使用tcp、udp、rdp等协议进行远程桌面连接,其中rdp是最为高效的。但是,一般来说,rustdesk需要服务器进行中转。显然,这些中转服务器会带来一定的延迟。
另一方面,微软Windows系统自带的remote desktop(远程桌面)可以直接进行点对点的rdp协议连接,所以从道理上讲,remote desktop会比rustdesk更快一些。
也正是基于上述考虑,我放弃了安装rustdesk远程桌面,改为直接用基于rdp协议的远程桌面软件。
安装软件后,有一些例行公事的常用配置,现在做成备忘录清单:
- 修改系统root密码
- 开启防火墙ufw,以及相应端口
- 配置ssh
2. zsh的装配
- 安装zsh
- 安装oh-my-zsh
- 将本地配置上传云主机
1 2 3 4 5 6 7
| # 安装软件 sudo apt install zsh --install-suggests # 安装oh-my-zsh,该脚本会自动将默认shell改为zsh(之后重启系统即可) sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" # 将本地配置上传云主机 rsync -avz --delete ~/.oh-my-zsh [email protected]:~/ rsync -avz --delete ~/.zshrc [email protected]:~/
|
3. tmux的装配
为tmux建立配置文件~/.tmux.conf
,配置内容如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| set-window-option -g xterm-keys on
source ~/.vim/colors/tmuxconf.tomorrow20200427
unbind c-b set -g prefix M-w
# copy-mode 将快捷键设置为vi 模式 set-window-option -g mode-keys vi
# suggestions from nvim:CheckHealth set-option -sg escape-time 10 set-option -g default-terminal "screen-256color" # enable the colors of nvim with tmux
# increase the history limit of tmux # https://stackoverflow.com/questions/18760281/how-to-increase-scrollback-buffer-size-in-tmux set-option -g history-limit 50000
# 让鼠标的滚轮可以用 setw -g mouse on
|
上述配置文件中,source ~/.vim/colors/tmuxconf.tomorrow20200427
是对tmux进行美化的配置文件,可以在~/.vim/colors/tmuxconf.tomorrow20200427
中写入下述tmux美化配置:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| # This tmux statusbar config was created by tmuxline.vim # on Mon, 27 Apr 2020
set -g status-justify "left" set -g status "on" set -g status-left-style "none" set -g message-command-style "fg=colour231,bg=colour235" set -g status-right-style "none" set -g pane-active-border-style "fg=colour231" set -g status-style "none,bg=colour237" set -g message-style "fg=colour231,bg=colour235" set -g pane-border-style "fg=colour235" set -g status-right-length "100" set -g status-left-length "100" setw -g window-status-activity-style "none" setw -g window-status-separator "" setw -g window-status-style "none,fg=colour231,bg=colour237" set -g status-left "#[fg=colour235,bg=colour231,bold] #S #[fg=colour231,bg=colour237,nobold,nounderscore,noitalics]" set -g status-right "#[fg=colour235,bg=colour237,nobold,nounderscore,noitalics]#[fg=colour231,bg=colour235] %Y-%m-%d %H:%M #[fg=colour231,bg=colour235,nobold,nounderscore,noitalics]#[fg=colour235,bg=colour231] #h " setw -g window-status-format "#[fg=colour231,bg=colour237] #I #[fg=colour231,bg=colour237] #W " setw -g window-status-current-format "#[fg=colour237,bg=colour235,nobold,nounderscore,noitalics]#[fg=colour231,bg=colour235] #I #[fg=colour231,bg=colour235] #W #[fg=colour235,bg=colour237,nobold,nounderscore,noitalics]"
|
4. nvim的装配
依次参见以下两篇我的博文:
- 进化 neovim 到 lin.nvim 风味
- (lin.) nvim 启用 Copilot 补全
- lin.nvim 中安装其它插件
由于我已经在本机配置好所有内容了,所以我可以直接把本地配置传到远端:
1 2 3 4 5 6 7 8
| # 安装最新版nvim sudo add-apt-repository ppa:neovim-ppa/unstable sudo apt update sudo apt install neovim -y # 一键安装lin.nvim git clone https://github.com/linrongbin16/lin.nvim ~/.nvim && cd ~/.nvim && ./install.sh # 上传本地lin.nvim的配置 rsync -avz --delete ~/.nvim [email protected]:~/
|
5. 远程桌面环境
参见文章如何在 Ubuntu 22.04 LTS 上安装 Xrdp
安装原装的gnome桌面:sudo apt install vanilla-gnome-desktop --install-suggests
。
安装xrdp,并启动服务:
1 2 3 4
| sudo apt install xrdp sudo systemctl enable xrdp sudo systemctl start xrdp sudo systemctl status xrdp
|
配置xrdp的文件权限、及其防火墙:
1 2
| sudo adduser xrdp ssl-cert sudo ufw allow 3389
|
注意:即使在ufw中开启了3389端口,我们还应该在腾讯云的“防火墙”中,明确的允许“Windows远程桌面”的规则(这是第一道大门)。
重启电脑。然后就可以用window系统自带的remote deskto实现远程访问了。
6. TimShift的装配
脚本代码如下:
1 2 3
| sudo add-apt-repository ppa:teejee2008/timeshift sudo apt update sudo apt install timeshift
|
7. Elastic Stack
这个还是有点复杂的,“一键脚本”不方便,还是直接参考我自己的另一篇文章吧:安装 ElasticStack 全套件(2. 实验)