Linux lid (libuser-lid) Command Examples

lid command

I am a new Linux and Unix system user. How do I list the user’s groups or group’s users on Linux operating systems? How can I show list of users belonging to a given group on Linux based server?

You need to use the lid (list ID) command to show information about groups containing user name, or users contained in group name at a shell prompt. This command is just like groups command which [donotprint]

lid/libuser-lid command details
DescriptionShows users belonging
to a given group.
CategoryN/A
DifficultyEasy
Root privilegesYes
Estimated completion time1m
Contents
[/donotprint]list a user’s group memberships or members command which outputs members of a group on Linux operating system. This command may not be available on other Unix-like operating systems.

ADVERTISEMENTS

Purpose

Displays the group that a given user belongs to on Linux operating systems.

Syntax

The basic syntax is as follows:

lid userNameHere
libuser-lid userNameHere

OR

lid [options] userNameHere
libuser-lid [options] userNameHere

This command must be run with superuser privileges other wise you will get an error that read as follows:

No user name specified, using nixcraft.
Error initializing libuser: not executing with superuser privileges.

Warning: On Debian and Ubuntu Linux based system you need to use the apt-get command/apt command to install lid command
sudo apt-get install libuser
On a newer system the lid command renamed as libuser-lid

Linux lid (libuser-lid) Command Examples

If you skip user name on command line, lid lists information about the invoking user (also know as the current user). Just type the following command:
$ sudo lid
OR
# lid
Sample outputs:

Fig. 01: lid command in action

Fig. 01: lid command in action

By default lid displays groups containing the invoking user if user-name is not specified on command line.

How do I list users in a group name?

To Show users in a group, enter:
# lid -g {groupNameHere}
#libuser-lid -g {groupNameHere}

To see users of members of ‘webmaster’ group, enter:
# lid -g webmaster
# libuser-lid -g webmaster

Sample outputs:

 webadmin(uid=1014)
 raj(uid=1001)
 vivek(uid=1002)
 archana(uid=1003)
 sai(uid=1004)
 sayali(uid=1005)

How do I hide GID/UID?

By default the user IDs (UID) or group IDs (GID) are displayed by lid command. To hide UID/GID pass the -n option:
# lid -n {name}
# lid -n nixcraft
# lid -n -g webmaster
# libuser-lid -n {name}
# libuser-lid -n nixcraft
# libuser-lid -n -g webmaster

Sample outputs:

 webadmin
 raj
 vivek
 archana
 sai
 sayali

lid command options

From the lid(1) command man page:

OptionsDescription
-i
--interactive
Prompt for all information.
-g
--group
List members of a named group instead of the group memberships for the named user.
-n
--onlynames
Only list membership information by name, and not UID/GID.
-?
--help
Show this help message on screen.
--usageDisplay brief usage message.
See also
  • /etc/group file.
  • lid(1) Linux/Unix command man page
CategoryList of Unix and Linux commands
File Managementcat
Network Utilitiesdighostip
Package Managerapkapt
Processes Managementbgchrootdisownfgjobskillkillallpwdxtimepidofpstree
Searchingwhereiswhich
User Informationidgroupslastlastcommlognameuserswwhowhoamilid/libuser-lidmembers

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
1 comment… add one
  • aref ghobadi Aug 16, 2015 @ 16:19

    Hi
    id command : print the user and group id

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.