Sorting Your Users By Logging Shell They Use


If you wanted to sort the users in your system by the login shell they use, you could use this command: sort -t: +6 /etc/passwd

This is how it works, the option -t: tells sort to use a colon as a field separator — so, in this example, field 0 is the login name, field 1 is the encoded password, field 2 is the user ID number, field 3 is the group ID number, and so on. By this numbering, the login shell is in the sixth field.

As you can see in this example passwd file is sorted by the login shell they use.

2007-12-19-192123_1280x800_scrot

By same method if we want to sort by UID we would use sort -t: +2 /etc/passwd

2007-12-19-192819_1280x800_scrot

… or in alphabetical order: sort -t: +0 /etc/passwd

2007-12-19-193142_1280x800_scrot



Subscribe without commenting


Leave a Reply

Note: Any comments are permitted only because the site owner is letting you post, and any comments will be removed for any reason at the absolute discretion of the site owner.