Operating System - Linux
1827474 Members
2059 Online
109965 Solutions
New Discussion

Re: Setup prompt from script

 
SOLVED
Go to solution
Coolmar
Esteemed Contributor

Setup prompt from script

Hi,
When I "su" to root (I can't change the root .profile) I want to run the following to set things up the way I like....but it is not running. Any ideas?

#!/usr/bin/ksh

PS1="`whoami`@`uname -n`:\$PWD# ";export PS1
alias l="ls -la"
7 REPLIES 7
spex
Honored Contributor

Re: Setup prompt from script

Hi Coolmar,

Are you typing:
$ su root
or
$ su - root
?

PCS
Coolmar
Esteemed Contributor

Re: Setup prompt from script

su - root .... sorry, should have mentioned that.
Peter Nikitka
Honored Contributor
Solution

Re: Setup prompt from script

Hi,

put your commands in a file 'my_settings' and then execute

. /path/to/my_settings

(there is a space between the dot and the pathname!).

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
James R. Ferguson
Acclaimed Contributor

Re: Setup prompt from script

Hi:

You have al that you need. Encapsulate your commands in a file as you show and when you have 'su'-ed to root, source (read) the file:

$ su root
# . ./mythings

Note the dot followed by a space, followed by your file's name.

Regards!

...JRF...
Jonathan Fife
Honored Contributor

Re: Setup prompt from script

You shouldn't be specifying a shebang (#!/path/to/shell) in the .profile, as it is sourced.

Other than that, are you sure you're modifying root's .profile? vi '~/.profile' if you're logged in as root. Usually you will see lines like " echo "WARNING: YOU ARE SUPERUSER !!\n"" -- do you see that warning when you log in as root?
Decay is inherent in all compounded things. Strive on with diligence
spex
Honored Contributor

Re: Setup prompt from script

Hello again,

Note that you should never change root's shell from /sbin/sh.

Why can't you change ~root/.profile? As others have said, you should be able to place your customized settings in a separate file, and then source it by adding '. ' to the top of .profile. If you really are not able to modify .profile, you could change /etc/profile to selectively source the settings file when the user is root.

PCS
Coolmar
Esteemed Contributor

Re: Setup prompt from script

Can't change root's profile due to policy. That's just the way it is here.

I have it already in a script but didn't realize I had to put the "." then a space to run it.

Thanks!