Sunday, May 5, 2024
33
rated 0 times [  33] [ 0]  / answers: 1 / hits: 135191  / 1 Year ago, fri, january 27, 2023, 2:09:47

How can I list all users along with their UIDs? I want to do this from the terminal.


More From » command-line

 Answers
3

List all users with a /home folder:



awk -F: '//home/ {printf "%s:%s
",$1,$3}' /etc/passwd


or all users with a UID >= 1000:



awk -F: '($3 >= 1000) {printf "%s:%s
",$1,$3}' /etc/passwd


a combination



awk -F: '//home/ && ($3 >= 1000) {printf "%s:%s
",$1,$3}' /etc/passwd


or for all entries



awk -F: '{printf "%s:%s
",$1,$3}' /etc/passwd


More information here


[#19203] Saturday, January 28, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tersle

Total Points: 342
Total Questions: 109
Total Answers: 99

Location: Kazakhstan
Member since Mon, Sep 26, 2022
2 Years ago
;