Variables for Effective Username?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Variables for Effective Username?
# 1  
Old 07-01-2002
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... Smilie

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  
Old 07-01-2002
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  
Old 07-01-2002
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  
Old 07-01-2002
MySQL

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? Smilie

Thanks again!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Why does "ps -[u|U] username" not list processes when username is numeric?

Greetings, The title pretty much says it all. I've snooped everywhere and can't find anything on this. Since our organization went to numeric usernames, using the u|U option for ps returns no processes. Example passwd entry: 320074:DjZAJKXun8HBs:10129:6006:Joe Y:/cadhome/analysis/jy:/bin/bash... (4 Replies)
Discussion started by: crimso
4 Replies

2. Cybersecurity

Password rules not effective

I was looking for a good list of words to exclude people from using as passwords, i.e. those that could be guessed easily. I'm working through a whole bunch of suggestions from skullsecurity.org, but I managed to find this page that seems to suggest I have more options than I thought. :b: I... (1 Reply)
Discussion started by: rbatte1
1 Replies

3. UNIX for Dummies Questions & Answers

[Solved] effective user id upon exec

Hello all. Despite the exec man page, the exec system call seems to turn my effective-user-id into my real-user-id. I coded and compiled 2 very simple c programs as user 1 (uid=501) The first one (A) prints real and effective user IDs and then execs the second one (B), which in turn prints... (7 Replies)
Discussion started by: oviv
7 Replies

4. UNIX for Dummies Questions & Answers

Real and Effective IDs

Can anyone explain me in details of Real and Effective IDs (6 Replies)
Discussion started by: kkalyan
6 Replies

5. Shell Programming and Scripting

what is the most effective way to process a large logfile?

I am dealing with a very large firewall logfile (more than 10G), the logfile like this *snip* Nov 9 10:12:01 testfirewall root: Nov 9 10:12:01 testfirewall root: 0:00:11 accept testfw01-hme0 >hme0 proto: icmp; src: test001.example.net; dst: abc.dst.net; rule: 1; icmp-type: 8;... (8 Replies)
Discussion started by: fedora
8 Replies

6. UNIX for Dummies Questions & Answers

Changing the Effective Group ID

Here is my situation. On a RedHat 7.3 box, I have a user named jody. When I log in with jody and type in "id", I get the expected output: uid=1(jody) gid=1(jody) groups=1(jody), 510(test) However, I cannot figure which "id" option allows me to change the effective gid. I tried the options... (2 Replies)
Discussion started by: Jody
2 Replies

7. UNIX for Dummies Questions & Answers

most effective search ?

what's the most efficient and effective search for a file in a dir ? I see many guys use this # find - print or something as such ? and sometimes pipe it to something else ? Is there a better way of using "grep" in all of this ? thanks simon2000 (3 Replies)
Discussion started by: simon2000
3 Replies

8. Cybersecurity

Changing effective user

I would like to give execution rights for a script to one user. (that's the easy part...) When that user is running the script, I would like the effective user ID to be that of the file-owner. Is this possible? (6 Replies)
Discussion started by: hilmel
6 Replies
Login or Register to Ask a Question