LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-24-2006, 05:48 PM   #1
Demon_Spawn
LQ Newbie
 
Registered: Sep 2006
Posts: 3

Rep: Reputation: 0
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
 
Old 09-24-2006, 06:30 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Jessie 8.4
Posts: 5,873

Rep: Reputation: 348Reputation: 348Reputation: 348Reputation: 348
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.
 
Old 09-24-2006, 07:10 PM   #3
Kristijan
Member
 
Registered: Sep 2003
Location: Melbourne, Australia
Distribution: NetBSD 3.0.1, Slackware 10.1
Posts: 394

Rep: Reputation: 30
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
 
Old 09-24-2006, 08:22 PM   #4
Demon_Spawn
LQ Newbie
 
Registered: Sep 2006
Posts: 3

Original Poster
Rep: Reputation: 0
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

Last edited by Demon_Spawn; 09-24-2006 at 08:26 PM.
 
Old 09-24-2006, 10:09 PM   #5
Kristijan
Member
 
Registered: Sep 2003
Location: Melbourne, Australia
Distribution: NetBSD 3.0.1, Slackware 10.1
Posts: 394

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

-Kristijan
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing the command prompt DJ KC Red Hat 3 10-10-2005 01:47 AM
Why prompt for changing password? gogo Linux - General 1 03-10-2005 10:47 AM
Changing the tux image on the command prompt Oholiab Slackware 3 03-06-2005 10:16 AM
Key stroke/command to shut down x and go into the command prompt screen? Fear58 Linux - General 1 07-14-2004 08:14 PM
Changing the command prompt in bash george3k Linux - General 4 07-11-2001 09:10 PM


All times are GMT -5. The time now is 12:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration