Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Identifying the user

Status
Not open for further replies.

Daedelus

Technical User
Aug 14, 2002
70
US
Does anyone know a simple, fool-proof way of identifying the user in the Korn shell?

The environment variable USER is writable, so anyone can change its value to whatever they want.
For a while I thought that LOGNAME would do it, but then I realized that you can get around its protections and change its value as well.

The best I have come up with so far is to create a temporary file, do a ls -l on it, and read in the owner name.

Somewhere, though, the system has to have stored who the current user is, and I ought to be able to read this information without pulling stunts like that.
 
you could execute whoami command or use the format $(whoami)
 
Thanks! I figured there had to be something simple I was overlooking. Alas, since I know who I am, it never occurred to me to ask! ;-)
 
Hello Daedelus,
I thought you might want to know who the user really is so the "who am i" command will tell you the original logon name even after multiple su's.
Later!
Charlie Ehler
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top