Linux Command to Display Current Login Name
Knowing the present login title is primary for finding out the id of the person who’s presently logged into the system particularly if a number of folks are utilising a single Linux system. For that there are numerous instructions by using which you will discover the presently energetic person within the Linux mint. We will focus on them listed here.
Linux Commands to Display Current Login Name
By default, Linux distribution has the username immediate within the terminal but when the person has modified their title, then try out the beneath instructions to search out the present login title. All we’d like is to open the terminal and monitor the present login title by way of the subsequent instructions:
- who Command
- whoami Command
- $USER Command
- w Command
- logname Command
- lslogins Command
- last Command
- id Command
1: who Command
The who command will monitor the present login title with the date and time. It reads the details from the default file location.
You also can -a flag with the Who command to get the aspect of the present logged in person:
2: whoami Command
Unlike Who the whoami will monitor a rectilineal reply solely the username, so should you solely like to examine the username then execute:
3: $USER Command
Another option to solely get the login title as within the whoami command, execute the $USER command:
4: w Command
The w command delivers the greater details concerning the present energetic person in your system:
Here TTY is the form of the terminal they’re logged in, FROM is the distant host, LOGIN@ is the time of person login, JCPU is the joint CPU time utilized by all processes, PCPU is the CPU time of the present procedure and WHAT is the present procedure
5: id Command
The id command shows the details of person and communities related to unique person:
6: logname Command
The logname command prints the one phrase, solely the title of presently energetic person:
7: final Command
This command prints the listing of customers, final logged in in your system:
8: lslogins Command
It shows the listing of login customers with their final login time and their names, right here -u flag shows solely the person’s details:
Bottom Line
As in Linux, completely different customers can log in to the similar system, and in that case one can monitor their routine. You can discover the present login title by way of completely different instructions within the terminal. In this tutorial, we’ve realized to search out the username with who, whoami, what, w, and lslogins instructions.
Try each command and examine which works most desirable for you.