logname command is used to print the name of the current terminal logged in user. This command is useful when you need to quickly determine the username of the user logged into a terminal session.
To use this command, simply open a terminal and type
logname. The output will be the name of the user currently logged into that terminal session.
$ logname johndoe
- Quickly determine the username of the user logged into a terminal session.
- Use in scripts to perform actions based on the current user.
logname command has no options.
logname command does not return any output, it may be because no user is currently logged into the terminal session. Ensure that a user is logged in before running this command.
lognamecommand is only useful for determining the username of the user logged into a terminal session. To determine the username of the user running a script or command, use the
- This command is available on most Linux distributions and does not require any special permissions to run.