${LOGNAME} vs. ${USER}

Brandon Vincent (Student) Brandon.Vincent at asu.edu
Sun Jul 12 15:42:53 UTC 2015


The environment variable LOGNAME is a convention from the early days of AT&T UNIX. USER has been around for the same time in the BSD community.

>From the man page of login(1) from UNIX System III circa 1982, the only environment variables set at login were:

HOME=your-login-directory
PATH=:/bin:/usr/bin
LOGNAME=your-login-name

>From the man page of login(1) for 2BSD (in particular, 2.9 a 1983 release which contained some backported features of 3BSD and 4BSD):

login initializes the user and group IDs and the working directory, and sets the HOME, PATH, TERM, SHELL and USER environment variables.

Interestingly, FWIW only LOGNAME is required to be set by POSIX-compliant systems as stated in the IEEE Std 1003.1-2008 / POSIX.1-2008 specification.

As for the practical difference between the two, I wouldn't worry about it. Both GNU/Linux and other *nix systems such as the BSD flavors support both for compatibility reasons.

Brandon Vincent


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20150712/fdec34d2/attachment.html>


More information about the ubuntu-users mailing list