Where to set root's prompt ?
Hello friends,
I have a Solaris 10 machine and I want to permanantly set root's prompt. By default it gives me "#" prompt for root. I couldn't find any .profile or .login or any shell initialization such as .bashrc or .cshrc file in root's home i.e. in "/". I tried appending the prompt command in /etc/profile but it also worked only for cureent session. But it returns to # after openning new terminal. Please suggest where to define root's prompt? Thanks in advance! |
Quote:
IIRC in my slackware a root from su uses a PS1 @ /etc/profile, and a root from login uses /root/.bashrc. Hope that helps. Good luck. |
Or try find it either from your ~/ or /etc.
Quote:
|
root is not often configured to use bash on Solaris. It usually stays with its default shell which is /sbin/sh and is sometimes configured to use ksh, especially on Solaris 10. Solaris 11 finally use a POSIX shell for root.
/etc/profile or /.profile are correct places to set the prompt, please post what you wrote there and make sure PS1 is exported. |
full of hot air here...
I do not use OpenSol myself, so I may be terribly full of it, but if it helps....
1. Generally / is not the root home folder on most Unix variants. More likely /root is the root home. If you have a .profile there you can use that to set the prompt. 2. Otherwise, look for a block in the /etc/profile that checks the UID and takes different actions if it is over or under some value. (Generally 500 or 1000.) Add your setting of the prompt to the block that includes LOW numbers. 3. Test. If that does not work, check back on later parts of the same file and/or login process to see if the value is being overwritten later. IF so, you might need to add later code and undo the earlier changes. Obviously changing the thing found LAST in the process is better, so creating or modifying .profile in the root home is the preferable option. Earlier changes may be overwritten during upgrades or maintenance events, or may have consequences for other processes, users, or accounts. |
Quote:
Quote:
Quote:
|
Thanks everyone for your responses, here's summery what I've tried so far:
1. There are no /etc/.bashrc or /etc/bashrc files existing. 2. There is no /etc/.profile, but /etc/profile exists there. 3. In root's home (apparently it is "/" only), there is no .bashrc or .profile. So in the meantime, I appended following in /etc/profile: Code:
# Personalization 4. I manually created /.bashrc and just added: Code:
PS1="$USER{`pwd`}\!:" So now quesiton is, what's initialization file for /sbin/sh shell? and is there any file which comes into effect before /etc/profile or /etc/.login to set root's prompt to "#"? |
Quote:
Does the /etc/profile get honored? Use your block to take "#" into effect: manipulate the setenv and elif lines: Code:
# Personalization Good luck. |
Quote:
Also one more thing, when I open a terminal and do: Code:
# echo $PATH Code:
# tcsh |
Quote:
This what you might use: Code:
export PS1 |
Quote:
Anyway, what I can conclude is, /etc/profile comes in effect first and takes over .bashrc for all types of users. If prompt is not set in /etc/profile, then it consults .bashrc for the same. As a workaround I changed root's shell (in /etc/passwd) to /bin/bash and then it's working fine and using .bashrc & prompts cmd set in it. But I guess this could cause many other environment related problems for root. So this is temporary. |
Do you have a local init script that loads automatically? Usually in Slackware it is located at /etc/rc.d/rc.local, this is the place where we can load some environment specifications or run scripts via init. If you have it in the /etc then set your export block there. But be sure that the tcsh is truly installed not just a link to /bin/bash. Check your shell availability first.
I'm sorry I already forget how it was when I was running Solaris, it was merely a brief time; when Sun sold open sol to Oracle I deinstalled and tried to forget everything. Solaris is the best unix I think; but I have natural allergy to copyrights :) . Hope that helps. Good luck. |
Quote:
Quote:
Quote:
Quote:
Quote:
|
Quote:
Quote:
|
conditionals
What was the root shell before you hanged it?
I would expect it to be /bin/sh, but you should know. If it is the posix shell, or another shell acting in posix mode, you should be able to CREATE a file in the folder that root logon lands you, named .profile. On that folder set PS1 and then export it. I would not get complex here, just two simple lines should do the job. Code:
PS1='..>' (Note: on some systems /bin/sh is really a link to bash, ksh, or another shell. When called this way they should behave in posix mode, but the degree to which this is constrained varies. In reality they all act differently: the shell man pages should be your definitive guide.) You will NOT find export in your path, it is a shell internal. Some shells implement commands that CAN be found in the path with internal equivalents that either run faster, behave better, have added functionality, or all of the above. Seeking them in your path really does nothing useful for you. To complicate things even more, different shells often implement different internals. Here again, your man pages should guide you. BTW: export makes environment variables more generally available to called processes and sub-processes, it has NOTHING to do with changing your default shell. I am not sure where that idea originated. |
All times are GMT -5. The time now is 05:14 AM. |