LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Problem in Terminal (https://www.linuxquestions.org/questions/linux-software-2/problem-in-terminal-4175457073/)

Huamin 04-06-2013 01:43 AM

Problem in Terminal
 
Hi,
Within my Red hat, when I login the server using "oracle" login, and then go to the Terminal, I get the prompt like

bash-3.2$

in that. Why?

kooru 04-06-2013 03:02 AM

What's the problem?
If you don't like the prompt, you can change PS1 variable.

http://www.thegeekstuff.com/2008/09/...ngelina-jolie/

Huamin 04-06-2013 03:04 AM

Thanks. I want to see why the prompt does change by itself. And why is the problem only for "oracle" user, while for "root" user, no such problem?

bloody 04-06-2013 09:01 AM

That's because the shell prompt is configured for each user separately. Don't look at this as a problem, but rather a useful feature. See also: ~/.profile, ~/.bashrc.

Huamin 04-07-2013 03:25 AM

Sorry, I am now using "oracle" login and I don't see 2 files below
bash-3.2$ ls ~/.profile
ls: /u01/app/oracle/.profile: No such file or directory
bash-3.2$ ls ~/.bashrc
ls: /u01/app/oracle/.bashrc: No such file or directory

catkin 04-07-2013 04:47 AM

Quote:

Originally Posted by Huamin (Post 4926712)
Sorry, I am now using "oracle" login and I don't see 2 files below
bash-3.2$ ls ~/.profile
ls: /u01/app/oracle/.profile: No such file or directory
bash-3.2$ ls ~/.bashrc
ls: /u01/app/oracle/.bashrc: No such file or directory

That's normal. You can create them if you want them.

In answer to the original question, "bash-3.2$" is the default prompt when PS1 is not set.

The link that kooru gave has comprehensive information but does not include setting the window title for terminal emulators. Many of them use xterm's control sequences, assumed below.

In a PS1 value like \[\033]0;\u@\h:\w\007\]\u@\h:\w\$ ...
  1. The \[ ... \] tells bash this part is non-printing and should be discarded when calculating the length of the prompt which the user will see.
  2. The \033 ... \007 tells the terminal to use the contained text as a control sequence.
  3. The ]0; tells the terminal this is its window title.
  4. The \u@\h:\w is the window title -- after changing \u to the user name, \h to the hostname and \w to the working directory in the usual way as well explained in the page linked by kooru.

Huamin 04-07-2013 05:34 AM

Thanks a lot. How to set PS1? Why is the problem only for "oracle" login while it is fine for root login?

Huamin 04-07-2013 08:33 PM

Dear all,
Any help to this?

chrism01 04-07-2013 09:09 PM

See post #4; its NOT a problem.
The PS1 prompt (the one you see most of; there are 4 ) can be set individually for each user.
If you want it to be different for the oracle user, here's a couple of links to start with
http://www.cyberciti.biz/tips/howto-...up-prompt.html
http://www.thegeekstuff.com/2008/09/...ngelina-jolie/

Huamin 04-07-2013 09:54 PM

Thanks. After I've done this
bash-3.2$ PS1="\$"

I see the prompt has been changed to
$
$

but after I've restarted the server, the prompt is still this
bash-3.2$

chrism01 04-08-2013 01:16 AM

Read the links above; they show how to set it permanently.

Huamin 04-08-2013 01:45 AM

Hi,
I edited this file
bash-3.2$ cd ~
bash-3.2$ vi .bash_profile

to put this
PS1="\$"

inside it. But after I've restarted the server, I still see this
bash-3.2$

as the prompt.

catkin 04-08-2013 03:02 AM

Quote:

Originally Posted by Huamin (Post 4926765)
Why is the problem only for "oracle" login while it is fine for root login?

Because root's shell is initialised differently. Most likely root has one or more of ~/.profile, ~/.bash_profile, ~/.bash_login and ~/.bashrc.

catkin 04-08-2013 03:08 AM

Quote:

Originally Posted by Huamin (Post 4927339)
Hi,
I edited this file
bash-3.2$ cd ~
bash-3.2$ vi .bash_profile

to put this
PS1="\$"

inside it. But after I've restarted the server, I still see this
bash-3.2$

as the prompt.

Maybe you are working in an interactive non-logon shell, in which case the PS1 setting needs to be in ~/.bashrc. For most of us the distinction between logon and non-logon shells does not matter. To get the same customisation in both types of shell put this in ~/.bash_profile ...
Code:

case $- in
 *i* )  # We're interactive
  if [ -f ~/.bashrc ]; then . ~/.bashrc; fi
esac

... and this (or your preferred alternayve) in ~/.bashrc
Code:

export PS1='\[\033]0;\u@\h:\w\007\]\u@\h:\w\$ '
There's no need to restart the server to test. You can just use
Code:

source ~/.bashrc

Huamin 04-08-2013 09:20 AM

Catkin,
It is fine now. Do you think it is due to files accidentally deleted or any other reasons for this problem?


All times are GMT -5. The time now is 06:15 AM.