You can modify user data with chfn (e.g. phone, room) but how can you just display that organisational data?
The fn
in chfn
stands for fullname, and the information is stored in the fullname field of the password database - or what man 5 passwd
calls the
· user name or comment field
(it's also commonly referred to as the GECOS field). So you can retrieve it using getent
$ getent passwd testuser
testuser:x:1001:1001:John Doe,101,234-555-1224,689-555-3785:/home/testuser:/bin/sh
If you're using local account management (rather than some kind of distributed management such as NIS or LDAP), the data is stored as plain text in the /etc/passwd
file, and may be accessed directly with cat
or less
or with any of the various text processing tools ex.
$ awk -F: -v user=testuser '$1 == user {print $5}' /etc/passwd
John Doe,101,234-555-1224,689-555-3785
You can also use the finger
command to access it in human readable format:
$ finger -l testuser
Login: testuser Name: John Doe
Directory: /home/testuser Shell: /bin/sh
Office: 101, 234-555-1224 Home Phone: 689-555-3785
Last login Thu Jul 8 14:41 (EDT) on pts/2 from 192.168.1.4
No mail.
No Plan.