Just a short command to obtain user name, if you just know uid (may be useful if you are investigating logs that don’t include usernames).
awk -v val={uid comes here} -F ":" '$3==val{print $1}' /etc/passwd
Let’s try to search for username with uid=0:
[root@server ~]# awk -v val=0 -F ":" '$3==val{print $1}' /etc/passwd root