debian 12 初始化

启用root用户ssh远程登录

nano /etc/ssh/sshd_config,PermitRootLogin 修改为 yes:

#PermitRootLogin prohibit-password
PermitRootLogin yes

配置华为云软件源

nano /etc/apt/sources.list,注释掉原本内容,插入以下内容:

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

安装基础软件

apt-get update
apt-get install curl vim zip unzip iptables

配置 vi 允许复制

vi /usr/share/vim/vim90/defaults.vim,搜索 mouse,找到下面的代码段,修改 set mouse=a 为 set mouse=-a,即:

if has('mouse')
  if &term =~ 'xterm'
    set mouse=a
  else
    set mouse=nvi
  endif
endif

改为:

if has('mouse')
  if &term =~ 'xterm'
    set mouse-=a
  else
    set mouse=nvi
  endif
endif

保存退出即可

设置 LANG 全局环境变量,避免 vim 操作时中文乱码

echo 'export LANG=zh_CN.UTF-8' >> /etc/profile
export LANG=zh_CN.UTF-8

配置命令别名

vi /root/.bashrc,插入以下内容,需要立即生效就在终端上再执行一把:

alias ls='ls --color'
alias ll='ls -l'

安装 docker,docker-compose

# 下载安装 docker
curl -OL https://mirror.sjtu.edu.cn/docker-ce/linux/static/stable/x86_64/docker-27.3.1.tgz
tar -zxvf docker-27.3.1.tgz
chmod +x docker/*
mv docker/* /usr/local/bin
echo
dockerd --version

# 删除 docker 安装包
rm docker docker-27.3.1.tgz -rf

# 生成 daemon.json 配置文件
mkdir -p /etc/docker/
cat > /etc/docker/daemon.json << EOF
{
    "hosts":[
        "unix:///var/run/docker.sock"
    ],
    "bip":"192.168.222.1/24",
    "data-root":"/var/lib/docker",
    "registry-mirrors":[
    ],
    "insecure-registries":[
    ]
}
EOF

# 启动 dockerd
nohup dockerd > /var/log/dockerd.log 2>&1 &

# 安装 docker-compose
url=https://github.com/docker/compose/releases/download/v2.29.7/docker-compose-linux-x86_64
mkdir -p ~/.docker/cli-plugins
curl -L $url -o ~/.docker/cli-plugins/docker-compose
chmod +x ~/.docker/cli-plugins/docker-compose
docker compose version

配置 docker 开机自启动

vi /etc/init.d/startup.sh,插入以下内容:

#!/bin/bash
nohup dockerd > /var/log/dockerd.log 2>&1 &

授予可执行权限,新建软连接:

chmod +x /etc/init.d/startup.sh
ln -s /etc/init.d/startup.sh /etc/rc2.d/S99startup

参考连接

运维Debian安装教程 开启root远程登录:https://zhuanlan.zhihu.com/p/661391452

debian12 国内镜像源设置:https://blog.csdn.net/bali16/article/details/139642707

解决各种终端工具在linux中使用vim编辑内容无法复制的问题:https://blog.csdn.net/al_wa_ys/article/details/139233441

一键安装 docker 及 docker compose:https://www.cnblogs.com/nihaorz/p/17406068.html

debian 开机自启动脚本或命令:https://blog.csdn.net/m0_69873023/article/details/136491722

posted @ 2024-09-10 10:34  Nihaorz  阅读(62)  评论(0编辑  收藏  举报