Change root prompt (Solaris)


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Change root prompt (Solaris)
# 1  
Old 12-31-2008
Change root prompt (Solaris)

Hello all. I was wondering if there is a way to change the root prompt.

I am using Solaris 10 and would like to have the root prompt display the current directory along with 'SU' to indicate root status.

What I have tried so far:

/etc/passwd

changed the root shell to korn with /bin/ksh

and in /etc/default/su

PS1='$PWD(SU)>'

saving changes and rebooted the system.

Unfortunately that did not have the desired effect.

Is there a different file that needs to be edited to change the root prompt from the default # or is this not possible?

Thanks,
~Robert
# 2  
Old 12-31-2008
Depending on your needs you just set the value of PS1 in $HOME/.profile or $HOME/.kshrc
# 3  
Old 12-31-2008
For what its worth, I personally would stay away from changing the root shell in /etc/passwd. root runs many things within the OS and I have found this to not be a good thing. If you want the root shell to be ksh, create a root .profile and simply execute it there.
Now, to answer your question.
Since /etc/profile is read for all logins, no matter which shell, I have found it most useful to modify the /etc/profile so users know which system they are on. Feel free to try this with your $PWD:
if [ "$LOGNAME" = "root" ]
then
PS1="ROOT@`uname -n`# " ; export PS1
else
PS1="$LOGNAME@`uname -n`$ " ; export PS1
fi
# 4  
Old 12-31-2008
Quote:
Originally Posted by 22blaze
For what its worth, I personally would stay away from changing the root shell in /etc/passwd. root runs many things within the OS and I have found this to not be a good thing.
There is no problem with changing it on Solaris 10. The old "/sbin/sh" is a statically linked shell no longer applies in Solaris 10. If something breaks because of the login shell it's badly written and should be fixed, either locally if it's an in-house application/script or else reported to the OS vendor.

On the other hand I do not like editing /etc/profile for user options. This is exactly why the home directory alternatives exist.
# 5  
Old 12-31-2008
Thanks for the tip on old /sbin/sh.
Understood on the "should be fixed".
As for the debate on /etc/profile vs. user home dirs, we can agree to disagree. It is a personal preference and as you said, it can be overridden by the user specific profile. For me, the /etc/profile entry ensures that I have put in a method of "self check" for admins who may be working on mulitiple systems at the same time and don't reboot the wrong server because they forgot to check which one they were on.
# 6  
Old 01-02-2009
Thanks all for the suggestions. I have reverted the root shell in /etc/passwd back to /sbin/sh

I am still not getting the root prompt to change to show the current directory with (su) to show root status.

Here is what I now have in /etc/profile

#code to set prompt
if [ "$LOGNAME" = "root" ]
then
PS1='$PWD(SU)>'; export PS1
else
PS1='$PWD>'; export PS1
fi

I log in to this box via telnet and here are what the prompts look like:

login: robert
Password:
Last login: Thu Jan 1 23:54:46 from 192.168.1.100
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
/home/robert>su
Password:
#
$LOGNAME still has me as "robert" even after going to root:

# echo $LOGNAME
robert
#
So I am not sure if the code in /etc/profile will work if it is based off of $LOGNAME. Unless /etc/profile is not the place to use it...?

Also I have tried the $PWD(SU)> in single and double quotes and still have not gotten the desired result.

Any suggestion on how to change the root prompt would be much appreciated.

Thanks,
~Robert
# 7  
Old 01-02-2009
Google knows all it seems or at least with enough poking around, you can find a hint that will help.

I tried going to root like such:
su - root

and the prompt did not change.

Changing the root shell in /etc/passwd to:
/bin/ksh

and trying again, the prompt changed to what I want.

Woot!

Now the question remains, is there a problem leaving the root shell set at /bin/ksh?

Thanks,
~Robert
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Can a root role change the root password in Solaris 10?

i do not have root on a solairs 10 server , however i do have the root role, i was wondering if I can change the root password as a a role with the passwd command? I have not tried yet. and do i have to use the # chgkey -p afterwards? i need to patch is why i am asking. thanks (1 Reply)
Discussion started by: goya
1 Replies

2. Ubuntu

Root access that can't change root password?

We are having a little problem on a server. We want that some users should be able to do e.g. sudo and become root, but with the restriction that the user can't change root password. That is, a guarantee that we still can login to that server and become root no matter of what the other users will... (2 Replies)
Discussion started by: 244an
2 Replies

3. UNIX for Dummies Questions & Answers

How to Change the % prompt to - prompt in UNIX?

how to Change the % prompt to - prompt in unix :wall: ---------- Post updated at 07:40 AM ---------- Previous update was at 07:38 AM ---------- How To display the last modification time of any file in unix ---------- Post updated at 07:40 AM ---------- Previous update was at 07:40 AM... (2 Replies)
Discussion started by: manjiri sawant
2 Replies

4. Solaris

Can't change root password in solaris express 11

How do I change root password in SolarisExpress 11? I used passwd while elevated to root and all it changes is the password of the user I am logged in, not te root password. (2 Replies)
Discussion started by: taltamir
2 Replies

5. Solaris

Solaris 8 - Asks for current root password when trying to change root password.

Hello All, I have several solaris boxes running Solaris 8. When changing root passwords on them, all will simply ask for the new root password to change and of course to re-type the new password. One of the systems however asks for the existing root password before it will display the new password... (8 Replies)
Discussion started by: tferrazz
8 Replies

6. Solaris

root can not change the permission of old oracle archive directory in solaris 8

I am using oracle 9i with sun solaris 8 on Sun E 250 server.earlier we are taking backup of oracle archive files on /orabackup directory.in which archive file are stored with ...arc.Z extension. now we have changed the archive backup directory.now when we are trying to delete earlier directory... (3 Replies)
Discussion started by: mahanalok
3 Replies

7. UNIX for Advanced & Expert Users

su command without password prompt to non-root account

Hello. I searched the internet for answers and don't seem to find any for about a day now. My problem. I want to su to a non-root account non-interactively, e.g. if I want to temporarily become prdusr, I want to su prdusr without keying prdusr's password every time. What I want is... (10 Replies)
Discussion started by: royale-sojin
10 Replies

8. Solaris

Solaris 10 root shell change

Why does Solaris keep coming with bourne as the default root shell? I've spoken with numerous admins that tell me they change all the root shells to korn. I would like to change all Solaris 10 boxes here at my company to have a root korn shell. Can someone tell me why I shouldn't do this? ... (10 Replies)
Discussion started by: x96riley3
10 Replies

9. AIX

Root login does not prompt for password

I've an LPAR set up on a P690. The LPAR ran AIX v5.2. I then did an upgrade (using the migration option) to AIX v5.3. I've now encountered the problem that, at the console, I cannot log in as root (or as anyone else that matter). I get the login prompt, enter "root " and then the shell returns to... (1 Reply)
Discussion started by: morgan_g
1 Replies

10. UNIX for Dummies Questions & Answers

I need it to prompt me for a root password, so I don't have to log as root

Hi folks, I'm trying to install a program, and I want to place some of the executables into /usr/bin so that they can be executed from any folder on the computer. I've been giveng the root password, but told never to log in directly as root. Instead, I can wait for a password prompt. However, I... (2 Replies)
Discussion started by: lunchtime
2 Replies
Login or Register to Ask a Question