Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I know if I'm root I can go the the /home folder and see the users there. But I was looking for a command that would list the users/groups in my system even if they are not logged in. I saw a few scripts using awk in order to retrieve the users list from /etc/passwd, but I did not find a command for for just displaying users NOT system users, not sure if it exists.
You could do that be looking at the UID numbers of the users. However, the ranges used for different distros may be different and you will need to find where that is set, in case it was changed.
On Mandrake, user IDs start with 500. On SuSE, they start with 1000. The kernel doesn't care whether a user is a system user or a regular user. You also need to look at the UIDs used for UIDs of users who exist so they can access samba shares but who don't actually have home directories.
You could also take the users in /etc/passwd and check if their password field indicates a password, or if they have a home directory field entry. A system user may have a home directory entry to function as a working directory. A samba user may have a password entry but not a home directory entry.
Also a user could have a remote home directory or have a home directory which doesn't match their user name.
The best way is to filter users by the UID numbers and make sure that you maintain the system so that regular users are within the regular user range. If you have a GUI inteface for adding or changing users values, it probably sorts out system users the same way.
syslog
klog
cupsys
xrgm
ntp
lab3
pc3
sambauser
test
As you can see its listing users such as ntp, cupssys, klog and syslog that I did not create. As jschiwal wrote there are users without a /home directory and they appear using that command. So, users that I created will always be at the /home dir? Thanks for the help...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.