{"id":12921,"date":"2019-03-29T02:54:18","date_gmt":"2019-03-29T02:54:18","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=12921"},"modified":"2019-03-29T02:54:18","modified_gmt":"2019-03-29T02:54:18","slug":"how-to-find-files-with-suid-and-sgid-permissions-in-linux","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/29\/how-to-find-files-with-suid-and-sgid-permissions-in-linux\/","title":{"rendered":"How to Find Files With SUID and SGID Permissions in Linux"},"content":{"rendered":"<p>In this tutorial, we will explain auxiliary file permissions, commonly referred to as \u201c<strong>special permissions<\/strong>\u201d in Linux, and also we will show you how to find files which have\u00a0<strong>SUID<\/strong>\u00a0(Setuid) and\u00a0<strong>SGID<\/strong>\u00a0(Setgid) set.<\/p>\n<h4>What is SUID and SGID?<\/h4>\n<p><strong>SUID<\/strong>\u00a0is a special file permission for executable files which enables other users to run the file with effective permissions of the file owner. Instead of the normal\u00a0<code>x<\/code>\u00a0which represents execute permissions, you will see an\u00a0<code>s<\/code>(to indicate\u00a0<strong>SUID<\/strong>) special permission for the user.<\/p>\n<p><strong>SGID<\/strong>\u00a0is a special file permission that also applies to executable files and enables other users to inherit the effective\u00a0<strong>GID<\/strong>\u00a0of file group owner. Likewise, rather than the usual\u00a0<code>x<\/code>\u00a0which represents execute permissions, you will see an\u00a0<code>s<\/code>\u00a0(to indicate\u00a0<strong>SGID<\/strong>) special permission for group user.<\/p>\n<p><b>Suggested Read:<\/b>\u00a0<a href=\"https:\/\/www.tecmint.com\/manage-users-and-groups-in-linux\/\" target=\"_blank\" rel=\"noopener\">Managing Users &amp; Groups, File Permissions &amp; Attributes in Linux<\/a><\/p>\n<p>Let\u2019s look at how to find files which have\u00a0<strong>SUID<\/strong>\u00a0and\u00a0<strong>SGID<\/strong>\u00a0set using the\u00a0<a href=\"https:\/\/www.tecmint.com\/35-practical-examples-of-linux-find-command\/\" target=\"_blank\" rel=\"noopener\">find command<\/a>.<\/p>\n<p>The syntax is as follows:<\/p>\n<pre>$ find directory -perm \/permissions\r\n<\/pre>\n<p><strong>Important<\/strong>: Certain directories (such as\u00a0<strong>\/etc<\/strong>,\u00a0<strong>\/bin<\/strong>,\u00a0<strong>\/sbin<\/strong>\u00a0etc.) or files require root privileges in order to be accessed or listed, if you are managing your system as a normal user, use the\u00a0<a href=\"https:\/\/www.tecmint.com\/su-vs-sudo-and-how-to-configure-sudo-in-linux\/\" target=\"_blank\" rel=\"noopener\">sudo command<\/a>\u00a0to gain root privileges.<\/p>\n<h3>How to Find Files with SUID Set in Linux<\/h3>\n<p>This below example command will find all files with\u00a0<strong>SUID<\/strong>\u00a0set in the current directory using -perm (print files only with permissions set to\u00a0<strong>4000<\/strong>) option.<\/p>\n<pre>$ find . -perm \/4000 \r\n<\/pre>\n<div id=\"attachment_26605\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/08\/Find-Files-with-SUID.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-26605\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/08\/Find-Files-with-SUID.png\" alt=\"Find Files with SUID Permissions\" width=\"652\" height=\"211\" aria-describedby=\"caption-attachment-26605\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-26605\" class=\"wp-caption-text\">Find Files with SUID Permissions<\/p>\n<\/div>\n<p>You can use the\u00a0<a href=\"https:\/\/www.tecmint.com\/tag\/linux-ls-command\/\" target=\"_blank\" rel=\"noopener\">ls command<\/a>\u00a0with\u00a0<code>-l<\/code>\u00a0option (for long listing) to view the permissions on the listed files as shown in the image above.<\/p>\n<h3>How to Find Files with SGID Set in Linux<\/h3>\n<p>To find files which have\u00a0<strong>SGID<\/strong>\u00a0set, type the following command.<\/p>\n<pre>$ find . -perm \/2000\r\n<\/pre>\n<div id=\"attachment_26606\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/08\/Find-Files-with-SGID.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-26606\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/08\/Find-Files-with-SGID.png\" alt=\"Find Files with SGID Permissions\" width=\"652\" height=\"268\" aria-describedby=\"caption-attachment-26606\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-26606\" class=\"wp-caption-text\">Find Files with SGID Permissions<\/p>\n<\/div>\n<p>To find files which have both\u00a0<strong>SUID<\/strong>\u00a0and\u00a0<strong>SGID<\/strong>\u00a0set, run the command below.<\/p>\n<pre>$ find . -perm \/6000\r\n<\/pre>\n<div id=\"attachment_26607\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/08\/Find-Files-with-SUID-SGID.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-26607\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/08\/Find-Files-with-SUID-SGID.png\" alt=\"Find Files with SUID and SGID\" width=\"522\" height=\"135\" aria-describedby=\"caption-attachment-26607\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-26607\" class=\"wp-caption-text\">Find Files with SUID and SGID<\/p>\n<\/div>\n<p>You may also like to read these useful guides about file permissions in Linux:<\/p>\n<ol>\n<li><a href=\"https:\/\/www.tecmint.com\/compress-files-and-finding-files-in-linux\/\" target=\"_blank\" rel=\"noopener\">How to Set File Attributes and Finding Files in Linux<\/a><\/li>\n<li><a href=\"https:\/\/www.tecmint.com\/check-linux-file-octal-permissions-using-stat-command\/\" target=\"_blank\" rel=\"noopener\">Translate rwx Permissions into Octal Format in Linux<\/a><\/li>\n<li><a href=\"https:\/\/www.tecmint.com\/secure-files-using-acls-in-linux\/\" target=\"_blank\" rel=\"noopener\">Secure Files\/Directories using ACLs (Access Control Lists) in Linux<\/a><\/li>\n<li><a href=\"https:\/\/www.tecmint.com\/chattr-command-examples\/\" target=\"_blank\" rel=\"noopener\">5 \u2018chattr\u2019 Commands to Make Important Files IMMUTABLE (Unchangeable) in Linux<\/a><\/li>\n<\/ol>\n<p>That\u2019s it for now! In this guide, we showed you how to find files which have\u00a0<strong>SUID<\/strong>\u00a0(Setuid) and\u00a0<strong>SGID<\/strong>\u00a0(Setgid) set in Linux. If you have any questions, use the feedback form below to share any queries or additional thoughts about this topic.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/how-to-find-files-with-suid-and-sgid-permissions-in-linux\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we will explain auxiliary file permissions, commonly referred to as \u201cspecial permissions\u201d in Linux, and also we will show you how to find files which have\u00a0SUID\u00a0(Setuid) and\u00a0SGID\u00a0(Setgid) set. What is SUID and SGID? SUID\u00a0is a special file permission for executable files which enables other users to run the file with effective permissions &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/29\/how-to-find-files-with-suid-and-sgid-permissions-in-linux\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Find Files With SUID and SGID Permissions in Linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-12921","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12921","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=12921"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12921\/revisions"}],"predecessor-version":[{"id":12922,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12921\/revisions\/12922"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=12921"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=12921"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=12921"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}