Sponsored Content
Top Forums Shell Programming and Scripting Using GID,Secondary ID in useradd command Post 302665269 by jayan_jay on Monday 2nd of July 2012 08:55:04 AM
Old 07-02-2012
Try this for extracting secondary group id ..
Code:
$ secondary_group=$(id -a | tr ' ' '\n' | nawk -F"[(),=]" '/groups=/ {if($0~/\,/){print $5}else{print $2}}')

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Want to create new users without using "useradd" command and user Interaction.

Don't want to use useradd command to create a new user I am doing manual addition of accounts. Actually I am writing a script and I am working on RedHat7.1 system. What I am trying to do is run the script and pass all the values of the username password and group as command line parameters. Now... (2 Replies)
Discussion started by: syedifti
2 Replies

2. UNIX for Dummies Questions & Answers

Who can help me how to add user without 'useradd' command

Can any one tell me if i dun want using 'useradd' command to add new user, it is have any command i can use to add a new user?and any extra step needed for my local environment? (3 Replies)
Discussion started by: foong
3 Replies

3. UNIX for Advanced & Expert Users

To get PID of a command passed to a secondary system

Hi Reqmt: I am working on Sys 1 and passes a command to Sys2 using a utility which has ssh coded in it. Is there any way to get the process id of the command in Sys 2 from my Sys1 ? Note: The utility is not editable, so you cannot get it through it and I am not logged in in Sys2. Thanks... (2 Replies)
Discussion started by: anu_math9
2 Replies

4. UNIX for Dummies Questions & Answers

useradd command

what if useradd ? or useradd * is given as input???? if it wont execute. then what are the values for name shud be avoided like ? * (1 Reply)
Discussion started by: Gopi Krishna P
1 Replies

5. UNIX for Advanced & Expert Users

How get secondary ID. ??

This is one our office BOX Sun Microsystems Inc. SunOS 5.10 Generic January 2005 Kisses% rlogin pebblz01 -l adminID Password: Last login: Sat Feb 14 01:11:36 from Kisses Please enter your own login id and password. Your login: I_rule Your password:xxxxx From the above... (3 Replies)
Discussion started by: dashok.83
3 Replies

6. Solaris

Purpose D option in useradd command

Hi Can any one tell about -D option in the useradd command? Thanks MaroV (3 Replies)
Discussion started by: vr_mari
3 Replies

7. UNIX for Dummies Questions & Answers

Get the gid from a group name

Hi there, One can easily retrieve the uid from a username : id -u $username But how can we easily retrieve the gid from a group name? I mean is there a command without using sed? sed -nr "s/^$groupname:x:(+):.*/\1/p" /etc/group Thanks for your help Santiago (7 Replies)
Discussion started by: chebarbudo
7 Replies

8. UNIX for Advanced & Expert Users

GID mappings cached?

We had a mapping to one UNIX box just fine, the server was changed to another UNIX box and now when mapping drives from Windows box to new UNIX box, we get the old GID associated with our Windows user. When checking on new UNIX box, we see GID of 108, which is what we want, but when we map the... (0 Replies)
Discussion started by: bd4021
0 Replies

9. UNIX for Advanced & Expert Users

Numeric uid and gid in ls -l command

I´m listing the contents of a directory using the command ls -lI get numeric uid and gid for some lines. example: drwxr-xr-x root root 1970-01-01 01:00 sys -rw-r--r-- 501 20 0 2010-08-04 14:54 shutdown.bravo.rc drwxr-x--- 501 20 ... (5 Replies)
Discussion started by: flocki
5 Replies

10. Shell Programming and Scripting

Help with useradd command

Hi, I want to create multiple user in same home directory. Is it possible ? If possible then please tell me how. Thanks in advance. (3 Replies)
Discussion started by: mnmonu
3 Replies
MEMBERS(1)						      General Commands Manual							MEMBERS(1)

NAME
members - outputs members of a group SYNOPSIS
members groupname DESCRIPTION
This manual page documents briefly the members commands. This manual page was written for the Debian GNU/Linux distribution. members is a program that sends a space-separated list of secondary member names to its standard output. OPTIONS
The programs follow the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of options is included below. -a, --all Show all group members on one line. This is the default. -p, --primary Show only primary group members. -s, --secondary Show only secondary group members. -t, --two-lines Send two lines to standard output. First line is primary members, second line is secondary members. NOTE: This always displays two lines, even if there are no members at all. -h, --help Show summary of options. DIAGNOSTICS
Exit status is 0 (i.e. "success") if the group was found, and 1 (i.e., "failure") if the group was not found. Technically, the exit status hinges on the output of getgrnam(3) as follows: if getgrnam(3) returns a null pointer, the exit status is 1, and 0 otherwise. BUGS
I don't know of any! If you find one, please let me know! SEE ALSO
groups(1) AUTHOR
This manual page was written by Jim Lynch <jim@laney.edu>, for the Debian GNU/Linux system (but may be used by others). MEMBERS(1)
All times are GMT -4. The time now is 04:17 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy