LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Changing the command Prompt (https://www.linuxquestions.org/questions/linux-newbie-8/changing-the-command-prompt-486572/)

Demon_Spawn 09-24-2006 04:48 PM

Changing the command Prompt
 
I was wondering if anyone can tell me how to change command prompt? I'm running RedHat 8. When I log in as root, it looks likr this:

Code:

[root@users root]#
But when I log in as a normal user, it looks likr this:

Code:

-sh-2.05b$
How can I make it look like it does on root?

Thanks
Demon_Spawn

bigrigdriver 09-24-2006 05:30 PM

Take a look in /etc. Look for a file which may be called bashrc or bash.bashrc. It may also be in profile. It may specify two different prompts: one for root and one for user. Just do some copy/paste to copy the root prompt to the user prompt.

If that doesn't work because you can't find anything about prompt (the line would start PS=), then look in /root for a hidden file (.bashrc). Copy the prompt line and paste it in your users .bashrc.

Kristijan 09-24-2006 06:10 PM

I'll take a stab at it from memory, I don't have a box in front of me.

Code:

PS1="[\u@\h \w]\$ "; export PS1
-Kristijan

Demon_Spawn 09-24-2006 07:22 PM

okay I found "bashrc" in /etc. Heres what I see, and I'm as lost as a needle in a heystack... and if I make a change I need to reboot?

Code:

# /etc/bashrc

# System wide functions and aliases
# Environment stuff goes in /etc/profile

# by default, we want this to get set.
# Even for non-interactive, non-login shells.
if [ "`id -gn`" = "`id -un`" -a `id -u` -gt 99 ]; then
        umask 002
else
        umask 022
fi

# are we an interactive shell?
if [ "$PS1" ]; then
    if [ -x /usr/bin/tput ]; then
      if [ "x`tput kbs`" != "x" ]; then # We can't do this with "dumb" terminal
        stty erase `tput kbs`
      elif [ -x /usr/bin/wc ]; then
        if [ "`tput kbs|wc -c `" -gt 0 ]; then # We can't do this with "dumb" terminal
          stty erase `tput kbs`
        fi
      fi
    fi
    case $TERM in
        xterm*)
                if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
                        PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
                else
                PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\007"'
                fi
                ;;
        screen)
                if [ -e /etc/sysconfig/bash-prompt-screen ]; then
                        PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
                else
                PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\033\\"'
                fi
                ;;
        *)
                [ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prom$
            ;;
    esac
    # Turn on checkwinsize
    shopt -s checkwinsize
    [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "

    if [ "x$SHLVL" != "x1" ]; then # We're not a login shell
        for i in /etc/profile.d/*.sh; do
            if [ -r "$i" ]; then
              . $i
            fi
        done
    fi
fi
# vim:ts=4:sw=4


Kristijan 09-24-2006 09:09 PM

There ya go, I was almost there - PS1="[\u@\h \W]\\$ "

-Kristijan


All times are GMT -5. The time now is 01:10 PM.