记录个人 Debian 服务器的配置过程。
apt debian | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror
编辑配置文件:
1 2 sudo - root vi /etc/apt/sources.list
替换为:
1 2 3 4 5 6 7 8 9 10 11 deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
安装常用工具:
1 2 apt update apt install vim git wget curl
deb 包安装与卸载:
1 2 3 sudo dpkg -i hello.deb sudo dpkg -l | grep "hello" sudo dpkg -r hello
sudo 安装:
1 2 su - root apt install sudo
配置:
1 usermod -aG sudo username
或者使用 visudo
命令或者编辑 /etc/sudoers
文件,文中添加 username ALL=(ALL) ALL
,保存文件后注销重新登录。
docker docker-ce | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror
卸载:
1 for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do apt-get remove $pkg ; done
信任公钥并添加仓库:
1 2 3 4 5 6 7 install -m 0755 -d /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg sudo chmod a+r /etc/apt/keyrings/docker.gpg echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/debian \ " $(. /etc/os-release && echo "$VERSION_CODENAME " )" stable" | \ tee /etc/apt/sources.list.d/docker.list > /dev/null
安装:
1 2 sudo apt update sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
编辑配置文件:
1 sudo vim /etc/docker/daemon.json
增加代理加速地址:
1 2 3 4 5 6 7 { "registry-mirrors" : [ "https://docker.1panel.live" , "https://docker.ketches.cn" , "https://hub.iyuu.cn" ] }
服务启动:
1 sudo systemctl restart docker
常用命令:
1 2 3 4 5 6 7 sudo vim docker-compose.yml sudo docker compose up -d sudo docker compose down sudo docker exec -it [contianer_name] /bin/bash sudo docker images sudo docker image remove xxx:xxx sudo docker container ps
ip 固定 编辑配置文件:
1 sudo vim /etc/network/interfaces
增加内容:
1 2 3 4 5 6 7 auto enp0s3 iface enp0s3 inet static address 192.168.1.240/24 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.1 dns-nameservers 223.5.5.5
服务启动:
1 sudo systemctl restart networking.service
常用命令:
smb 安装:
1 2 sudo apt update sudo apt install samba
配置:
1 2 mkdir share sudo vim /etc/samba/smb.conf
末尾增加:
1 2 3 4 5 6 [SHARE] comment = My Share Folder path = /home/username/share writable = yes browseable = no guest ok = no
服务启动:
1 sudo systemctl restart smbd.service
crontab Debian 12 已经默认安装了 cron
安装:
1 2 sudo apt update sudo apt install cron
常用命令:
1 2 3 4 5 6 7 crontab –e //修改 crontab 文件,如果文件不存在会自动创建 crontab –l //显示 crontab 文件 crontab -r //删除 crontab 文件 crontab -ir //删除 crontab 文件前提醒用户 crontab [-u username] -e
编写服务 创建配置文件:
1 sudo vim /etc/systemd/system/frpc.service
添加内容:
1 2 3 4 5 6 7 8 9 10 [Unit] Description=Frpc Service After=network.target [Service] ExecStart=/home/username/frpc -c ./frpc.toml Restart=on-failure [Install] WantedBy=default.target
服务启动:
1 2 sudo systemctl daemon-reload sudo systemctl enable frpc.service