Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List users in Linux

Tags:

linux

unix

How can I list in alphabetical order all users and also for the first 10 users to see user ID info (column 5). I know for the first part of the question that I can use like cat /etc/passwd | cut -d ':' -f1, but how about the second part? should i use "for" or "if" or something like this?

like image 540
Mihaela Cușnir Avatar asked Mar 17 '26 05:03

Mihaela Cușnir


1 Answers

Remove the header with grep and use cut:

cat /etc/passwd | grep -v '^#' | cut -d: -f1,5
like image 119
Timur Shtatland Avatar answered Mar 19 '26 01:03

Timur Shtatland



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!