外观
Debian安装
官网下载包安装即可
如果是虚拟机安装,最好断网安装,否则下载很慢 netinst网络安装
1.设置网络
# 先用ip a 看网卡名称
# 使用dhcp方式
auto ens33
iface ens33 inet dhcp
# 静态
auto ens33
iface ens33 inet static
address 192.168.242.25
netmask 255.255.255.0
gateway 192.168.242.2
nameserver 223.5.5.5
nameserver 8.8.8.8
# 重启命令
systemctl restart networkingapt install net-tools
换源
在安装时 有什么奇怪的报错 一般就是源的问题 换源要注意系统的版本号,需要与源标记的版本号对应 注意注释掉第一句检查磁盘的源 使用
lsb_release -b或cat /etc/debian_version查看版本号
# /etc/apt/sources.list
deb http://mirrors.163.com/debian/ buster main contrib non-free
deb-src http://mirrors.163.com/debian/ buster main contrib non-free
apt updatecat > /etc/apt/sources.list << EOF
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
EOF开启 root 远程登录,修改端口
$ cat /etc/ssh/sshd_config # 编辑
PermitRootLogin without-password => PermitRootLogin yes # 改值
Port 2222
/etc/init.d/ssh restart # 重启
# 使用root登录改变登录提醒信息
vi/etc/motd
设置语言编码
export LANG=zh_CN.UTF-8
export LC_ALL=zh_CN.UTF-8
source ~/.bashrc #重启生效ssh日志
# ssh登录日志
journalctl -u ssh
sudo journalctl -u ssh --since "1 hour ago"
# 最近的ssh登录尝试
journalctl -u sshd --since "1 day ago"安装docker
apt install curl vim wget gnupg dpkg apt-transport-https lsb-release ca-certificates
curl -sSL https://download.docker.com/linux/debian/gpg | gpg --dearmor > /usr/share/keyrings/docker-ce.gpg
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh新增用户
adduser dailybacker
root@moss:~# mkdir /backup
root@moss:~# chown dailybacker /backup
root@moss:~# chmod 700 /backup/unrar包
apt install unrar #安装
unrar x 文件名.rar #解压
# 会创建文件夹,无法做到解压到对应目录下
find . -name "*.rar" -execdir unrar x -ad -e {} \; #解压到对应文件夹的当前目录
# 等价于 ↓ ↓ ↓ ↓ ↓ ↓ ↓
#递归遍历目录下的所有 .rar 文件,并解压到对应的文件夹下
find . -type f -name "*.rar" -exec sh -c '
#获取当前RAR文件的路径和文件名
file="$0"
path="$(dirname "$file")"
filename="$(basename "$file")"
# 创建与RAR文件同名的文件夹
folder="${filename%.*}"
mkdir -p "$path/$folder"
# 使用 unrar 命令解压当前找到的 RAR 文件到对应的文件夹中
unrar x "$file" "$path/$folder"
' {} \;
#递归遍历目录下的所有 .rar 文件,并解压到对应的当前文件夹(不创建文件,类似解压到当前文件夹)
find . -type f -name "*.rar" -exec sh -c '
#获取当前RAR文件的路径和文件名
file="$0"
path="$(dirname "$file")"
filename="$(basename "$file")"
# 创建与RAR文件同名的文件夹
folder="${filename%.*}"
mkdir -p "$path"
# 使用 unrar 命令解压当前找到的 RAR 文件到对应的文件夹中
unrar x "$file" "$path"
' {} \;7z包
容易出问题,不支持一些格式 解压的文件无大小。不稳定
apt install p7zip-full
find . -name "*.rar" -execdir 7z x -o. {} \; #递归解压到当前文件夹
find . -name "*.rar" -type f -exec rm -f {} \; #递归删除所有rar文件