Solved

UNIX PATH variable

Posted on 2011-03-12
4
953 Views
Last Modified: 2012-05-11
I set my PATH variables in .profile file and also in .kshrc file.
If .profle file I set up shell variables:
----------
ENV=$HOME/.kshrc
export ENV
----------
I have set PATH variables and aliases in the .kshrc variable.
Now when I become root via pbrun ksh command and lose all the PATH variables and aliases that I had in my login.
How can I use the those when I become root?
I am on a Solaris 10 server.
0
Comment
Question by:toooki
4 Comments
 
LVL 40

Expert Comment

by:omarfarid
Comment Utility
put the PATH and other variables settings in /.profile for root user. You need to export them as well to be set in sub shells
0
 
LVL 3

Expert Comment

by:Alberto Cortes
Comment Utility
Solution:

1. Edit /.profile
  # vi /.profile
2. Append below items to the end of /.profile:
  ENV=$HOME/.kshrc
  export ENV
3. Save and exit
0
 
LVL 6

Accepted Solution

by:
Tomunique earned 475 total points
Comment Utility
don't know pbrun, or solaris...

but, (while not nice pretty and automated), you can manually set them.

Your Home:  /home/myhome
kshrc:        /home/myhome/.kshrc

when you log in as root
source those files with "dot space"

# .  /home/myhome/.kshrc

this will load into your crrent environment, the contents of your .kshrc file.
you could do the same thing with your .profile

# . /home/myhome/.profile

I'd urge you to NOT modify root's profile etc, to reference a users files.
WHile it can be done, IMHO, keep root as stripped down as possible.
Any problems with your .kshrc or .profile, that would prevent root from logging in, could be a bad thing in the future.

Tom
0
 

Author Comment

by:toooki
Comment Utility
Thank you all.

Yes root user does not have any .profile or .kshrc entries -- as multiple users become root from time to time.

After being root I used the command .  /home/myhome/.kshrc and it worked perfectly.
Thanks!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now