Sponsored Content
Top Forums Shell Programming and Scripting Script to list primary group of users Post 302461791 by ygemici on Tuesday 12th of October 2010 09:07:48 AM
Old 10-12-2010
Code:
# x=( $(cat /etc/group | grep ONE | sed 's/.*:\(.*\)/\1/;s/,/ /g;/^$/d') )
# for i in ${x[@]}; do echo $i; done > xgroups && sort -u xgroups | while read -r user ; do echo "$user's primary group -> `id -gn $user`" ; done

This User Gave Thanks to ygemici For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to find All Primary and Secondary Group ID's for a user

Is there any command which can list me all the Group ID's (Primary, Secondary ) assocaited with a single user. Thanks Sanjay (2 Replies)
Discussion started by: sanjay92
2 Replies

2. UNIX for Dummies Questions & Answers

command help, how do i list the users of a group?

What command allows you to display a list of the userids of all the other users in a group, regardless if they are logged in or not? (3 Replies)
Discussion started by: crabtruck
3 Replies

3. Solaris

How do you list users in a solaris group

I need to list all users in a group. This is a large unix site running nis+. (6 Replies)
Discussion started by: gillbates
6 Replies

4. UNIX for Advanced & Expert Users

Change a users primary group after login

When users login, they are directed to menu (aix script). The menu enables the user to choose an environment to work in. Each environment has a different group id. When a user chooses a menu option, I want to change his primary group to that specific environment's group id. Is this at all possible... (3 Replies)
Discussion started by: terrym
3 Replies

5. Shell Programming and Scripting

List ALL users in a Unix Group (Primary and Secondary)

Is there a command or better combination of cmds that will give me the list of Unix users in a particular Unix group whether their primary group is that group in question (information stored in /etc/passwd) or they are in a secondary group (information stored in /etc/group). So far all I got... (5 Replies)
Discussion started by: ckmehta
5 Replies

6. AIX

script for finding all the users with GID 0 ( admin group )

Hi Friends, I am trying to write a script for finding all the users with the GID 0 i.e. Admin users. can you please help me on this. (1 Reply)
Discussion started by: anoopraok
1 Replies

7. Ubuntu

primary group for user

HI I need to know what is the primary group name of a particular user. How to do this ? Maybe with groups cmd ? (first group name in line, is the primary group) thx for help. (2 Replies)
Discussion started by: presul
2 Replies

8. Shell Programming and Scripting

Script to add new users to a group on multiple servers using SSH

Hi Experts, I am new to scripting. We have around 400 Linux servers in our environment. I want to add a new user to a perticular group on all the servers using SSH. Requirements: 1) Need to take the server names from a text file. 2) Login into each server and check whether perticular... (1 Reply)
Discussion started by: Satya1983
1 Replies

9. UNIX for Beginners Questions & Answers

Primary group

Is it possible user without a primary group (3 Replies)
Discussion started by: lobsang
3 Replies

10. HP-UX

Creating a group of users with script

Hi, I have a file with usernames, and the comment section, e.g : Data removed by request of sanchitadutta91, 20 May 2020 I need to add these users into a server. Is it possible to use a script to create the users, together with the comment ? From the commandline to add one user, the... (2 Replies)
Discussion started by: anaigini45
2 Replies
logins(1M)                                                System Administration Commands                                                logins(1M)

NAME
logins - list user and system login information SYNOPSIS
/usr/bin/logins [-admopstux] [-g group...] [-l login_name...] DESCRIPTION
This command displays information on user and system logins known to the system. Contents of the output is controlled by the command options and can include the following: user or system login, user id number, passwd account field value (user name or other information), primary group name, primary group id, multiple group names, multiple group ids, home directory, login shell, and four password aging param- eters. The default information is the following: login id, user id, primary group name, primary group id and the account field value. Out- put is sorted by user id, system logins, followed by user logins. OPTIONS
Options may be used together. If so, any login that matches any criteria are displayed. The following options are supported: -a Add two password expiration fields to the display. The fields show how many days a password can remain unused before it automatically becomes inactive, and the date that the password expires. -d Selects logins with duplicate uids. -g group Selects all users belonging to group, sorted by login. Multiple groups can be specified as a comma-separated list. When the -l and -g options are combined, a user is only listed once, even if the user belongs to more than one of the selected groups. -l login_name...Selects the requested login. Multiple logins can be specified as a comma-separated list. Depending on the nameservice lookup types set in /etc/nsswitch.conf, the information can come from the /etc/passwd and /etc/shadow files and other nameservices. When the -l and -g options are combined, a user is only listed once, even if the user belongs to more than one of the selected groups. -m Displays multiple group membership information. -o Formats output into one line of colon-separated fields. -p Selects logins with no passwords. -s Selects all system logins. -t Sorts output by login instead of by uid. -u Selects all user logins. -x Prints an extended set of information about each selected user. The extended information includes home directory, login shell and password aging information, each displayed on a separate line. The password information consists of password status (PS for password, NP for no password or LK for locked). If the login is passworded, status is followed by the date the password was last changed, the number of days required between changes, and the number of days allowed before a change is required. The password aging information shows the time interval that the user receives a password expiration warning message (when logging on) before the password expires. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
attributes(5) SunOS 5.10 5 Jul 1990 logins(1M)
All times are GMT -4. The time now is 03:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy