Path: utzoo!attcan!uunet!munnari!murtoa.cs.mu.oz.au!mimir!hugin!augean!sirius!eco!nt!levels!ccdn From: ccdn@levels.sait.edu.au (DAVID NEWALL) Newsgroups: comp.unix.wizards Subject: Re: (login) behaviour. Message-ID: <204@levels.sait.edu.au> Date: 23 May 89 17:22:02 GMT References: Distribution: comp Organization: Sth Australian Inst of Technology Lines: 22 In article , brister@td2cad.intel.com (James Brister) writes: > Is this standard operating procedure for UN*X or just Ultrix 2.2? Basically, > when running the command ``login'' in a subshell, the username of the original > shell gets changed when the subshell exits. The file "/etc/utmp" can be used to translate terminals into logged in users. This file is updated by login. The "who" command uses this file to display the appropriate information. The command "who am i" therefore also uses this file. What is happening when you call "login" in a subshell is this: the utmp entry for your terminal is overwritten with the new username. When you exit the subshell, the utmp entry still contains the "new" username. If you are using a BSD flavour of Unix (and I suspect you are), you should use the command "whoami". This command apparently does not use /etc/utmp. David Newall Phone: +61 8 343 3160 Unix Systems Programmer Fax: +61 8 349 6939 Academic Computing Service E-mail: ccdn@levels.sait.oz.au SA Institute of Technology Post: The Levels, South Australia, 5095