Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am trying to get the username of the person who modified a specific file:

stat -c "%u"

this script returns a number like 544

what does that mean? i was hoping to get the username like myUsername?

share|improve this question

2 Answers 2

You get the numerical userid from this commmand (edit: the userid of the owner, not the user who last modified the file). To get the related username, try getent passwd 544 (I have no idea if that works like this on Cygwin).

You can try to combine these commands:

getent passwd $(stat -c "%u"
share|improve this answer
thanks! i did man getent, but it doesnt have this. would there be a way to do this on one line instead of having to do the stat etc and then getent? i need to do a count of how many files every user modified – IIIIIllllllllIlllllIIIIIIIIlll Feb 1 '13 at 18:09
@АртёмЦарионов I just edited the combination command before receiving your comment :) – Sven Feb 1 '13 at 18:11
-bash: getent: command not found – IIIIIllllllllIlllllIIIIIIIIlll Feb 1 '13 at 18:11
@АртёмЦарионов: You don't get the information you want this way anyway, as I just realized. It shows the owner of a file, not who last modifed it. – Sven Feb 1 '13 at 18:18
oh i see! owner = person who created? – IIIIIllllllllIlllllIIIIIIIIlll Feb 1 '13 at 18:18

It is the ID of the user. Issue:

awk -F: '{if ($3 == "544") print $1;}' /etc/passwd

to see the account name.

Now, you'll see Administrators, which probably isn't very helpful for you, but that's how Cygwin sees the owner.

See and especially chapter Example 3.3. /etc/passwd there for more information.

share|improve this answer
This is cygwin, on Windows. – Sven Feb 1 '13 at 18:17
interesting! here's what i did $ grep $(stat -c "%u" woodland\ terrace.lnk) /etc/passwd SYSTEM:*:18:544:,S-1-5-18:: LocalService:*:19:544:U-NT AUTHORITY\LocalService,S-1-5-19:: NetworkService:*:20:544:U-NT AUTHORITY\NetworkService,S-1-5-20:: Administrators:*:544:544:,S-1-5-32-544:: – IIIIIllllllllIlllllIIIIIIIIlll Feb 1 '13 at 18:17
which one would be the username here? – IIIIIllllllllIlllllIIIIIIIIlll Feb 1 '13 at 18:17
Edited my answer. – grassroot Feb 2 '13 at 6:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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