1

Why is the terminal prompt unchanged when I log in as root? I.e, my default prompt is 0|storm@sky:~ %, but when I log in as root, it's something like ~ root] #. How do I change that variable, and would it affect my other prompts?

Eugene
  • 87

1 Answers1

3

@Eugene.

I'm not sure if I understand your question but if by "prompt" you mean the $PS1 variable you can try to change it through one of these files ~/.bash_profile or ~/.bashrc or /etc/profile. Those files would be read by the shell after you login, which means you'll have to logout and login again to make those changes available.

The $PS1 variable is the first prompt string variable which defines your 0|storm@sky:~%. The second one is the $PS2 which is usually seen as ">" ("greater than" symbol).

Let me show you some options:

$ PS1="\d$" #date format
Sun Jan 9$

$ PS1="\u$" #username
john$

$ PS1="\h$" #hostname
your_computers_name$

The combination of some of these options will define your prompt string.

Hope it helps.

ekkos
  • 46
  • Yes, I do mean the $PS1 variable. However, is there a way for it to be automatically exported during login? And could I (possibly) change the default shell for the root user? – Eugene Feb 13 '13 at 09:40
  • Hi, @Eugene. I'm so sorry! Was away the last year... Well, answering your question, I think you should try modifying your .bashrc, .bash_profile instead of just exporting the variables. Don't forget to logout and login again of terminal to see the changes. Or you could just write this: source .bash_profile or source .bashrc. – ekkos Apr 12 '14 at 17:15