{"id":14893,"date":"2023-05-07T20:16:46","date_gmt":"2023-05-07T12:16:46","guid":{"rendered":"https:\/\/www.linuxcool.com\/lmlxj"},"modified":"2023-05-07T20:16:46","modified_gmt":"2023-05-07T12:16:46","slug":"lmlxj","status":"publish","type":"post","link":"https:\/\/www.linuxcool.com\/lmlxj","title":{"rendered":"Linux whoami\u547d\u4ee4\u8be6\u89e3"},"content":{"rendered":"<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u5728<a style='color:#0000CC' href='https:\/\/www.linuxprobe.com\/' target='_blank' rel=\"noopener\">Linux<\/a>\u64cd\u4f5c<a style='color:#0000CC' href='https:\/\/www.linuxdown.com\/' target='_blank' rel=\"noopener\">\u7cfb\u7edf<\/a>\u4e2d\uff0cwhoami<a style='color:#0000CC' href='https:\/\/www.linuxcool.com\/' target='_blank' rel=\"noopener\">\u547d\u4ee4<\/a>\u662f\u4e00\u4e2a\u975e\u5e38\u57fa\u7840\u7684\u547d\u4ee4\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u67e5\u770b\u5f53\u524d\u767b\u5f55\u7528\u6237\u7684\u7528\u6237\u540d\u3002\u4f46\u662f\uff0c\u4f60\u662f\u5426\u771f\u6b63\u4e86\u89e3\u5b83\uff1f\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u4ece\u591a\u4e2a\u65b9\u9762\u5bf9whoami\u547d\u4ee4\u8fdb\u884c\u8be6\u7ec6\u5206\u6790\u548c\u8ba8\u8bba\u3002<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'><b>\u4e00\u3001\u57fa\u672c\u7528\u6cd5<\/b><\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>whoami\u547d\u4ee4\u7684\u57fa\u672c\u7528\u6cd5\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u5728\u7ec8\u7aef\u8f93\u5165\u8be5\u547d\u4ee4\u5373\u53ef\u3002\u4f8b\u5982\uff1a<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\n<pre>\n$ whoami\n<\/pre>\n<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u6267\u884c\u8be5\u547d\u4ee4\u540e<strong>linux whoami\u547d\u4ee4<\/strong>\uff0c\u7ec8\u7aef\u4f1a\u8fd4\u56de\u5f53\u524d\u7528\u6237\u7684\u7528\u6237\u540d\u3002\u8fd9\u4e2a\u547d\u4ee4\u770b\u8d77\u6765\u975e\u5e38\u7b80\u5355\uff0c\u4f46\u5b83\u5b9e\u9645\u4e0a\u975e\u5e38\u5b9e\u7528\u3002<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'><b>\u4e8c\u3001\u67e5\u770b\u7528\u6237ID<\/b><\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u9664\u4e86\u53ef\u4ee5\u67e5\u770b\u5f53\u524d\u7528\u6237\u7684\u7528\u6237\u540d\u5916\uff0cwhoami\u547d\u4ee4\u8fd8\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u67e5\u770b\u5f53\u524d\u7528\u6237\u7684ID\u3002\u53ea\u9700\u8981\u5728\u7ec8\u7aef\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\n<pre>\n$ id -u-n\n<\/pre>\n<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u8be5\u547d\u4ee4\u5c06\u8fd4\u56de\u5f53\u524d\u7528\u6237\u7684ID\u3002<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'><b>\u4e09\u3001\u4e0esu\u548csudo\u7ed3\u5408\u4f7f\u7528<\/b><\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u5728Linux\u7cfb\u7edf\u4e2d\u624b\u673alinux\u64cd\u4f5c\u7cfb\u7edf\uff0csu\u548csudo\u662f\u975e\u5e38\u5e38\u7528\u7684\u5207\u6362\u7528\u6237\u8eab\u4efd\u7684\u5de5\u5177\u3002\u800cwhoami\u547d\u4ee4\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u786e\u8ba4\u81ea\u5df1\u5f53\u524d\u6240\u5904\u7684\u7528\u6237\u8eab\u4efd\u3002\u4f8b\u5982<strong>linux whoami\u547d\u4ee4<\/strong>\uff0c\u5728\u4f7f\u7528su\u5207\u6362\u5230root\u7528\u6237\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528whoami\u786e\u8ba4\u81ea\u5df1\u662f\u5426\u5df2\u7ecf\u6210\u529f\u5207\u6362\u5230root\u8d26\u6237\uff1a<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\n<pre>\n$ su\nPassword:\n# whoami\nroot\n<\/pre>\n<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u540c\u6837\uff0c\u5728\u4f7f\u7528sudo\u6267\u884c\u9700\u8981\u7ba1\u7406\u5458\u6743\u9650\u7684\u547d\u4ee4\u65f6\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u4f7f\u7528whoami\u786e\u8ba4\u81ea\u5df1\u5f53\u524d\u6240\u5904\u7684\u7528\u6237\u8eab\u4efd\uff1a<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\n<pre>\n$ sudo whoami\nroot\n<\/pre>\n<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'><b>\u56db\u3001\u4e0eshell\u811a\u672c\u7ed3\u5408\u4f7f\u7528<\/b><\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u5728\u7f16\u5199shell\u811a\u672c\u65f6\uff0c\u6211\u4eec\u53ef\u80fd\u9700\u8981\u6839\u636e\u5f53\u524d\u7528\u6237\u7684\u8eab\u4efd\u6267\u884c\u4e0d\u540c\u7684\u64cd\u4f5c\u3002\u8fd9\u65f6\u5019\uff0cwhoami\u547d\u4ee4\u5c31\u975e\u5e38\u6709\u7528\u4e86\u3002\u4f8b\u5982\uff0c\u6211\u4eec\u53ef\u4ee5\u7f16\u5199\u4e00\u4e2a\u7b80\u5355\u7684\u811a\u672c\u6765\u5224\u65ad\u5f53\u524d\u7528\u6237\u662f\u5426\u4e3aroot\uff1a<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\n<pre>bash\n#!\/bin\/bash\nif [$(whoami)==&quot;root&quot;]; then\n    echo &quot;You are root.&quot;\nelse\n    echo &quot;You are not root.&quot;\nfi\n<\/pre>\n<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u5728\u6267\u884c\u8be5\u811a\u672c\u540elinux\u865a\u62df\u4e3b\u673a\uff0c\u7ec8\u7aef\u4f1a\u8f93\u51fa\u76f8\u5e94\u7684\u7ed3\u679c\u3002<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'><b>\u4e94\u3001\u67e5\u770b\u7528\u6237\u7ec4<\/b><\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u9664\u4e86\u67e5\u770b\u5f53\u524d\u7528\u6237\u7684\u7528\u6237\u540d\u548cID\u5916\uff0cwhoami\u547d\u4ee4\u8fd8\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u67e5\u770b\u5f53\u524d\u7528\u6237\u6240\u5c5e\u7684\u7528\u6237\u7ec4\u3002\u53ea\u9700\u8981\u5728\u7ec8\u7aef\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5373\u53ef\uff1a<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\n<pre>\n$ id -Gn\n<\/pre>\n<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u8be5\u547d\u4ee4\u5c06\u8fd4\u56de\u5f53\u524d\u7528\u6237\u6240\u5c5e\u7684\u6240\u6709\u7528\u6237\u7ec4\u3002<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'><b>\u516d\u3001\u67e5\u770b\u767b\u5f55\u540d<\/b><\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u9664\u4e86\u67e5\u770b\u5f53\u524d\u7528\u6237\u540d\u5916\uff0cwhoami\u547d\u4ee4\u8fd8\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u67e5\u770b\u5f53\u524d\u767b\u5f55\u540d\u3002\u53ea\u9700\u8981\u5728\u7ec8\u7aef\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5373\u53ef\uff1a<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\n<pre>\n$ echo $LOGNAME\n<\/pre>\n<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u8be5\u547d\u4ee4\u5c06\u8fd4\u56de\u5f53\u524d\u767b\u5f55\u540d\u3002<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'><b>\u4e03\u3001\u67e5\u770b\u6709\u6548\u7528\u6237ID<\/b><\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u9664\u4e86\u67e5\u770b\u5f53\u524d\u7528\u6237ID\u5916\uff0cwhoami\u547d\u4ee4\u8fd8\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u67e5\u770b\u6709\u6548\u7528\u6237ID\uff08EUID\uff09\u3002\u53ea\u9700\u8981\u5728\u7ec8\u7aef\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5373\u53ef\uff1a<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\n<pre>\n$ id -u\n<\/pre>\n<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u8be5\u547d\u4ee4\u5c06\u8fd4\u56de\u5f53\u524d\u7528\u6237\u7684\u6709\u6548\u7528\u6237ID\u3002<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'><b>\u516b\u3001\u67e5\u770b\u5b9e\u9645\u7528\u6237ID<\/b><\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u9664\u4e86\u67e5\u770b\u6709\u6548\u7528\u6237ID\u5916\uff0cwhoami\u547d\u4ee4\u8fd8\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u67e5\u770b\u5b9e\u9645\u7528\u6237ID\uff08UID\uff09\u3002\u53ea\u9700\u8981\u5728\u7ec8\u7aef\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5373\u53ef\uff1a<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\n<pre>\n$ id -ru\n<\/pre>\n<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u8be5\u547d\u4ee4\u5c06\u8fd4\u56de\u5f53\u524d\u7528\u6237\u7684\u5b9e\u9645\u7528\u6237ID\u3002<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'><b>\u4e5d\u3001\u603b\u7ed3<\/b><\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u901a\u8fc7\u672c\u6587\u7684\u4ecb\u7ecd\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\uff0cwhoami\u547d\u4ee4\u867d\u7136\u975e\u5e38\u7b80\u5355\uff0c\u4f46\u5b83\u5374\u6709\u7740\u975e\u5e38\u5e7f\u6cdb\u7684\u5e94\u7528\u573a\u666f\u3002\u65e0\u8bba\u662f\u5728\u65e5\u5e38\u4f7f\u7528\u4e2d\u786e\u8ba4\u81ea\u5df1\u7684\u8eab\u4efd\uff0c\u8fd8\u662f\u5728\u7f16\u5199shell\u811a\u672c\u65f6\u6839\u636e\u5f53\u524d\u7528\u6237\u8eab\u4efd\u6267\u884c\u4e0d\u540c\u64cd\u4f5c\uff0c\u90fd\u79bb\u4e0d\u5f00\u8fd9\u4e2a\u5c0f\u5c0f\u7684\u547d\u4ee4\u3002\u56e0\u6b64\uff0c\u5728\u5b66\u4e60Linux\u64cd\u4f5c\u7cfb\u7edf\u65f6\uff0cwhoami\u547d\u4ee4\u4e5f\u662f\u5fc5\u4e0d\u53ef\u5c11\u7684\u4e00\u90e8\u5206\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>whoami\u547d\u4ee4\u7684\u57fa\u672c\u7528\u6cd5\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u5728\u7ec8\u7aef\u8f93\u5165\u8be5\u547d\u4ee4\u5373\u53ef\u3002whoami\u9664\u4e86\u53ef\u4ee5\u67e5\u770b\u5f53\u524d\u7528\u6237\u7684\u7528\u6237\u540d\u5916\uff0cwhoami\u547d\u4ee4\u8fd8\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u67e5\u770b\u5f53\u524d\u7528\u6237\u7684ID\u3002whoamiwhoami\u8fd9\u65f6\u5019\uff0cwhoami\u547d\u4ee4\u5c31\u975e\u5e38\u6709\u7528\u4e86\u3002bash\/bin\/bash\u9664\u4e86\u67e5\u770b\u5f53\u524d\u7528\u6237\u540d\u5916\uff0cwhoami\u547d\u4ee4\u8fd8\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u67e5\u770b\u5f53\u524d\u767b\u5f55\u540d\u3002\u9664\u4e86\u67e5\u770b\u5f53\u524d\u7528\u6237ID\u5916\uff0cwhoami\u547d\u4ee4\u8fd8\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u67e5\u770b\u6709\u6548\u7528\u6237ID\uff08EUID\uff09\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[23,24,151],"class_list":["post-14893","post","type-post","status-publish","format-standard","hentry","category-knowledge","tag-lxt","tag-r","tag-s-5"],"_links":{"self":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/14893","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/comments?post=14893"}],"version-history":[{"count":0,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/14893\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/media?parent=14893"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/categories?post=14893"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/tags?post=14893"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}