Get the gid from a group name


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Get the gid from a group name
# 8  
Old 04-17-2010
Thanks all for your replies.

@jim mcnamara: vbe is right, I wanted the GID of a given group.

@hergp: your command works on my system but I don't think
Code:
getent group adm | cut -d: -f3

is far more efficient than
Code:
grep '^adm:' /etc/group | cut -d: -f3

@vbe: Thanks for pointing out the non portability. I'd modify your code like this:
Code:
grep "^$1:" /etc/group | cut -d: -f3

to avoid greping groups whose names start with the same string.

Thanks again to all of you.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

UID & GID instead of user name and group name

Hi Everyone, We are encountering the following issue on AIX 5.3. When we do ls -ltr the list displays only user id and group id instead of user name and group name. This is happening for all users except root. Whe we do ls -ltr with root user it shows perfectly fine. When we searched... (25 Replies)
Discussion started by: madhav.kunapa
25 Replies

2. UNIX for Dummies Questions & Answers

Conflicting GID in group and passwd files.

Hi guys, I have a question. In the passwd file, user johndoe has a GID of 100 which is the group named users in the group file. But if you check the group file, johndoe is not listed under GID 100, but under GID 33, which is the group named videos. Under what group does johndoe really belong,... (1 Reply)
Discussion started by: goldenlight1814
1 Replies

3. UNIX for Dummies Questions & Answers

uid ,gid value change

Present /home/dsadm# id dsadm uid=0(root) gid=0(root) ---------------------------------- needs to be /home/dsadm> id dsadm uid=23186(dsadm) gid=16284(gdstage) Please provide the command/steps for the above uid, gid value change Thanks in advance for all your support . ... (3 Replies)
Discussion started by: sridhardwh
3 Replies

4. Shell Programming and Scripting

changing uid,gid

Hi, I am new to scrippting need little help, I would like to change uid, gid of exisisting user, example User A current uid=1,gid=2 would like to change uid=4,gid=5 I know the command to change uid,gid but after changing I have to change permissions on folders also which are belonging... (3 Replies)
Discussion started by: manoj.solaris
3 Replies

5. 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

6. AIX

Gid=0 and 7 + admin=FALSE

Checking configuration access files for an AIX server, left me wondering about this :confused:: If a user is added to system group, it gets gid=0 with some security risks because it gets some root kind of file access level. Is this insecure condition kept if the user has admin variable... (0 Replies)
Discussion started by: bkiddo
0 Replies

7. 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

8. UNIX for Advanced & Expert Users

GID & UID for HP-UX ?

Hi, can somebody tell me how to make directoriy in which all files will be generated as dir owner ? I'm able to add GID for directory group and files have group id like folder , but when i do same for user files still are created as user which creates them :( drwsrwsrwx 2 flexbul ... (2 Replies)
Discussion started by: pp56825
2 Replies

9. Shell Programming and Scripting

Rsync - Preserve owner/group with different UID/GID

Dear Folks :-) I want to rsync some files between some servers and preserve files owner and group (not UID or GID), in some machines UID and GID are differents, for example: a) In the rsync server: # stat vbseo.php File: `vbseo.php' Size: 26758 Blocks: 56 IO... (1 Reply)
Discussion started by: Santi
1 Replies

10. Shell Programming and Scripting

Changing userID and Changing group and GID

Hello, I want to write a ksh script about changing UID and changing group with GID. There are multiple servers i want to perform that job. linux1 linux2 linux3 linux4 linux5 ...... . . . . . 1.) How can i enter "password" in script rather asking me? I was trying this... ssh... (2 Replies)
Discussion started by: deal732
2 Replies
Login or Register to Ask a Question
really(8)						      System Manager's Manual							 really(8)

NAME
really - gain privilege or run commands a different user SYNOPSIS
really [options] [command args... ] DESCRIPTION
really checks whether the caller is allowed, and if it is it changes its uids and gids according to the command line options and executes the specified command. If no options are specified, the uid will be set to 0 and the gids will be left unchanged. If no command is specified, really will run $SHELL -i. A caller is allowed if it has write access to /etc/inittab. This is most easily achieved by creating or using a suitable group, containing all the appropriate users, and making /etc/inittab group-owned by that group and group-writeable. OPTIONS
-u username | --user username Sets the uid, gid, and supplementary group list, according to username's entry in the password and group databases. -i username | --useronly username Sets only the uid according to username's entry in the password database. -I uid | --uidonly uid Sets the uid to the numeric value uid (which need not correspond to any existing user in the password database). -g groupname | --group groupname groupname is looked up in the group database and its gid is appended to the process's supplementary groups list. If this is the first gid specified it will also be set as the primary gid. -G gid | --gid gid gid is appended to the process's supplementary groups list. (gid need not correspond to any existing group in the group database.) If this is the first gid specified it will also be set as the primary gid. -z | --groupsclear Clears the process's supplementary groups list. When using this option you must also specify -g or -G. The process's groups will then be exactly those specified. The relative position of -z in the argument list is not relevant. -- Indicates the end of the options. The next argument (if present) will be interpreted as the command name, even if it starts with a hyphen. SECURITY CONSIDERATIONS
really is designed so that installing it setuid root is extremely unlikely to compromise the security of any system. It will check using access(2) whether the real user is allowed to write to /etc/inittab and if this check fails really will exit without even attempting to parse its command line. really is not designed to be resistant to malicious command line arguments. Do not allow untrusted processes to pass options to really, or to specify the command to be run. Whether it is safe to allow relatively untrusted processes to pass options to the command which is to be run depends on the behaviour of that command and its security status. Attempting to use really to drop privilege is dangerous unless the calling environment is very well understood. There are many inherited process properties and resources which might be used by the callee to escalate its privilege to that of the (root-equivalent) caller. For this function, it is usually better to use userv if possible. ENVIRONMENT
really does not manipulate the environment at all. The calling program is run in exactly the same environment as the caller passes to really. In particular, really will not add sbin directories to PATH so really-enabled accounts will usually need to have these directories on their configured PATH to start with. SHELL is used to find the default shell to use in interactive mode (ie, when no command is specified). AUTHOR
This version of really was written by Ian Jackson <ian@chiark.greenend.org.uk>. It and this manpage are Copyright (C) 1992-5,2003 Ian Jackson <ian@chiark.greenend.org.uk>. really is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. really is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this file; if not, consult the Free Software Foundation's web- site at www.fsf.org, or the GNU Project website at www.gnu.org. AVAILABILITY
really is currently part of chiark-utils and is available for download from ftp.chiark.greenend.org.uk in /users/ian/chiark-utils/, in source and pre-compiled binary form, and also from Ian Jackson's cvsweb. SEE ALSO
userv(1), access(2), setresuid(2), setresgid(2), setgroups(2) chiark-backup 2001-10-21 really(8)