I am using last command in linux to fetch last loggedin user. But last command shows only 8 characters in the username field. In the below image, username administrator is trimmed to administ.

Is there any other way to get the full name of last logged-in user ?

I tried lastlog too.

enter image description here

3 Answers 3


last -w should do the trick for you. I don't have any long usernames to test this with but the man page suggests it should work.

You can also use last -a to list hostnames as the last field and not truncate them or last -i to display them as IP addresses instead of hostnames.

These are local users to your system so you could grep them out of your /etc/passwd file if the above options don't work. You should only run into problems doing that if you have two users that share the same first 8 characters.

Failing all of that, you could try strings /var/log/wtmp. This data will be somewhat more difficult to interpret but it should contain the full usernames and hostnames.

  • @prasanna time to mark this the correct answers. Dec 31, 2020 at 10:04

Try this,

show all available login since last restart:

last -Fw | grep -E 'Oct ([ 1-9]|1[0-9]|2[0-9]|30)' | grep $(date +"%Y")

  • Aren't you going to explain why we can't live without those greps, and how it helps to work around the 8 character username limitation? Oct 31, 2021 at 5:29

last reads from utmp, and there the username field is limited to 8 characters. So it's better to have username somewhat unique within the first characters.

  • 4
    This is incorrect; while utmp stores only 8 characters, last actually reads from wtmp which can store full domain and user name. last -w is the answer.
    – rymo
    Nov 13, 2013 at 20:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.