{"id":408,"date":"2018-01-08T09:12:35","date_gmt":"2018-01-08T09:12:35","guid":{"rendered":"https:\/\/mellowhost.com\/blog\/?p=408"},"modified":"2018-01-08T09:12:35","modified_gmt":"2018-01-08T09:12:35","slug":"how-to-get-username-from-uid-vice-versa-in-linux","status":"publish","type":"post","link":"https:\/\/mellowhost.com\/blog\/how-to-get-username-from-uid-vice-versa-in-linux.html","title":{"rendered":"How To: Get Username from UID &#038; Vice Versa in Linux"},"content":{"rendered":"<h4>Question:<\/h4>\n<p>I have an UID, how do I get the username belongs to this UID in Linux?<\/p>\n<h4>How to Get UID from USERNAME in Linux<\/h4>\n<p>We usually know, there is a dedicated command called &#8216;id&#8217; in linux given to find UID from username is called &#8216;<code>id<\/code>&#8216;<\/p>\n<p>You can use that to get the UID from the username in linux:<\/p>\n<p><code># id -u root<br \/>\n0<\/code><\/p>\n<h4>How to get Username from UID in Linux<\/h4>\n<p>Although, there is no built in command get fetch the username from the UID. We can use a pipe and regular expression match on getent to do that.<\/p>\n<blockquote><p><b>getent<\/b>\u00a0is a unix command that helps a user get entries in a number of important text files called databases. This includes the passwd and group databases which store user information \u2013 hence\u00a0<b>getent<\/b>\u00a0is a common way to look up user details on Unix.<\/p><\/blockquote>\n<p>You can use the following command to find username of the UID 752 for example in a system:<\/p>\n<p><code># getent passwd \"752\"|cut -d: -f1<br \/>\ntexstard<\/code><\/p>\n<p>getent can take group database too, although, we have used passwd database as that contains the UID of the respective linux user.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Question: I have an UID, how do I get the username belongs to this UID in Linux? How to Get UID from USERNAME in Linux We usually know, there is a dedicated command called &#8216;id&#8217; in linux given to find UID from username is called &#8216;id&#8216; You can use that to get the UID from &hellip; <a href=\"https:\/\/mellowhost.com\/blog\/how-to-get-username-from-uid-vice-versa-in-linux.html\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How To: Get Username from UID &#038; Vice Versa in Linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[193,180,12,191,21,150,25,192],"tags":[230,231,70,229],"_links":{"self":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/408"}],"collection":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/comments?post=408"}],"version-history":[{"count":1,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/408\/revisions"}],"predecessor-version":[{"id":409,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/408\/revisions\/409"}],"wp:attachment":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/media?parent=408"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/categories?post=408"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/tags?post=408"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}