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?
Asked
Active
Viewed 259 times
1
Eugene
- 87
- 1
- 6
-
1Please specify: What do you mean by "not changed" - What do you expect to see? – user98085 Feb 12 '13 at 14:24
-
@FEichinger I think he is asking about how to change host name. OP be clear about what you would like to have so that we can help you in a better way. – Raja G Feb 12 '13 at 14:35
-
#Warning (as an aside): [Running routinely as root is a bad idea](http://askubuntu.com/questions/16178/why-is-it-bad-to-run-as-root) - You rarely need to do it but **if** you do you can very easily and irreparably destroy your system and your data. – guntbert Feb 12 '13 at 16:03
-
Please add to your question, the command that you use to log in as root (or if you activated login for root like any user). – Ankit Feb 12 '13 at 17:18
-
I didn't really add the command for logging in as root (not `su` or `sudo bash`), but booted into single-user mode. If you're asking how I booted into SU mode, [http://askubuntu.com/questions/132965/how-do-i-boot-into-single-user-mode-from-grub](http://askubuntu.com/questions/132965/how-do-i-boot-into-single-user-mode-from-grub) – Eugene Feb 13 '13 at 09:41
1 Answers
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
- 5
-
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