Sample Header Ad - 728x90

Display consistently the date and time output for the who command

0 votes
2 answers
174 views
If I connect via SSH to my Debian 12 Server from another Linux Server and run the **who -m** command, it displays the following:
test-user    pts/1        2024-01-24 11:13 (xx.xx.xx.xx)
But, if I connect from a Windows 11 computer, via Windows Terminal or using a third-party App to connect to the same Debian 12 Server using the same exact user and run the same **who -m** command, the date/time format display is different.
test-user    pts/0        Jan 24 11:15 (xx.xx.xx.xx)
I am running this line in the */etc/profile* to determine the IP address from the user on every login, but it doesn't work properly as the output is different and those spaces are altering the outcome.
myip=$(who -m | awk '{print substr($5, 2, length($5) - 2)}')
Is there a way to control the date/time output for the **who** command? What could be causing this behavior? _Update_ Running the locale command from: From Linux:
$locale

LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
From Windows 11
$locale

LANG=
LANGUAGE=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=
Just to note that this behavior doesn't seem to happen with all the Linux Servers I connect to. It varies and it's explained in the solution below. As I understood the root cause as per the explanation below, I opted to use the suggestions and they both work for my use case.
Asked by User-xdfr1 STS (3 rep)
Jan 24, 2024, 03:33 PM
Last activity: Jan 26, 2024, 02:49 PM