The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
what is the most effective way to process a large logfile? fedora Shell Programming and Scripting 8 11-16-2006 09:55 AM
Changing the Effective Group ID Jody UNIX for Dummies Questions & Answers 2 12-05-2002 03:53 PM
most effective search ? simon2000 UNIX for Dummies Questions & Answers 3 10-09-2002 10:18 AM
Changing effective user hilmel Security 6 12-06-2001 04:31 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-01-2002
QuadMonk QuadMonk is offline
Registered User
  
 

Join Date: Jun 2002
Location: College Station, Texas
Posts: 2
Variables for Effective Username?

Hey all, I'm glad to have found this forum as I'm trying to dive head first into Solaris 8 - been working with it for a few months now and am finally getting a bit comfortable with the layout and concepts. In any case, on to the questions...

I was wondering how I would go about displaying the Effective Username (for example if I login as user1 initially, then su to root, now my Effective Username is root) in the prompt on the system.

Currently $PS1 is set to: '[$LOGNAME : $PWD]$' and I'd like to replace $LOGNAME with their Effective Username so that when one su's to another username you don't forget whether you're still root, etc.

Thanks for your input!
  #2 (permalink)  
Old 07-01-2002
auswipe's Avatar
auswipe auswipe is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2001
Location: Wide Awake Wylie, Texas
Posts: 535
Does Solaris support `whoami`?

I use this for my prompt on my BSD systems:

Code:
OpenBSD:auswipe:/home/auswipe $ echo $PS1
`uname`:`whoami`:$PWD $
When I su to root, the prompt changes accordingly. Works like a champ.
  #3 (permalink)  
Old 07-01-2002
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,119
The command "whoami" will get this value. You don't say which shell you are using, but all shells have some technique for putting the output of a commend into a variable.

But there is another standard that you should be aware of. When you become root the final character of your prompt should switch from $ to #. This is a more or less universal standard in unix.
  #4 (permalink)  
Old 07-01-2002
QuadMonk QuadMonk is offline
Registered User
  
 

Join Date: Jun 2002
Location: College Station, Texas
Posts: 2
Thumbs up

Cool, thanks auswipe - I had forgotten about the good ol' `command` thing.

Perderabo - So, in theory, if I could test the output of the command `whoami` for root then I could tell it to use a different value for $PS1 (which would include the # rather than the $)? Sounds like I need to read up on some scripting, eh?

Thanks again!
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:16 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0