{"id":3371,"date":"2018-04-23T17:23:24","date_gmt":"2018-04-23T13:23:24","guid":{"rendered":"https:\/\/www.howtoforge.com\/linux-id-command\/"},"modified":"2018-04-23T17:23:24","modified_gmt":"2018-04-23T13:23:24","slug":"linux-id-command-tutorial-for-beginners-5-examples","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/linux-id-command-tutorial-for-beginners-5-examples\/","title":{"rendered":"Linux id Command Tutorial for Beginners (5 Examples)"},"content":{"rendered":"<p>If you are new to system administration in Linux, you&#8217;ll gradually learn that user management is an important aspect of your work. The Linux command line offers several command-line utilities for this purpose, and one of them is the <strong>id<\/strong>\u00a0command.<\/p>\n<p>In this article, we will discuss the basics of this tool using some easy to understand examples. However, before that, it&#8217;s worth mentioning that all examples in this tutorial have been tested on an Ubuntu 16.04 LTS machine.<\/p>\n<h2 id=\"linux-idnbspcommand\">Linux id\u00a0command<\/h2>\n<p>The id command shows you the real and effective user and group IDs. Following is its syntax:<\/p>\n<p class=\"command\">id [OPTION]&#8230; [USERNAME]<\/p>\n<p>And here&#8217;s how the tool&#8217;s man page explains it:<\/p>\n<pre>Print user and group information for the specified USERNAME, or (when USERNAME omitted) for the current user.<\/pre>\n<p>Following are some Q&amp;A-styled examples that should give you a good idea on how the id command works.<\/p>\n<p><em>In case you aren&#8217;t aware of what real and effective IDs are, read the discussion <a href=\"https:\/\/stackoverflow.com\/questions\/32455684\/difference-between-real-user-id-effective-user-id-and-saved-user-id\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>.<\/em><\/p>\n<h2 id=\"q-how-to-use-id-command\">Q1. How to use id command?<\/h2>\n<p>The basic usage is easy &#8211; all you have to do is to execute &#8216;id&#8217; with the username for which you want to access the information. For example:<\/p>\n<p class=\"command\">id himanshu<\/p>\n<p><a class=\"fancybox\" id=\"img-id-command-basic\" href=\"https:\/\/www.howtoforge.com\/images\/command-tutorial\/big\/id-command-basic.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/04\/linux-id-command-tutorial-for-beginners-5-examples.png\" alt=\"How to use id command?\" width=\"500\" height=\"63\" title=\"\"><\/a><\/p>\n<p>So you can see the output consists of several fields. The first two entries are user and group IDs for &#8216;himanshu&#8217;, while the rest are the groups that the user &#8216;himanshu&#8217; is part of, along with the respective group IDs.<\/p>\n<p>Note that if you don&#8217;t pass any username as an argument to the id command, the tool assumes the current user as the one for which you want the information.<\/p>\n<h2 id=\"q-how-to-make-id-print-only-group-ids\">Q2. How to make id print only group IDs?<\/h2>\n<p>This can be achieved using the -G command line option. For example:<\/p>\n<p class=\"command\">id -G himanshu<\/p>\n<p><a class=\"fancybox\" id=\"img-id-G-option\" href=\"https:\/\/www.howtoforge.com\/images\/command-tutorial\/big\/id-G-option.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/04\/linux-id-command-tutorial-for-beginners-5-examples-1.png\" alt=\"How to make id print only group IDs?\" width=\"388\" height=\"41\" title=\"\"><\/a><\/p>\n<p>So you can see that only group IDs were displayed in the output.<\/p>\n<h2 id=\"q-how-to-make-id-print-only-effective-group-id\">Q3. How to make id print only effective group ID?<\/h2>\n<p>This can be achieved using the -g command line option. For example:<\/p>\n<p class=\"command\">id -g himanshu<\/p>\n<p><a class=\"fancybox\" id=\"img-id-g-option\" href=\"https:\/\/www.howtoforge.com\/images\/command-tutorial\/big\/id-g-option.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/04\/linux-id-command-tutorial-for-beginners-5-examples-2.png\" alt=\"How to make id print only effective group ID\" width=\"390\" height=\"40\" title=\"\"><\/a><\/p>\n<h2 id=\"q-how-to-make-id-print-only-effective-user-id\">Q4. How to make id print only effective user ID?<\/h2>\n<p>Similar to the previous example, this can be achieved using the -u command line option. For example:<\/p>\n<p class=\"command\">id -u himanshu<\/p>\n<p><a class=\"fancybox\" id=\"img-id-u-option\" href=\"https:\/\/www.howtoforge.com\/images\/command-tutorial\/big\/id-u-option.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/04\/linux-id-command-tutorial-for-beginners-5-examples-3.png\" alt=\"How to make id print only effective user ID\" width=\"390\" height=\"35\" title=\"\"><\/a><\/p>\n<h2 id=\"q-how-to-make-id-print-real-ids-instead-of-effective-ids\">Q5. How to make id print real IDs instead of effective IDs?<\/h2>\n<p>To make the id command print real IDs, use the -r command line option. This option can be clubbed with the -u, -g, and -G command line options.<\/p>\n<p>For example:<\/p>\n<p class=\"command\">id -ur himanshu<\/p>\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>The id command is easy to understand and use. The number of command line options it offers is also limited, and we&#8217;ve discussed the majority of them here. Once you are done practicing these, head to the tool&#8217;s <a href=\"https:\/\/linux.die.net\/man\/1\/id\" target=\"_blank\" rel=\"noopener noreferrer\">man page<\/a>\u00a0to learn more about it.<\/p>\n<div>\n<p><b>Share this page:<\/b><\/p>\n<p>\n<a href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Fwww.howtoforge.com%2Flinux-id-command%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/04\/linux-id-command-tutorial-for-beginners-5-examples-4.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fwww.howtoforge.com%2Flinux-id-command%2F&amp;text=Linux+id+Command+Tutorial+for+Beginners+%285+Examples%29&amp;via=howtoforgecom&amp;related=howtoforgecom\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/04\/linux-id-command-tutorial-for-beginners-5-examples-5.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/howtoforgecom\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/04\/linux-id-command-tutorial-for-beginners-5-examples-6.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/plus.google.com\/share?url=https%3A%2F%2Fwww.howtoforge.com%2Flinux-id-command%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/04\/linux-id-command-tutorial-for-beginners-5-examples-7.png\" height=\"20\" alt=\"\" title=\"\"><\/a>\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>If you are new to system administration in Linux, you&#8217;ll gradually learn that user management is an important aspect of your work. The Linux command line offers several command-line utilities for this purpose, and one of them is the id\u00a0command. In this article, we will discuss the basics of this tool using some easy to &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-3371","post","type-post","status-publish","format-standard","hentry","category-36"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/3371","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=3371"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/3371\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=3371"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=3371"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=3371"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}