[LBo] Re: How to let the system display number of users and
groups?
Tim Cruikshank
linux.debian.user at gmail.com
Fri Nov 3 17:26:43 CET 2006
On November 3, 2006 12:00, Jan wrote:
> Tim Cruikshank wrote:
> > On November 3, 2006 09:53, Jan wrote:
> >> Hello class,
> >>
> >> I don't seem to be able to solve two of the questions regarding Chapter
> >> 3. How to let the system display the number of users and groups defined
> >> on the system?
> >>
> >> I tried /etc/passwd and /etc/group, but that seems to be the wrong
> >> approach.
> >>
> >> Can somebody please assist me on that? I am using SUSE 10.1.
> >>
> >> Thanks!
> >>
> >> Jan
> >
> > This is supposed to be a learning exercise, so I'll start with just a
> > hint. Try checking the manpage of cat, or cat --help.
>
> Hi Tim,
>
> Do you mean cat -n passwd and cat -n group? If that's what you meant, I am
> a bit ashamed I didn't think of that. As usual I was digging too deep ;-)
>
> Jan
Close, I was actually referring to cat -b instead of cat -n.
-n numbers all lines including blank ones, whereas -b only numbers non-blank
lines. Since it is possible that /etc/passwd could contain blank lines -n
could give you a false report of the number of users.
Another way to achieve the desired result would be to use wc.
$cat /etc/passwd | wc -l
--
Tim Cruikshank <linux.debian.user at gmail.com>
Linux User #246684
More information about the QnA
mailing list