学习Linux的一些笔记,持续更新
1. 中文配置
以Debian/Ubuntu系统为例,中文语言及其环境配置(命令行)。
首先要更新一下系统和软件列表
sudo apt update
sudo apt upgrade -y
删除用不到的软件和数据包
sudo apt autoremove -y
安装locales
这个软件包,用于配置语言
sudo apt install locales -y
执行下列命令配置语言环境:
sudo dpkg-reconfigure locales
配置界面如下:
按上下键移动光标,找到zh_CN.UTF-8 UTF-8
这个选项,按下空格即可选择,前面带星号(*
)即被选中,选中后按Tab
键移动光标到,按Enter
键确定。跳转到另一个界面默认语言设置:
这里继续选中zh_CN.UTF-8
,然后确定。
(可选)选择好后自动加载中文环境:但是注意可能没有对应的字库,我们需要手动下载中文字库:
apt --fix-broken install xfonts-intl-chinese xfonts-wqy -fy
apt install ttf-wqy-zenhei -y //这个是用来修复谷歌浏览器中文乱码问题
然后注销重新登录,或者重连服务器,语言配置就生效了。
查看已安装的语言环境:
locale -a
查看当前系统语言环境变量配置:
locale
2. 新建用户和删除用户
注意:要创建用户,当前用户必须是 root 用户或者 sudo 用户
创建用户(命令后面的test为你要创建的用户名)
sudo adduser test
输入这条命令后会提示要你为这个用户设置密码,密码输入两次,之后的用户信息按Enter
键默认就行
将新用户成为 sudo 用户
创建test用户后,可以使用 -aG 组合选项将其添加到 sudo 组,就可以将其转为 sudo 用户。使用 -a 选项是为了确保向组中“追加”。
sudo usermod -aG sudo test
验证 sudo 权限
使用下面命令验证test用户是否被赋予sudo权限,在命令输出中,末尾你会看到是否可以 sudo 权限运行所有命令:(ALL : ALL) ALL
sudo -l -U test
删除用户
删除test用户同时删除test用户的主目录
sudo deluser --remove-home test
3. Debian12换国内阿里云源(不适合Debian11和之前的)
修改文件:/etc/apt/sources.list 可以使用nano工具修改
阿里云服务器:
deb http://mirrors.cloud.aliyuncs.com/debian/ bookworm main non-free non-free-firmware contrib
deb http://mirrors.cloud.aliyuncs.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb http://mirrors.cloud.aliyuncs.com/debian/ bookworm-proposed-updates main non-free non-free-firmware contrib
deb http://mirrors.cloud.aliyuncs.com/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src http://mirrors.cloud.aliyuncs.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src http://mirrors.cloud.aliyuncs.com/debian/ bookworm main non-free non-free-firmware contrib
deb-src http://mirrors.cloud.aliyuncs.com/debian/ bookworm-proposed-updates main non-free non-free-firmware contrib
deb-src http://mirrors.cloud.aliyuncs.com/debian/ bookworm-backports main non-free non-free-firmware contrib
deb http://mirrors.cloud.aliyuncs.com/debian-security/ bookworm-security main non-free non-free-firmware contrib
deb-src http://mirrors.cloud.aliyuncs.com/debian-security/ bookworm-security main non-free non-free-firmware contrib
非阿里云服务器:
deb https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib
deb https://mirrors.aliyun.com/debian-security/ bookworm-security main
deb-src https://mirrors.aliyun.com/debian-security/ bookworm-security main
deb https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib
4. 从 Debian 11 升级到 Debian 12
https://linux.cn/article-15902-1.html
5. Debian 升级内核Debian 升级内核
检查是否有内核源:/etc/apt/sources.list
deb http://mirrors.cloud.aliyuncs.com/debian/ bookworm-backports main non-free non-free-firmware contrib
或
deb https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib
安装新内核
apt -t bookworm-backports install linux-image-amd64
apt -t bookworm-backports install linux-headers-amd64
update-grub
然后 重启 并查看内核是否已经更新
reboot
uname -r
截止目前 Debian 的最新内核是:6.1.0-10-amd64
,返回形如此的内容及更新成功。
卸载旧内核
dpkg --list | grep linux-image
输出格式
在确保剩余至少一个最新内核下,删除旧内核:
apt purge linux-image-4.19.0-11-amd64
注意:卸载了旧内核后一定要确保剩余至少一个最新内核