命令提示符组成
ubuntu默认提示符:root@DESKTOP:~#
注释:
- root: 当前登录用户
- DESKTOP:主机名
- ~: 当前目录名(即用户主目录)
- #:超级用户权限(root用户显示)
- $: 普通用户权限(非root用户显示)
可在终端打印默认提示符配置:
root@DESKTOP:~# echo $PS1
\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$
修改命令提示符
参数
命令提示符的配置文件在用户主目录下的.bashrc:
root@DESKTOP:~# vim ~/.bashrc
有关内容如下:
...
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
#xterm-color) color_prompt=yes;; #增加|*-256color可激活彩色显式
xterm-color|*-256color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be

本文介绍了Ubuntu命令提示符的组成及如何修改。默认提示符包括用户、主机名、目录和权限标识。通过修改`.bashrc`文件中的`PS1`变量,可以定制提示符的颜色、时间显示。例如,加入`d`参数可显示日期,使用`[e[F;Bm]`设置颜色。同时,通过调整`LC_TIME`变量,可以改变日期的显示语言。此外,还讲解了如何修改系统时区和时间,并确保硬件CMOS时间同步。
最低0.47元/天 解锁文章
1521

被折叠的 条评论
为什么被折叠?



