其他配置文件
本节 System V 和 systemd 版本配置方法一致。
5.5.1 创建/etc/inputrc 文件
inputrc 文件的作用是告知系统应该以怎样的键盘布局处理键盘。此文件对于 readline —— 输入相关库,或者是一些 shell(例如 bash 等)来说十分重要。
对于大部分用户来说,都不使用那些奇奇怪怪的键盘映射,所以,可以通过以下的命令建立一个全局的/etc/inputrc 以供所有用户使用。如果需要更改某一个用户的键盘映射,仅需要在那个用户的 HOME 目录下建立一个.inputrc 文件,然后修改对应的键盘映射就可以了。
如果需要了解更多有关如何编辑 inputrc 文件的信息,可以查看 info bash 中 Readline Init File 小节的内容。其实查看 info readline 也可以获取到不少有用的信息。
下面显示的就是通用的 inputrc 文件,其中包含有“#”的都是注释行。需要注意的是,此文件不支持在设置后跟随注释。使用以下命令创建此文件:
cat > /etc/inputrc << "EOF"
# Begin /etc/inputrc
# Modified by Chris Lynn <roryo@roryo.dynup.net>
# Allow the command prompt to wrap to the next line
set horizontal-scroll-mode Off
# Enable 8bit input
set meta-flag On
set input-meta On
# Turns off 8th bit stripping
set convert-meta Off
# Keep the 8th bit for display
set output-meta On
# none, visible or audible
set bell-style none
# All of the following map the escape sequence of the value
# contained in the 1st argument to the readline specific functions
"\eOd": backward-word
"\eOc": forward-word
# for linux console
"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": beginning-of-history
"\e[6~": end-of-history
"\e[3~": delete-char
"\e[2~": quoted-insert
# for xterm
"\eOH": beginning-of-line
"\eOF": end-of-line
# for Konsole
"\e[H": beginning-of-line
"\e[F": end-of-line
# End /etc/inputrc
EOF
5.5.2 创建/etc/shells 文件
shells 文件是当前系统所有可用 shell 的列表文件。应用程序通过读取它,可以知道需要使用的 shell 是否有效。每行指定一个 shell 的绝对路径,即从根目录(/)开始的路径。例如,当非特权用户想要使用 chsh 命令更改自己登录所用的 shell 时。如果命令没有在/etc/shell 中找到,那么将会拒绝更改。
这个文件对于某些程序来说是必需的,比如 GDM 在找不到/etc/shells 时就不会启用头像登录界面(Face Browse),还有 FTP 守护进程通常会禁止使用不在这个文件里列出终端的用户登录。
cat > /etc/shells << "EOF"
# Begin /etc/shells
/bin/sh
/bin/bash
# End /etc/shells
EOF