加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

shell 提示符

发布时间:2020-12-15 20:54:01 所属栏目:安全 来源:网络整理
导读:? [email?protected]:~$ echo ${PS1}[e] 0 ;[email?protected]h: w a]${debian_chroot:+($debian_chroot)}[ 033 [ 01 ;32m][email?protected]h[ 033 [00m]:[ 033 [ 01 ;34m] w [ 033 [00m]$ ? ? The default? $PS1 ?in Ubuntu consi

?

[email?protected]:~$ echo ${PS1}
[e]0;[email?protected]h: wa]${debian_chroot:+($debian_chroot)}[033[01;32m][email?protected]h[033[00m]:[033[01;34m]w[033[00m]$

?

?

The default?$PS1?in Ubuntu consists of three parts:

  • [e]0;[email?protected]h: wa]

    This is an escape sequence which will set the terminal title text to?[email?protected]$HOST: $PWD.

    [?and?]?indicate the beginning and end of a sequence of non-printing characters.

    e?is an ASCII escape character.

    ]0;?is the specific escape sequence to?set the terminal icon and title?in?xterm?compatible terminals

    u?expands to the username of the current user.

    @?is a literal @.

    h?expands to the hostname.

    :?is a literal colon character.

    w?expands to the current working directory.

    a?is an ASCII bell character.

  • ${debian_chroot:+($debian_chroot)}

    If you‘re in a chroot environment,this will expand to the name of the chroot in parentheses.

    ${var:+OTHER}?evaluates to?$OTHER?if?var?is set,otherwise as null string.?$debian_chrootis a variable initalized in?/etc/bash.bashrc?to the contents of the file?/etc/debian_chroot. Thus if your chroot environment includes this file,the prompt will include the contents of that file as an indication for which chroot the shell currently operates in.

  • [email?protected]h:w$

    This is the actual prompt you typically see.

    u,?@,?h,?:,?w?are as above.

    $?expands to a number sign # if the effective uid is zero (i.e. user is root),otherwise it expands to a dollar sign $.

Resources

  • Bash prompt escape sequences

  • Prompt magic

  • How to change the title of and xterm

?

?

参考资料:

  • https://unix.stackexchange.com/questions/86918/ps1-on-ubuntu-vm-does-not-match-actual-prompt

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读