Linux id command tutorial

The Linux id command can be used to print user identity. For example, we can use Linux id command to check user id (uid), group id (gid) and the current user's effective groups. See Linux id command's usage examples below, which is running in Ubuntu command line interface.

If we want to view the current user's user ID, we can use Linux id command with -uoption. See the command example below:

[email protected]:~$ id -u
1001
[email protected]:~$

If we want to view the current user's effective group ID, we can use Linux id command with -goption. See the command example below:

[email protected]:~$ id -g
1001
[email protected]:~$

If we want to view all the current user's group ID, we can use Linux id command with -Goption. See the command example below:

[email protected]:~$ id -G
1001 4 20 21 24 25 26 29 30 44 46 104 106 108 123 124
[email protected]:~$

We can print a name instead of a number, for user ID, group ID and all groups ID using Linux id command with -n option. See how to run the command with example below:

[email protected]:~$ id -n -u
kucing
[email protected]:~$ id -n -g
kucing
[email protected]:~$ id -n -G
kucing adm dialout fax cdrom floppy tape audio dip video plugdev scanner fuse lpadmin admin sambashare
[email protected]:~$

To view all related user's identity, use Linux id command with -a option such as in the example below:

[email protected]:~$ id -a
uid=1001(kucing) gid=1001(kucing) groups=4(adm),20(dialout),21(fax),24(cdrom),25(floppy),26(tape),29(audio),30(dip),44(video),46(plugdev),
104(scanner),106(fuse),108(lpadmin),123(admin),124(sambashare),1001(kucing)

The result above is the same as Linux id command with no option. See example command below:

[email protected]:~$ id
uid=1001(kucing) gid=1001(kucing) groups=4(adm),20(dialout),21(fax),24(cdrom),25(floppy),26(tape),29(audio),30(dip),44(video),46(plugdev),
104(scanner),106(fuse),108(lpadmin),123(admin),124(sambashare),1001(kucing)

Here is the Linux id command example from Slackware Linux.

The 'id' command displays the current real and effective user and group ID names or values. If the value does not have a corresponding entry in /etc/passwd or /etc/group, the value will be displayed without the corresponding name. The optional -a flag will display the group set on systems which support multiple concurrent group membership.

[email protected]:~$ id
uid=1001(bill) gid=100(users) groups=100(users), 11(floppy), 17(audio), 18(video), 9(cdrom)
[email protected]:~$ id root
uid=0(root) gid=0(root) groups=0(root), 1(bin), 2(daemon), 3(sys), 4(adm), 6(disk), 1(wheel), 11(floppy)
[email protected]:~$

That's all.

Back to Other important Linux basic commands main page.

Add new comment