【好玩的 Docker 项目】Debian 11 系统安装

Debian 系统安装(debian 11)

系统安装包下载

Debian 64 位 x86 完整安装镜像

Debian 64 位 arm 完整安装镜像

其他镜像:Debian 镜像

参考文献

如何安装 Debian 11 (Bullseye) 图文教程

Debian 11 “bullseye” 安装笔记

安装

  • 使用界面安装
  • 如果使用软 raid,在分区前先在硬盘上划出足够空间给 ESP,然后再分两个区设置为 raid 模式,再将两个 raid 分区组成 raid。
  • 软件包去除桌面环境,留下 ssh 和基本系统工具

安装必要包

sudo apt install git
sudo apt install net-tools

SSH 配置

开启 root 账号登录

# 修改 /etc/ssh/sshd_config
#   PermitRootLogin prohibit-password  #允许 root 登录,但禁止使用密码认证
#   可以配合使用 Pubkey 认证,默认 `PubkeyAuthentication yes`
# 增加一句
PermitRootLogin yes

# 重启服务生效
sudo systemctl restart ssh

时区配置

# 查看时区
date
# 设置时区
sudo timedatectl set-timezone Asia/Shanghai

locale 设置

安装 locales 包

sudo apt-get install locales

添加配置

dpkg-reconfigure locales

选择 en_US.UTF-8 UTF-8zh_CN.UTF-8 UTF-8

查看语言

locale

用户配置

查看用户信息

id <username>

添加 sudo

# 安装 sudo
apt install sudo
# 将用户添加到 sudo 组
usermod -a -G sudo <username>

配置 /etc/sudoers

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

创建管理员账号

useradd -m -s /bin/zsh -G sudo <username>

删除用户

sudo userdel --remove-home <username>

Zsh 配置

sudo apt install zsh

设置默认 shell

# 查看当前shell
echo $SHELL

# 为 root 设置默认 shell
# sudo chsh -s /bin/zsh root
sudo chsh -s /usr/bin/zsh

# 为特定用户设置默认 shell
# sudo chsh -s /usr/bin/zsh <username>
sudo chsh -s /bin/zsh pandoranext

# 或者修改 /etc/passwd
# /bin/bash 改为 /bin/zsh

下载 oh-my-zsh

这边是配置全局 oh-my-zsh

# 使用 root 用户
# 下载本体
git clone https://github.com/ohmyzsh/ohmyzsh.git /etc/oh-my-zsh

# 下载主题(非必要,可忽略)
git clone https://github.com/spaceship-prompt/spaceship-prompt.git /etc/oh-my-zsh/custom/themes/spaceship-prompt --depth=1
ln -s /etc/oh-my-zsh/custom/themes/spaceship-prompt/spaceship.zsh-theme /etc/oh-my-zsh/custom/themes/spaceship.zsh-theme

# 下载插件(非必要,可忽略)
git clone https://github.com/zsh-users/zsh-autosuggestions.git /etc/oh-my-zsh/custom/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git /etc/oh-my-zsh/custom/plugins/zsh-syntax-highlighting

配置 oh-my-zsh

# 从模板文件复制 .zshrc 创建默认配置文件(新用户将使用该配置文件)
cp /etc/oh-my-zsh/templates/zshrc.zsh-template /etc/skel/.zshrc
# 修改 on-my-zsh 的安装目录 export ZSH=$HOME/.oh-my-zsh 为 export ZSH=/etc/oh-my-zsh
sed -i 's|$HOME/.oh-my-zsh|/etc/oh-my-zsh|g' /etc/skel/.zshrc

# 更改默认主题(非必要,可忽略)
sed -i '/^ZSH_THEME=.*/c ZSH_THEME="spaceship"' /etc/skel/.zshrc

# 取消每周自动检查更新(非必要,可忽略)
sed -i 's/^#[ ]\(DISABLE_AUTO_UPDATE="true"\)/\1/' /etc/skel/.zshrc

# 创建新用户配置文件上述变量定义的缓存目录
mkdir -p /etc/skel/.oh-my-zsh/cache

# 修改加载的插件(非必要,可忽略):
sed -i '/^plugins=.*/c plugins=(git zsh-autosuggestions zsh-syntax-highlighting)' /etc/skel/.zshrc

# 修改 PATH 变量(非必要,可忽略)
echo "" >> /etc/skel/.zshrc
echo "# PATH" >> /etc/skel/.zshrc
echo "export PATH=/usr/local/sbin:/usr/sbin:/sbin:$PATH" >> /etc/skel/.zshrc

# 修改语言(非必要,可忽略)
echo "" >> /etc/skel/.zshrc
echo "# locale" >> /etc/skel/.zshrc
echo 'LANG=zh_CN.UTF-8' >> /etc/skel/.zshrc
echo 'LANGUAGE=zh_CN.UTF-8' >> /etc/skel/.zshrc
echo 'LC_ALL=zh_CN.UTF-8' >> /etc/skel/.zshrc

# 新增用户单独配置 zsh cache 目录
echo "" >> /etc/skel/.zshrc
echo "# cache" >> /etc/skel/.zshrc
echo "export ZSH_CACHE_DIR=~/.oh-my-zsh/cache" >> /etc/skel/.zshrc

# 配置ll别名(非必要,可忽略)
echo "" >> /etc/skel/.zshrc
echo "# alias" >> /etc/skel/.zshrc
echo 'alias ll="ls -lahF --color --time-style=long-iso"' >> /etc/skel/.zshrc

# 老用户
cp /etc/skel/.zshrc ~/.zshrc
mkdir -p ~/.oh-my-zsh/cache
source ~/.zshrc

# 新增用户
useradd -m -s /bin/zsh -G sudo ${username}
# 设置新用户密码
passwd ${username}

Vim 编辑器配置

# 删除系统自带 vim-tiny
apt autoremove vim-tiny
# 安装 vim
apt install vim
# 修改默认编辑器
select-editor
# 修改 vim 配置
vi ~/.vimrc
# 修改完成保存
:wq

配置样例

" 编码设置释义
" vim 内部使用的字符编码方式
"set encoding=编码
"set enc=编码
" vim 当前编辑的文件的字符编码方式,保存文件时也使用
"set fileencoding=编码
"set fenc=编码
" vim 打开的文件的字符编码方式,按顺序,最前面的优先
"fileencodings 是一个用逗号分隔的列表,简写 fencs
"set fileencodings=编码
" vim 所工作的终端的字符编码方式
"set termencoding=编码

" 编码设置
set encoding=utf-8
set fileencoding=utf-8
set fencs=utf-8,gb18030,gbk,cp936,gb2312,big5
set termencoding=utf-8

" 语言设置
set langmenu=zh_CN.UTF-8
set helplang=cn

" 去掉 vi 的一致性
set nocompatible

" 显示行号
set number

" 开启语法高亮
syntax on

" 设置字体
"set guifont=Monaco:h13
" solarized 主题设置在终端下的设置
"let g:solarized_termcolors=256

" 设置不自动换行
set nowrap

" 设置以 unix 的格式保存文件(UNIX 系统下默认)
set fileformat=unix

" 自动缩进
set autoindent
set cindent

" Tab 键的宽度 = 4 个空格
set tabstop=4
" 统一缩进为 4
set softtabstop=4
set shiftwidth=4
" expandtab:缩进用空格来表示,noexpandtab:用制表符表示一个缩进
set expandtab

" 高亮显示匹配的括号
set showmatch
" 匹配括号高亮的时间(单位是十分之一秒)
set matchtime=5

" 光标移动到 buffer 的顶部和底部时保持 3 行距离
set scrolloff=3

" 启动显示状态行 (1), 总是显示状态行 (2)
set laststatus=2

" 使退格键(backspace)正常处理 indent, eol, start 等
set backspace=2
" 允许 backspace 和光标键跨越行边界
"set whichwrap+=<,>,h,l

" 可以在 buffer 的任何地方使用鼠标(类似 office 中在工作区双击鼠标定位)
set mouse=a
set selection=exclusive
set selectmode=mouse,key

" 搜索忽略大小写
set ignorecase
" 高亮显示匹配字符(回车后)
set hlsearch
" 搜索实时高亮显示所有匹配的字符
set incsearch

" 设置当文件被改动时自动载入
"set autoread

" 突出显示当前行
set cursorline

" 打开标尺,在屏幕右下角显示当前光标所处位置(设置了 statusline 可以忽略)
set ruler
" 状态行显示的内容
"set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ENC=%{&encoding}]\ [POS=%l,%v][%p%%]\ %{strftime(\"%Y.%m.%d\ -\ %H:%M\")}
set statusline=\ %<%F[%1*%M%*%n%R%H]%=\ %y\ %0(%{&fileformat}\ %{&encoding}\ %l,%c%)\ %p%%

" 显示 Tab 键和行尾空格
set list
"set listchars=tab:→■,trail:■
"set listchars=tab:→▫,trail:□
set listchars=tab:→·,trail:□

Docker 环境搭建

参考 (【好玩的 Docker 项目】Debian 11 搭建 Docker 环境)

5 个赞

不错

提供个dd脚本原文地址

wget --no-check-certificate -qO InstallNET.sh 'https://raw.githubusercontent.com/leitbogioro/Tools/master/Linux_reinstall/InstallNET.sh' && chmod a+x InstallNET.sh && bash InstallNET.sh -debian 11 -pwd '密码'

谢谢分享 :kissing_heart: :smiling_face_with_three_hearts:

24 个赞

插个眼