Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we get list of non-system users on linux?

Considering that all users with id >= 1000 are non-system users, how can we get list of these users in a single command?

like image 582
user2436428 Avatar asked Oct 15 '15 13:10

user2436428


1 Answers

You need to get all users whose gid is greater than or equals 1000. Use this command for that:

awk -F: '($3>=1000)&&($1!="nobody"){print $1}' /etc/passwd

If you want system users (gid<1000) it will be:

awk -F: '($3<1000){print $1}' /etc/passwd
like image 199
Diogo Rocha Avatar answered Oct 22 '22 15:10

Diogo Rocha