Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's 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'm trying to currently figure out the number of users using /bin/bash as their shell to login into the crux. I think I have the right command, but I'm not entirely sure. I was hoping someone could look at the two different commands I have and let me know if it's correct or possibly point me into a direction?
The first command I figured out (or I think so) is this one:
Code:
$ cat /etc/passwd | grep -c "/bin/bash"
4314
Then I have another version of that command that I put together which was:
Code:
$ grep -c "bin/bash" /etc/passwd
4314
As you can see they both come out with the same amount. But I guess what I'm trying to figure out is if that is getting what I'm trying to figure out, which is the number of users who use /bin/bash as their login shell in crux. I think both work correctly since both commands give me the same amount, but I guess I'm a little weary of it because I'm not sure if it's giving me the number of users who use /bin/bash as their login shell.
Thanks Dave. Now I'm stuck on something else. I'm working on pretty much the samething, but now I'm trying to figure out what the second most commonly used shell program in crux is. I figured using the same command would work by adding a * at the end of /bin/bash/* but that doesn't work. It just gives me a 0. Like this:
Code:
$ grep -c "/bin/bash/*" /etc/passwd
0
Not sure what I'm doing wrong. Maybe I'm not using the right command. Hmm, lol
Thanks Dave. Now I'm stuck on something else. I'm working on pretty much the samething, but now I'm trying to figure out what the second most commonly used shell program in crux is. I figured using the same command would work by adding a * at the end of /bin/bash/* but that doesn't work. It just gives me a 0. Like this:
Code:
$ grep -c "/bin/bash/*" /etc/passwd
0
Not sure what I'm doing wrong. Maybe I'm not using the right command. Hmm, lol
How is /bin/bash/* going to match any other shells? If you want to count all entries without bash, use grep's -v option. Otherwise, just change /bin/bash to a different shell like tcsh.
I don't know. I'm getting kind of frustrated because I've been at this all day now, and I just can't figure it out. I guess all I wanted to do was see what the second commonly used shell is that users use to login too. But I'm not exactly sure. lol I figured the grep command that I used would tell me but apparently not.
I did try:
Code:
$ grep -vc /bin/bash /etc/passwd
38
and got 38, but that doesn't tell me what shell. I'm about to pull my hair, does anyone ever do that when they are unable to figure something out in linux? LOL
which listed off the shells that we were able to use, which was very helpful. I then went on to checking each one with the
Code:
$ grep -c "/bin/bash" /etc/passwd
which gave me the numbers, then I just changed the "/bin/bash" to the other shell names and got the answer. The shell that is the second commonly used shell is /sbin/nologin which was 34.
Thanks again, I appreciate you helping me with this one. I believe I got what I was looking for. HE HE!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.