猫子早期都使用CentOS,官方不维护后改用Ubuntu,最近猫子有在使用Debian,发现一些常用命令与CentOS、Ubuntu有略微不同,有点不适应,以下是各问题的解决办法:
Debian 不支持ls
命令的解决办法
修改~/.bashrc文件,将以下两行前的井号去掉。
alias ll='ls $LS_OPTIONS -l'
alias l='ls $LS_OPTIONS -lA'
生效命令
source ~/.bashrc
这样就可以使用ll
和l
命令了。
区别:
l
命令显示目录下的隐藏文件,等价于ll -l
ll
命令不显示目录下的隐藏文件
Debian vim
命令不支持右键黏贴的解决办法
查看vim
版本
vim -v
根据版本号修改vim的配置文件,将 set mouse=a
改为set mouse-=a
vi /usr/share/vim/vim90/defaults.vim
if has('mouse')
if &term =~ 'xterm'
set mouse-=a
else
set mouse=nvi
endif
endif
保存退出后,再次用vim会发现右键可以粘贴。
Debian9 无法更新问题
Debian9源失效,需要替换一下地址
sed -i s/deb.debian.org/archive.debian.org/g /etc/apt/sources.list
sed -i s/deb.debian.org/archive.debian.org/g /etc/apt/sources.list.d/stretch-backports.list
sed -i 's|security.debian.org|archive.debian.org|g' /etc/apt/sources.list
sed -i '/stretch-updates/d' /etc/apt/sources.list
清华软件源
大部分 Debian 的软件源配置文件使用传统的 One-Line-Style,路径为 /etc/apt/sources.list
;但是对于容器镜像,从 Debian 12 开始,其软件源配置文件变更为 DEB822 格式,路径为 /etc/apt/sources.list.d/debian.sources
。一般情况下,将对应文件中 Debian 默认的源地址 http://deb.debian.org/
替换为镜像地址即可。
Debian Buster 以上版本默认支持 HTTPS 源。如果遇到无法拉取 HTTPS 源的情况,请先使用 HTTP 源并安装:
apt install apt-transport-https ca-certificates
传统格式(/etc/apt/sources.list
)
Debian 12 (bookworm)
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
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
DEB822 格式(/etc/apt/sources.list.d/debian.sources
)
Debian 12 (bookworm)
Types: deb
URIs: https://mirrors.tuna.tsinghua.edu.cn/debian
Suites: bookworm bookworm-updates bookworm-backports
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
Types: deb-src
URIs: https://mirrors.tuna.tsinghua.edu.cn/debian
Suites: bookworm bookworm-updates bookworm-backports
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
# 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换
Types: deb
URIs: https://mirrors.tuna.tsinghua.edu.cn/debian-security
Suites: bookworm-security
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
Types: deb-src
URIs: https://mirrors.tuna.tsinghua.edu.cn/debian-security
Suites: bookworm-security
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
为了方便快速配置,此处一并附上了 debian-security 的配置,一般来说,镜像站会同时提供 debian-security,为了更准确的信息您可以前往 Debian Security 帮助 确认。
不过,一般来说,为了更及时地获得安全更新,不推荐使用镜像站安全更新软件源,因为镜像站往往有同步延迟。参考 https://www.debian.org/security/faq.en.html#mirror
The purpose of security.debian.org is to make security updates available as quickly and easily as possible.
Encouraging the use of unofficial mirrors would add extra complexity that is usually not needed and that can cause frustration if these mirrors are not kept up to date.
评论