Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Printing the user and group info Post 303040557 by apmcd47 on Thursday 31st of October 2019 12:59:09 PM
Old 10-31-2019
Code:
mygroup=$(groups $user)
printf "User_name: \"$user\"\nGroup_name: \"%s\"\n" ${mygroup#*:}

You embed the username in the format string in printf. The ${mygroup#*:} strips everything to the left of the ":". Printf will keep repeating until all items in mygroup have been printed.


Andrew
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find all files with group read OR group write OR user write permission

I need to find all the files that have group Read or Write permission or files that have user write permission. This is what I have so far: find . -exec ls -l {} \; | awk '/-...rw..w./ {print $1 " " $3 " " $4 " " $9}' It shows me all files where group read = true, group write = true... (5 Replies)
Discussion started by: shunter63
5 Replies

2. Solaris

Secondary group info source

Experts, I know when I use id it shows only the primary group information for the given user, and that info comes from passwd file. When I use groups it shows all groups user are member of, however from where come information given by groups command? grep fmtt3990 /etc/passwd... (6 Replies)
Discussion started by: fmattos
6 Replies

3. Shell Programming and Scripting

Help on capturing /etc/group info.....!!

Gurus I am trying to capture all the data in /etc/group file in a CSV ,thru a fingerprinting engine. For hosts having ,unique group names and Ids ,following code works fine. Trouble starts when on a host,there are multiple groups defined with same name and id. e.g One of my hosts has 8... (10 Replies)
Discussion started by: ak835
10 Replies

4. Shell Programming and Scripting

Update LDIF User info based on Test User Certs ID's

Hi I need help.......... I have an Sun One Directory server LDIF file with 5000 user entries, I need to change the data to match Test ID's, so I can run a perf test. I'm way out of my league as I have not done any scripting for 10 years. There are four entries for each user in the file... (3 Replies)
Discussion started by: Macdaddy99
3 Replies

5. Ubuntu

Create New User with the same group nd privileges of the other user

Hi, Anyone can help me on how to duplicate privileges and group for useroradb01 to userrootdb01. I have currently using "useroradb01" and create a newly user "userrootdb01". I want both in the sames privileges and group. Please see the existing users list below; drwxr-xr-x 53 useroradb01... (0 Replies)
Discussion started by: fspalero
0 Replies

6. Shell Programming and Scripting

need a one liner to grep a group info from /etc/group and use that result to search passwd file

/etc/group tiadm::345:mk789,po312,jo343,ju454,ko453,yx879,iy345,hn453 bin::2:root,daemon sys::3:root,bin,adm adm::4:root,daemon uucp::5:root /etc/passwd mk789:x:234:1::/export/home/dummy:/bin/sh po312:x:234:1::/export/home/dummy:/bin/sh ju454:x:234:1::/export/home/dummy:/bin/sh... (6 Replies)
Discussion started by: chidori
6 Replies

7. Red Hat

Samba/Winbind issue - Can't get user and group info from sub domains

Hi, We now have a Samba or Winbind issue. The Linux client under RHEL6 can not get Windows' AD sub-domain info. See the following output please. The main domain 'Global' is shown online, but the sub-domain 'Europe' and 'Asia' are shown offline although they are online. Commands 'wbinfo -u' and... (0 Replies)
Discussion started by: aixlover
0 Replies

8. Red Hat

User is a Part of a Group But Group Details Do Not Show the User

Hi, In the following output you can see the the user "richard" is a member on the team/group "developers": # id richard uid=10247(richard) gid=100361(developers) groups=100361(developers),10053(testers) but in the following details of the said group (developers), the said user... (3 Replies)
Discussion started by: indiansoil
3 Replies

9. Shell Programming and Scripting

Printing more info than find command gives out

Hi, I am trying to find files that are more than a gig with this command find . -size +1073741823c and it just gives me the names of the files. How do i get it to give me the actual size of the files too? ---------- Post updated at 09:41 AM ---------- Previous update was at 09:37 AM... (2 Replies)
Discussion started by: LilyClaro
2 Replies
getacl(1)						      General Commands Manual							 getacl(1)

NAME
getacl - Displays the specified access control list (ACL) on a file of directory SYNOPSIS
getacl [-d|-D] [-g group[,group...]] [-n] [-m] [-u user[,user...]] file... FLAGS
Displays the default access ACL instead of the access ACL. Valid for directories only. The -d and -D options are mutually exclusive. [Tru64 UNIX] Displays the default directory ACL instead of the access ACL. Valid for directories only. The -d and -D options are mutu- ally exclusive. [Tru64 UNIX] Display the entries for the designated group names or GIDs only. If a numeric group name exists in the group database, then the entry for that group is displayed, not the entry for the GID. For example if there is a group name "521" with GID 40, a group name "mygroup" with GID 521, and you request the entry using the -g 521 flag then the entry for the group name "521" is dis- played, not the entry for the group name "mygroup". The -g flag is not defined by POSIX. [Tru64 UNIX] Display the output in multi- columns. The -m flag is not defined by POSIX. [Tru64 UNIX] Display numeric IDs. The -n flag is not defined by POSIX. [Tru64 UNIX] Display the entries for the designated user names and UIDs only. If a numeric user name exists in the user database, then the entry for that user is displayed, not the entry for the UID. For example if there is a user name "39456" with UID 420, a user name "fred" with UID 39456, and you request the entry using the -u 39456 flag then the entry for user name "39456" is displayed, not the entry for user name "fred". The -u flag may be used multiple times on the command line. DESCRIPTION
This command is based on Draft 13 of the POSIX P1003.6 standard. The getacl command displays the selected type of ACL for each file or directory named on the command line. The following three types of ACLs may be displayed: Access ACL Used to control access to a file or directory. Default directory ACL Used to specify ACLs inherited by new subdirectories in a directory. Valid on directories only. Default access ACL Used to specify ACLs inheried by new subdirectories and files in a directory. Valid on directories only. For more nformation on the types of ACLs see the acl(4) reference page and the Security guide. If the access ACL is selected for display, and there is no access ACL, the getacl command displays the permission bits in ACL format. If a default ACL is selected for display, and the selected default ACL doesn't exist on the specified directory, only the ACL header will be displayed. The user readable format of the ACL consists of the ACL header section and the entries section. The ACL header section contains, at a min- imum, the following three lines: name of the object object owner group owner It may also contain blank comment lines or warning messages. Each line of the ACL header section begins with a # character. The ACL entries section by default consists of one line per entry. Each line contains three colon-separated fields defined as: The ACL entry tag type (user/group/other). The ACL entry tag qualifier. This is the name or id that this entry pertains to. If this field is empty the entry refers to the owning user, owning group or other. The access being granted by the entry. The output display format and relative ordering of ACL entries is as follows: user::perm user:uid1:perm user:uid2:perm group::perm group:gid1:perm group:gid2:perm other::perm The following are some typical getacl outputs: % getacl /ufs/test # # file: /ufs/test # owner: root # group: system # user::rwx user:fran:-wx user:adm:r-- group::r-x other::r-x % getacl -g adm /ufs/test # # file: /ufs/test # owner: root # group: system # % getacl -u adm /ufs/test # # file: /ufs/test # owner: root # group: system # user:adm:r-- If any ACL entry is wider than the screen, the access control list is continued on the next line, indented to the previous line. The width of the screen is taken from the COLUMNS environment variable, if the variable is not set, the default width is 80 columns. The -m option may be used to cause the ACL to be displayed in a multicolumn format. The user entries defined in the ACL are placed on the screen in the maximum number of columns allowed by the current size of the screen, followed by the group entries. The output from the getacl command is in the correct format for input to the setacl command. The output may be redirected into a file, then the output file can be used as input to the setacl command. This technique is useful for assigning the ACL on an existing file to one or more new files. For example: $ getacl file1 > entries_file $ setacl -U entries_file file2 file3 file4 The getacl command displays the access control lists of those files that resides in directories that the user has search permissions to. ACLs may be set on files and directories if ACLs are disabled on the system, but ACL access checks and ACL inheritance won't take place. The getacl command will print a warning if ACLs are disabled on the system. Not all types of filesystems support ACLs. The getacl command will print a warning if ACLs are not supported on the filesystem. EXIT VALUES
If successful, the getacl command exits with a status of zero. Otherwise, this command exits with a status of 1 if it aborted because of syntax errors, or if the ACL of one or more files could not be accessed. RELATED INFORMATION
Commands: setacl(1) Files: acl(4). Security delim off getacl(1)
All times are GMT -4. The time now is 09:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy