{"id":11482,"date":"2021-10-30T14:37:55","date_gmt":"2021-10-30T14:37:55","guid":{"rendered":"https:\/\/linuxways.net\/?p=11482"},"modified":"2021-10-30T14:37:55","modified_gmt":"2021-10-30T14:37:55","slug":"listing-selinux-contexts-on-linux-mint-20","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/mint\/listing-selinux-contexts-on-linux-mint-20\/","title":{"rendered":"Listing SELinux Contexts on Linux Mint 20"},"content":{"rendered":"<h2>Introduction:<\/h2>\n<p>All the additional information about a process or a file in SELinux is referred to as the SELinux context. This context is used to determine the access control rights. There are different ways of listing down the SELinux contexts but in this article, we will share with you the methods of doing so on a Linux Mint 20 system.<\/p>\n<h2>Pre-Requisite:<\/h2>\n<p>You need to have SELinux installed and enabled on your Linux Mint 20 system before viewing its contexts.<\/p>\n<h2>Different Methods of Listing the SELinux Contexts on Linux Mint 20:<\/h2>\n<p>There are different methods of listing the SELinux contexts on a Linux Mint 20 system. All of these methods are stated below:<\/p>\n<h3>Method # 1: Running the \u201cls\u201d Command:<\/h3>\n<p>This method is used to list down only the SELinux file contexts. You can use the \u201cls\u201d command to list down the SELinux contexts in the following manner:<\/p>\n<pre><strong>$ ls \u2013lZ \/root<\/strong><\/pre>\n<p>You need to run this command with \u201csudo\u201d privileges if you are not already logged in to a root user account.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"325\" height=\"25\" class=\"wp-image-11483\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-530.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-530.png 325w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-530-300x23.png 300w\" sizes=\"auto, (max-width: 325px) 100vw, 325px\" \/><\/p>\n<p>The SELinux file contexts are shown in the image below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"642\" height=\"71\" class=\"wp-image-11484\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-531.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-531.png 642w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-531-300x33.png 300w\" sizes=\"auto, (max-width: 642px) 100vw, 642px\" \/><\/p>\n<h3>Method # 2: Running the \u201cps\u201d Command:<\/h3>\n<p>This method is used to list down only the SELinux process contexts. You can use the \u201cps\u201d command to list down the SELinux contexts in the following manner:<\/p>\n<pre><strong>$ ps axZ<\/strong><\/pre>\n<p>You need to run this command with \u201csudo\u201d privileges if you are not already logged in to a root user account.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"274\" height=\"25\" class=\"wp-image-11485\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-532.png\" \/><\/p>\n<p>The SELinux process contexts are shown in the image below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"795\" height=\"598\" class=\"wp-image-11486\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-533.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-533.png 795w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-533-300x226.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-533-768x578.png 768w\" sizes=\"auto, (max-width: 795px) 100vw, 795px\" \/><\/p>\n<h3>Method # 3: Running the \u201csemanage\u201d Command:<\/h3>\n<p>This method is used to list down both the SELinux file and process contexts. You can use the \u201csemanage\u201d command to list down the SELinux contexts in the following manner:<\/p>\n<pre><strong>$ semanage fcontext \u2013l | grep httpd_log_t<\/strong><\/pre>\n<p>You need to run this command with \u201csudo\u201d privileges if you are not already logged in to a root user account.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"543\" height=\"23\" class=\"wp-image-11487\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-534.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-534.png 543w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-534-300x13.png 300w\" sizes=\"auto, (max-width: 543px) 100vw, 543px\" \/><\/p>\n<p>The SELinux contexts for all the files and processes of our Linux Mint 20 system are shown in the image below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"801\" height=\"549\" class=\"wp-image-11488\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-535.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-535.png 801w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-535-300x206.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-535-768x526.png 768w\" sizes=\"auto, (max-width: 801px) 100vw, 801px\" \/><\/p>\n<h3>Method # 4: Running the \u201cid\u201d Command:<\/h3>\n<p>This method is used to list down only the SELinux current user contexts. You can use the \u201cid\u201d command to list down the SELinux contexts in the following manner:<\/p>\n<pre><strong>$ id -Z<\/strong><\/pre>\n<p>You need to run this command with \u201csudo\u201d privileges if you are not already logged in to a root user account.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"264\" height=\"25\" class=\"wp-image-11489\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-536.png\" \/><\/p>\n<p>The SELinux current user contexts are shown in the image below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"274\" height=\"54\" class=\"wp-image-11490\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/10\/word-image-537.png\" \/><\/p>\n<h2>Conclusion:<\/h2>\n<p>This article threw light on the four different methods of listing the SELinux contexts on a Linux Mint 20 system. Using these methods, you can conveniently find out the SELinux contexts related to the processes, files, or users of your system depending upon your requirements.<\/p>","protected":false},"excerpt":{"rendered":"<p>Introduction: All the additional information about a process or a file in SELinux is referred to as the SELinux context. This context is used to determine the access&hellip;<\/p>","protected":false},"author":1,"featured_media":11710,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[129,404],"class_list":["post-11482","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mint","tag-linux-mint-20","tag-selinux"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/11482","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=11482"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/11482\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/11710"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=11482"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=11482"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=11482"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}