×


List SELinux Contexts on Linux Mint 20

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.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform related SELinux Linux queries.

In this context, we shall look into how to List SELinux Contexts on a Linux Mint 20 system.


Different ways of listing the SELinux Contexts on Linux Mint system

You need to have SELinux installed and enabled on your Linux Mint 20 system before viewing its contexts.


1. Executing the "ls" Command

Here, you will be listing down only the SELinux file contexts. You can use the "ls" command to list down the SELinux contexts with the below command:

$ ls –lZ /root

You need to run this command with "sudo" privileges if you are not already logged in to a root user account.

You will see the SELinux file contexts.


2. Executing the "ps" Command

This method is used to list down only the SELinux process contexts. You can use the "ps" command to list down the SELinux contexts with the below command:

$ ps axZ

You need to run this command with "sudo" privileges if you are not already logged in to a root user account.

The SELinux process contexts will be displayed on the terminal window.


3. Executing the "semanage" Command

This method is used to list down both the SELinux file and process contexts. You can use the "semanage" command to list down the SELinux contexts with the below command:

$ semanage fcontext –l | grep httpd_log_t

You need to run this command with "sudo" privileges if you are not already logged in to a root user account.

Now you will see the SELinux contexts for all the files and processes of the system.


4. Executing the "id" Command

This method is used to list down only the SELinux current user contexts. You can use the "id" command to list down the SELinux contexts with the below command:

$ id -Z

You need to run this command with "sudo" privileges if you are not already logged in to a root user account.

You will see the SELinux current user contexts of the system.


[Need support in configuring your Linux system ? We can help you. ]


Conclusion

This article covers the different ways of listing the SELinux contexts on a Linux Mint 20 system. In fact, 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.