最近,我在使用Ubuntu 26.04的环境,经常使用命令行的方式操作一些不常用的系统自带软件例如,mkdir、lsblk、df等等,现在就有一个问题,Ubuntu 26.04自带的man手册是英文的看起来不方便,有没有更好的呢?例如中文man手册。
我问了一下AI,并操作了一下,发现的确可行,现在记录下来。
第一步:
安装中文 man 手册
bash
sudo apt update
sudo apt install manpages-zh
第二步:
推荐用法:保留英文 man,新增 cman
bash
nano ~/.bashrc
在默认新增:
bash
alias cman='man -M /usr/share/man/zh_CN'
第三步:生效配置:
bash
source ~/.bashrc
之后:
bash
cman ls
cman fdisk
不过值得注意的是cman手册的内容不全,并不是所有命令的中文man手册解释都有的。
如果想让 man 默认显示中文(我尝试了一下,可行)
可以在 ~/.bashrc 里加:
bash
export LANG=zh_CN.UTF-8
然后,使配置生效:
bash
source ~/.bashrc
引伸:
man手册内容比较多,有一种比较简查询命令"cheat"便的,具体安装方式如下:需要用到snap命令。这也是为什么查询apt-get 以及dpkg命令无法找到原因。
bash
apt list --installed
# 或者
apt-mark showmannul
# 或者
dpkg -l
安装方式:
bash
snap install cheat
使用方式:
bash
cheat ls
# 显示如下:
# To display everything in <dir>, excluding hidden files:
ls <dir>
# To display everything in <dir>, including hidden files:
ls -a <dir>
# To display all files, along with the size (with unit suffixes) and timestamp:
ls -lh <dir>
# To display files, sorted by size:
ls -S <dir>
# To display directories only:
ls -d */ <dir>
# To display directories only, include hidden:
ls -d .*/ */ <dir>
# To display all files sorted by changed date, most recent first:
ls -ltc
# To display files sorted by create time:
ls -lt
# To display files in a single column:
ls -1
# To show ACLs (MacOS):
# see also `cheat chmod` for `/bin/chmod` options for ACLs
/bin/ls -le
# To show all the subtree files (Recursive Mode):
ls -R