Thursday, June 11, 2015

How to show list of users on Lubuntu


In this article i will teach you how to show list of users on lubuntu/ubuntu machine, and of course we are going to use command line, but it's pretty simple i'm sure everybody can do it.

Basically we can find out about users on lubuntu/ubuntu by reading the /etc/passwd file, using simple cat command like this:

cat /etc/passwd

Or you can read using less and more command, like this: 

less /etc/passwd
more /etc/passwd

There are better ways to do this, with more advanced commands, such as the awk command, here's some of them:

awk -F':' '{ print $1}' /etc/passwd
awk -F: '$3 >= 1000 && $1 != "nobody" {print $1}' /etc/passwd
awk -F":" '{ print "Linux_name: " $1 "\t\tFull_Name: " $5 }' /etc/passwd

Also with cut command like this:

cut -d: -f1 /etc/passwd

Besides using /etc/passwd file, we can also use /etc/shadow, but for this one we are going to need root permission (sudo), like this:

sudo awk -F':' '$2 ~ "\$" {print $1}' /etc/shadow

There is one more command that might be useful to find out about users on lubuntu/ubuntu, this command is called lastlog and it doesn't take any parameter to run.

lastlog

As you can see lastlog will output login date and time, very useful to find out which users login on what date and time.

With all those commands, now you should be able to see all users available or existed on your lubuntu/ubuntu machine.

~ cheers ~

No comments:

Post a Comment