Equivalent Command for "members" in RHEL [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
I have requirement to check members of the group "wheel" periodically.
I see that 'members wheel' is expected to display the members of that group. However when i tried, it says command not found. I see no entries in the man page as well.
I am using RHEL - Linux Version 3.10 (Red Hat 4.8.5)
I know we can use awk and cat in combination to get these details from "/etc/group" file
But is there a straight forward or a better approach?

This is an answered question from Linux admin.
In short the answer is:
I prefer to use the getent command ...
Since getent uses the same name service as the system, getent will show all information, including that gained from network information sources such as LDAP.
So for a group, you should use the following ...
getent group name_of_group
where name_of_group is replaced with the group you want to look up.
Note that this only returns supplementary group memberships, it
doesn't include the users who have this group as their primary group.
There are a whole lot of other lookups that you can do ... passwd
being another useful one, which you'll need to list primary groups.

Related

Why do shells look different for different users? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I have a server in which there are 2 users: root and bob while I am logged in as root, everything look normal. Files are colored according to type, I can press up and down to search for previous typed commands, and I can see the current folder name in the shell prompt.
Being logged in as user bob everything seems "weird", nothing is colored, pressing up and down give me weird characters in the command line like "^[[A^[[B" and I can only see the character "$" in the command line prompt.
Is there a way to fix the issue?
Two possible features could be causing this.
The first: your two users could be using different terminals (i.e. bash, busybox, etc.)
You can change this per user in the /etc/passwd file
The second comes down to preferences, typically stored in ~/.profile, ~/.bash_rc and ~/.bash_profile. ("~" refers to the home directory for that user, also found in /etc/passwd file, typically "/home/USERNAME").

Are files in UNIX always owned by an owner and a group? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
For example, when I use ls -l | awk '{print $3, $4 }' on my file/folder, I see my username appearing twice.
Does that mean that all files are owned by one user and one group, which that one group is me? But how can the user also be a group? Why does my name appear twice?
Is a file always owned by one group and a user, or is there really only 1 user all along?
Files in Unix systems are always owned by 1 user, and 1 group. In this case, the user name happens to match the name given to the group. You can check out the user and group names at /etc/passwd and /etc/group.

How to permit securely Bob to read some file in /var/log/? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
this is my first question here.
I'm using a Centos server.
I want to know how to permit proprely a non-sudoer user (let's call it Bob) to read a specific file in /var/log. I want to be able to read some logs without being root and without jeoparadizing my logfile.
For the moment,
I created a group named "loggers"
I added Bob to the group
I made a chgrp for the file I want to read with Bob
I changed file permissions from 600 to 640.
Is there any better (secure) way to make the same thing ?
If you're happy with a special group, then that is the way to do it. The alternative is to use ACLs, which are additive to standard unix permissions. You'd return your logfile to its original unix permissions then permit Bob with something like
setfacl -m user:Bob:r-- /var/log/mylogfile.log
There are circumstances where ACLs are unfavorable, in particular where you have file backup/migration across servers or filesystems. However, this isn't the case for your scenario.

Is there a script to determine linux user name? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I am looking for some code to get the linux username.. I have come across code to get current username but what I need to get is the username that was used when installing linux..
For example, if im logged in as root user, how can i get the initial username that was used when installing ubuntu?
Better still, Is there a variable that I can put in my script that will search & store install username..
you can use fact, that default uid and gid for first created user is 1000:
grep 1000:1000: /etc/passwd|cut -f1 -d':'
but keep in mind:
when default user was deleted, you get empty string
if it running on non standard configuration, uid, and gid may be different
this is not good practise (see next point)
you ate not considering multi-seat configurations, when station have many users, you should provide user config file, where user can put usernames he wants to processed or do it from command line

Linux /etc/group and /etc/passwd don't match? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
I have a group named "www" (GID=997), which has users mydata, adb and root.
If I use $groups mydata or $groups adb, it shows mydata : www. Also in /etc/passwd file, I can see mydata:x:2001:997: and adb:x:2003:997:.
But in /etc/group file, it show www:!:997:root.
First, I don't understand why this www group only shows the user root, not followed by other users in this group. I think in the group file there should be something like www:!:997:root,mydata,adb
Second, what does "!" mean here? I know that if it shows x (www:x:997:...) then it means the group has a password. But I can't find out the explanation for "!" .
Each user has one primary group, and can have multiple secondary groups.
The primary group is the one whichs group id is in the passwd file, in the group file you have the information to which secondary groups the user belongs. It would be possible to add the user's primary group to it's seccondary groups, but that's redundant.
The ! in the groups file is used to indicate that the group has no password set for grouplogin. You can find that informatoin in the manpage for gshadow, as it is more common to have an x in the password field in the groups file, indicating that the password information should be taken from /etc/gshadow instead.

Resources