0

Linux provides a few commands that display in production the user that is current login name. One of those is logname. In this tutorial, we shall quickly comprehend the fundamentals with this demand line device with a couple straightforward examples. But you know the login name of the current (or calling) user before we do that, it’s worth mentioning all examples in this tutorial have been tested on CentOS 7.

Linux logname command

As already mentioned in the beginning, the logname command lets. Here’s the syntax of this utility:

logname [OPTION]

And following is how the tool’s man page explains it:

logname - print user´s login name
Print the name of the user that is current

Check out Q&A-styled examples that will provide you with a idea that is good how the logname utility works.

Q1. How to use logname?

Basic usage is very easy – all you have to do is to run ‘logname’ without any arguments.

logname

The command will produce the user that is current login title. As an example, in my own instance, it produced the output that is following******)

tarra9779725351

Q2. Where does logname look for information?

The logname command accesses a system file that is maintainedusually /var/run/utmp or /etc/utmp) to seize the data it creates in production. In the event that demand executes effectively, its exit status is 0, else the status is 1.

Q3. Exactly how is logname distinctive from other commands that are similar

Some of you might argue why is the logname command is even needed when there exist other commands that are similar whoami? Well, there is at-least one difference that is major those commands and logname: it returns the underlying username even when you use it in the sudo mode.

The following screenshot clearly shows other similar commands produce ‘root’ in output when executed in the sudo mode, but logname produces the underlying username even in that case.

How is logname different from other similar commands

Note: To display generic help or version-related information, use the –help and –version command line options.

Conclusion

Logname is a very command that is basic energy – you can comprehend and make use of, with which has no demand line choices. Therefore general, the educational bend is non-existent. To understand more relating to this device, check out its guy web page.

What exactly is TCP/IP?

Previous article

10 Complimentary Mobile Phone UI Kits For Sketch

Next article

You may also like

Comments

Leave a Reply

More in Linux