AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1024093
Accepted
Jonas Heinze
Jonas Heinze
Asked: 2020-07-06 08:15:17 +0800 CST2020-07-06 08:15:17 +0800 CST 2020-07-06 08:15:17 +0800 CST

更改 linux 外壳

  • 772

在我的 Centos7 服务器上,我为我的用户提供了不同的 shell。

例如,作为 root 的终端如下所示:

[root@hostname www]#.

终端作为不同用户的样子bash-4.2$。

如果我键入echo $0以获取当前使用的 shell,我将/bin/bash访问我的不同用户和-bash我的 root。

我是否必须为我的不同用户配置 shell,以使其看起来像我的 root 的 shell?

有没有办法使用 Debian ( bash) 中使用的 shell 来查看我所在位置的完整路径?(root@server:/var/www#而不是root@server www)。

谢谢你的帮助。

linux terminal-server shell terminal centos7
  • 2 2 个回答
  • 105 Views

2 个回答

  • Voted
  1. Best Answer
    Michael Hampton
    2020-07-06T08:31:45+08:002020-07-06T08:31:45+08:00

    听起来您的用户缺少骨架文件, default.bashrc等.bash_profile,这些文件通常从/etc/skel创建用户时复制到用户的主目录中。如果这些文件丢失或损坏,您可以自己复制这些文件。

    • 4
  2. fpmurphy
    2020-07-06T19:52:10+08:002020-07-06T19:52:10+08:00

    用户的提示由 shell 变量 PS1、PS2、PS3、PS4 的值决定。

    PS1 – The value of this parameter is expanded and used as the primary prompt string. 
          The default value for Bash is \s-\v\$ .
    PS2 – The value of this parameter is expanded as with PS1 and used as the secondary 
          prompt string. The default value for Bash is >
    PS3 – The value of this parameter is used as the prompt for the select command
    PS4 – The value of this parameter is expanded as with PS1 and the value is printed 
          before each command bash displays during an execution trace.
    

    通常用户只自定义 PS1。

    Bash 允许通过插入一个或多个转义的特殊字符来自定义这些变量:

    \a : ASCII bell character
    \d : The date in “Weekday Month Date” format (e.g., “Tue May 26”)
    \D{format} : the format is passed to strftime(3) and the result is inserted into
    the prompt string; an empty format results in a locale-specific time representation. 
    The braces are required
    \e : Tne ASCII escape character
    \h : The hostname up to the first ‘.’
    \H : The full hostname
    \j : The number of jobs currently managed by the shell
    \l : The basename of the shell's terminal device name
    \n : A newline
    \s : The name of the shell
    \t : The current time in 24-hour HH:MM:SS format
    \T : The current time in 12-hour HH:MM:SS format
    \@ : The current time in 12-hour am/pm format
    \A : The current time in 24-hour HH:MM format
    \u : The username of the current user
    \v : The current version of bash (e.g., 2.00)
    \V : The current release of bash, version and patch level (e.g., 4.12.0)
    \w : The current working directory, with $HOME abbreviated with a tilde
    \W : The basename of the current working directory, with $HOME abbreviated 
         with a tilde
    \! : The history number of this command
    \# : The command number of this command
    \$ : If the effective UID is 0, a #, otherwise a $
    \nnn : The character corresponding to the octal number nnn
    \\ : A backslash
    \[ : Begin sequence of non-printing characters, which could be used to embed 
         a terminal control sequence into the prompt
    \] : End sequence of non-printing characters
    

    例子:

    fpm@fpmurphy ~]$ PS1="[\d \t \u@\h:\w ] $ "
    [Sun Jul 05 23:44:17 fpm@fpmurphy:~ ] $ 
    

    要在重新启动或注销时保留自定义提示,请将提示添加到 users $HOME/.bashrc,或使其成为所有用户的默认提示,根据您的发行版将其添加到/etc/bashrc或创建一个条目。/etc/bashrc.d

    • 1

相关问题

  • 多操作系统环境的首选电子邮件客户端

  • 你最喜欢的 Linux 发行版是什么?[关闭]

  • 更改 PHP 的默认配置设置?

  • 保护新的 Ubuntu 服务器 [关闭]

  • (软)Ubuntu 7.10 上的 RAID 6,我应该迁移到 8.10 吗?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve