When the echo $LOGNAME
and logname
commands run normally, I get identical results from them:
pandya@pandya-desktop:~$ echo $LOGNAME
pandya
pandya@pandya-desktop:~$ logname
pandya
Is there any difference between them?
environment-variables
When the echo $LOGNAME
and logname
commands run normally, I get identical results from them:
pandya@pandya-desktop:~$ echo $LOGNAME
pandya
pandya@pandya-desktop:~$ logname
pandya
Is there any difference between them?
Best Answer
From Environment variables:
$LOGNAME
is same as$USER
which givesFrom
man logname
:Explained differently used by following example:
Here you can see the difference after logging as root in a terminal,
$LOGNAME
gives the name of the currently logged-in user in the terminal (i.eroot
)logname
prints the user's login name who logged in to the session (i.e.pandya
)