4

How can I get groups, permissions, shell, etc from a desired user from command line?

There is a tool to obtain all basic data for each user?

1 Answer 1

4

I don't think there is a single unified command for this.

For most things, you can use the finger command:

$ finger $USER
Login: root                             Name: root
Directory: /root                        Shell: /bin/bash
On since Thu Jan 15 13:46 (IST) on tty1    19 days 18 hours idle
Last login Tue Feb  3 20:55 (IST) on pts/5 from localhost
No mail.
No Plan.

You get the username, home directory, shell, count of unread mails, and last login details.

To list groups, either groups or id will do:

$ groups
muru adm cdrom sudo dip plugdev lpadmin sambashare debian-tor libvirtd autopilot socks
$ id 
uid=1000(muru) gid=1000(muru) groups=1000(muru),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),108(lpadmin),124(sambashare),127(debian-tor),132(libvirtd),136(autopilot),999(socks)

Permissions, of course, depend on what they are for. For sudo, use sudo -l:

$ sudo -l
[sudo] password for muru: 
Matching Defaults entries for muru on ica:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin

User muru may run the following commands on ica:
    (ALL : ALL) ALL

With PolKit it's a lot tougher, pkcheck can assess whether an individual process can use some privilege, but I couldn't figure out a way to list all permissions.

1
  • If anyone has correct output on Login: but incorrect on name, they can easily change it by going to "Settings" -> "User" and edit the name using the pencil next to the image. This worked on: "Linux ubuntu 5.11.0-46-generic #51-Ubuntu SMP Thu Jan 6 22:14:29 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux"
    – thanos.a
    Jan 13, 2022 at 21:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .