<SOLVED> listing all users via commandline......what the hell are all of these users on my machine???? lol

smooth_buddha

Active Member
Credits
0
hey guys so i wanted to list all users on my machine via commandline. I have created 2 users (accounts)on my linux machine. i did my research and used the follwing commands:

cat etc/passwd
or
getent passwd

now iwas expecting a simple list of 2 users maybe with login info (as there is 2 users on my system).

i then get a big list of users. but i only have made 2 users on my machine. i notice a lot of the names on the list are programs like clamav, nvidia, usbmux, syslog and a whole load more.

Is there a way to just isolate the actual usernames and users of my linux machine, in simple list format????

why does linux class some of my programs as users?????? is this to do with the programs requiring system privalagees in order to run such as clamav (anti virus software or nvidia graphics software)????
 


Alexzee

Well-Known Member
Credits
1,116
Here's some more commands that you can run in this article.


I'm not sure why some of the programs are being considered as users. However;
If I had to guess it's because those programs can only be run as the root user.
 

wizardfromoz

Super Moderator
Staff member
Gold Supporter
Credits
1,012
linux for the most part does not distinguish between human users and system users, for example, daemons.

btw that is

Code:
cat /etc/passwd
also an interesting read is

https://linuxacademy.com/guide/12659-understanding-linux-users-and-groups/

and if you take a stroll through our tutorials section, you will find articles from rob on users and groups

Code:
cat /etc/group
and

Code:
groups
i find useful

wizard
 

smooth_buddha

Active Member
Credits
0
I had a litle play with trying to pipe some commmands and i came up with this:

cat /etc/passwd | cut -d ":" -f 1

so i got my temrinal to display just the usernames fields from the /etc/passwd

then created my own alias:

alias usernames='cat /etc/passwd | cut -d ":" -f 1'

now feeling very proud of myself lol!
 

JasKinasis

Well-Known Member
Credits
515
Certain programs and services are given a user ID so that they can own files and directories and securely read/write their data from/to the filesystem.

Typically, the first real user registered on the system is given the user id 1000. Every subsequent user ID is greater than 1000.

Programs and services are usually assigned a user ID that is below 1000.
 

smooth_buddha

Active Member
Credits
0
thanks for that! yeah i just noticed my account is 1000 and i created a another account which read 1001

may i ask what learning resources you used to learn all this knowledge???

is ther a particular book you recommend or course ect????
 

CptCharis

Well-Known Member
Credits
0
Hello @smooth_buddha , I will answer to you as they answered to me when I was new here in this forum.
“There is not a start here point”
You can find outnumber sources about Linux in wed and YouTube videos but the best way to learn is to repeat all of them in your machine.
The only suggestion I can give to you, in order to save time of searching in internet, is to decide what you want to learn.
Are you interested about servers ? Or you are a distro hopper ? Do you want to learn as much as possible CLI commands or you want to learn more about desktop environment? Finally I would like to suggest to you LearnLinuxTV which is a YouTube channel that I really like and this forum here which was very useful to me. You will find very interesting people in this forum they are ready to answer all of your questions.
What ever you will choose, just enjoy it.
 

Vrai

Well-Known Member
Credits
763
@smooth_buddha
I found this script over at https://www.cyberciti.biz/faq/linux-list-users-command/ . It will separately list both System and Normal User Accounts. Handy! I tried it - it works. Not that interesting as I am the only user on this machine though :\
The script:
Bash:
#!/bin/bash
# Name: listusers.bash
# Purpose: List all normal user and system accounts in the system. Tested on RHEL / Debian Linux
# Author: Vivek Gite <www.cyberciti.biz>, under GPL v2.0+
# -----------------------------------------------------------------------------------
_l="/etc/login.defs"
_p="/etc/passwd"
 
## get mini UID limit ##
l=$(grep "^UID_MIN" $_l)
 
## get max UID limit ##
l1=$(grep "^UID_MAX" $_l)
 
## use awk to print if UID >= $MIN and UID <= $MAX and shell is not /sbin/nologin   ##
echo "----------[ Normal User Accounts ]---------------"
awk -F':' -v "min=${l##UID_MIN}" -v "max=${l1##UID_MAX}" '{ if ( $3 >= min && $3 <= max  && $7 != "/sbin/nologin" ) print $0 }' "$_p"
 
 
 
echo ""
echo "----------[ System User Accounts ]---------------"
awk -F':' -v "min=${l##UID_MIN}" -v "max=${l1##UID_MAX}" '{ if ( !($3 >= min && $3 <= max  && $7 != "/sbin/nologin")) print $0 }' "$_p"
 


Members online


Top