Previous Table of Contents Next

Module 78
logname (SV)


The external logname command displays your user name (login name). logname returns the value of the environment variable $LOGNAME. The LOGNAME variable is set when you log in to the system.

The logname command can be used to perform testing in shell scripts. The user's login name can be checked for access permissions to a shell script. The logname output can be used for record keeping within a shell. It is not advisable to depend upon the output of logname for security reasons. The user can change the value of LOGNAME, thus changing the output of logname.


Following is the general format of the logname command.



Refer to env and login described in modules 41 and 77.


The LOGNAME variable is set in /etc/profile file on some systems or by the login command on others. The logname command writes to the standard output.


The logname command is used to return the user's login name. It may be used to log which users are using a certain shell script or to limit access to a shell script. If first names are used as login sequences the $LOGNAME variable may be used to personalize shell scripts.


In this activity you use the logname command to display your LOGNAME variable. Begin at the shell prompt.

1.  Type logname and press Return to display the value of your LOGNAME variable.
     cj> logname
2.  Turn to Module 159 to continue the learning sequence.

Previous Table of Contents Next