Simple Questions on setting environment variables

rohini_the_babe
rohini_the_babe used Ask the Experts™
on
1)

How can I set the PS1 variable to appear as follows?

username@hostname/PWD

A cd shud change the PS1 value

Using Korn shell on Solaris 9

2)

I dont want to type in commands frequently. I want to reuse the command i just used before. I want to accomplish this using the up and down arrow keys. How do I do this?

3)

When I log in as root it puts me on /? How do i create a home directory for root? I dont want it to be /home/root. Instead I want it to be /root.

4)
Is there any way of setting the PS1 varaible and all others globally instead of having a profile being copied to every account. I mean when I create account using  a script Is there any way that I can  avoid copying the .profile stuff from a protoype account and still have the PS1,PATH,MANPATH set?

5)
On one of the servers I log to I see that df -k shows me that /dev/rdsk/c#t#d#s# is mounted on /export/home/sales. When I log in and type pwd it says
/home/sales/rohini. Where did the export go? what is its role?

6) Does the guys who answer Q's get paid thru the points they earn?

Thanks a lot,
Rohini.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Here's the answers for your questions:

1) How can I set the PS1 variable to appear as follows?

    Put the followings in your .profile

    HOSTNAME=$(hostname)
    PWD=$(pwd)
    PS1='${LOGNAME}@${HOSTNAME}[${PWD}] !# '

2) I dont want to type in commands frequently. I want to reuse the command i just used before. I want to accomplish this using the up and down arrow keys. How do I do this?

   This cannot be done with ksh, if you want to use it, use tcsh instead.

   In ksh your can use vi/emacs style of searching for command line history by putting the following in .profile

   vi style :
            set -o vi
   or emacs style:
             set -o emacs

3) When I log in as root it puts me on /? How do i create a home directory for root? I dont want it to be /home/root. Instead I want it to be /root.

   If your /home is in the root filesystem, you can edit /etc/passwd and change the home dir /home/root

   otherwise, mkdir /root, and use /root as the root's home dir. (root have to work in single user mode, have to make sure its home dir always mounted !)

4) Is there any way of setting the PS1 varaible and all others globally instead of having a profile being copied to every account. I mean when I create account using  a script Is there any way that I can  avoid copying the .profile stuff from a protoype account and still have the PS1,PATH,MANPATH set?

   Create a file /etc/skel/.kshrc, and put all the stuff you want to be globally accessible in the file, and make sure that every one have rx permission !
   (chmod a+rx /etc/skel/.kshrc)
   for all the ksh user, put the following in their .profile
   export ENV=/etc/skel/.kshrc


5) On one of the servers I log to I see that df -k shows me that /dev/rdsk/c#t#d#s# is mounted on /export/home/sales. When I log in and type pwd it says
/home/sales/rohini. Where did the export go? what is its role?

   /export/home is mount on /home in this case
   (short path !)
6) Does the guys who answer Q's get paid thru the points they earn?

   No, we don't get paid for it, at least I never get a cent from EE.

   We come here just for helpping people.
   

Author

Commented:
Sorry I forgot to accept this answer. I will be glad if you can elaborate more up on the Home directory stuff.

My home is not under /. I do have a separate /export/home. So do you mean to say that i shud create a /export/home/root and edit the root entry in /etc/passwd file to /export/home/root.
What I mean is that IF the /export/home is in the / (root) filesystem, THEN you can use /export/home/root and edit the root entry in /etc/passwd file to /export/home/root

Cheers!

yuzh

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial