To get information about Linux users with the shell, give these examples a go.
Get a listing of all /home folders on Linux.
jason@Yog-Sothoth:~/Documents$ sudo gawk -F: '{ print $6 }' /etc/passwd | grep /home /home/syslog /home/jason /home/justin /home/daniel |
Count the number of users on your Linux system.
jason@Yog-Sothoth:~/Documents$ sudo gawk -F: '{ print $1 }' /etc/passwd | wc -l 49 |
Get information about a certain user.
jason@Yog-Sothoth:~/Documents$ finger -lmps mathis Login: mathis Name: Mathis Miles Directory: /home/mathis Shell: /bin/bash Office: 101 Never logged in. No mail. |
List the Linux users that are actually logged in at this moment.
jason@Yog-Sothoth:~/Documents$ users jason |
List all groups your Linux user is a member of.
jason@Yog-Sothoth:~/Documents$ id -Gn jason adm cdrom sudo dip plugdev lpadmin sambashare |
Get the user`s string from the /etc/passwd file with this command.
jason@Yog-Sothoth:~/Documents$ sudo getent passwd mathis [sudo] password for jason: mathis:x:1002:1002:Mathis Miles,101,,:/home/mathis:/bin/bash |