How to find active users in Ubuntu?

With help of the who command we can get active users, I want only the first field such as

user 1
user 2
user 3

Solution 1:

You can get just the user names like so:

who | awk '{print $1}' | sort 

Where who lists all logged in users, passes the output to awk which only prints the first section ("column") of text for every line, passes it to sort which sorts the output.