Linux / Unix: logname Command Examples To Display Loginname

The logname command in Unix-like systems is used to display the login name of the user running the command. Here’s how to use it:

  1. Open a terminal or shell window.
  2. Type the following command:
    $ logname
  3. Press Enter. The logname command will display the login name of the current user, for example:
    user

Note that the logname command is a simple and easy way to display the login name of the current user, but it may not be available on all Unix-like systems. If it’s not available on your system, you can use the whoami or id command to display the current user’s information, including the login name.

Leave a Comment