
seinfo Command in Linux
The seinfo command is a useful tool in the Linux ecosystem, particularly for those working with Security-Enhanced Linux (SELinux) policies. This command provides comprehensive insights into SELinux policies, helping administrators manage and troubleshoot security settings efficiently.
Table of Contents
Here is a comprehensive guide to the options available with the seinfo command â
- Introduction of seinfo Command
- Installing of seinfo Command in Linux
- Syntax of seinfo Command
- seinfo Command Options
- Examples of seinfo Command in Linux
Introduction of seinfo Command
The seinfo command is a specialized utility designed to extract and display information about SELinux policies. Whether you need to inspect policy rules, analyze security contexts, or audit policy configurations, seinfo offers a powerful means to achieve these tasks with precision.
Mastering the seinfo command enhances your ability to manage SELinux policies and maintain robust security.
Installing of seinfo Command in Linux
To install the seinfo command, you need to install the setools-console package, which includes seinfo along with other SELinux policy analysis tools. Hereâs how you can do it on different Linux distributions:
Ubuntu / Debian
sudo apt install setools
Fedora
sudo dnf -y install setools-console
On CentOS/RHEL
sudo yum -y install setools-console
Syntax of seinfo Command
The general syntax for the Linux seinfo command is:
seinfo [options] [policy-file]
Where:
- [options] specifies the different flags and parameters to refine the information displayed.
- [policy-file] represents the SELinux policy file to be analyzed.
seinfo Command Options
Listed below are a few different options used with the Linux seinfo command:
Option | Description |
---|---|
-c[NAME], --class[=NAME] | Output a list of object classes, or if a specific NAME is provided, display details for that object class. Use the -x option to also list permissions associated with each displayed object class. |
--sensitivity[=NAME] | Print a list of sensitivities, or if a specific NAME is provided, print details for that sensitivity. When used with -x, it also prints the corresponding level statement for each displayed sensitivity. |
--category[=NAME] | Print a list of categories, or if a specific NAME is provided, print details for that category. When used with -x, it also prints the sensitivities that each displayed category may be associated with. |
-t[NAME], --type[=NAME] | Print a list of types (excluding aliases or attributes), or if a specific NAME is provided, print details for that type. When used with -x, it also prints the attributes that include each displayed type. |
-a[NAME], --attribute[=NAME] | Print a list of type attributes, or if a specific NAME is provided, print details for that attribute. When used with -x, it also prints the types assigned to each displayed attribute. |
-r[NAME], --role[=NAME] | Print a list of roles, or if a specific NAME is provided, print details for that role. When used with -x, it also prints the types assigned to each displayed role. |
-u[NAME], --user[=NAME] | Print a list of users, or if a specific NAME is provided, print details for that user. When used with -x, it also prints the roles assigned to each displayed user. |
-b[NAME], --bool[=NAME] | Print a list of conditional booleans, or if a specific NAME is provided, print details for that boolean. When used with -x, it also prints the default state of each displayed conditional boolean. |
--initialsid[=NAME] | Print a list of initial SIDs, or if a specific NAME is provided, print details for that initial SID. When used with -x, it also prints the context assigned to each displayed SID. |
--fs_use[=TYPE] | Print a list of fs_use statements, or if a specific TYPE is provided, print the statement for that filesystem type. |
--genfscon[=TYPE] | Print a list of genfscon statements, or if a specific TYPE is provided, print the statement for that filesystem type. |
--netifcon[=NAME] | Print a list of netif contexts, or if a specific NAME is provided, print the statement for that interface name. |
--nodecon[=ADDR] | Print a list of node contexts, or if a specific ADDR is provided, print the statement for that node address. |
--portcon[=PORT] | Print a list of port contexts, or if a specific PORT is provided, print the statement for that port. |
--protocol=PROTO | Print only portcon statements for the specified protocol. This option is ignored if portcon statements are not printed or if no statement exists for the requested port. |
--constrain | Print a list of constraints. |
--all | Print all components. |
-x, --expand | Print additional details for each component matching the expression, such as the types assigned to an attribute or role and the permissions for an object class. |
-l | Print line breaks when displaying constraint statements. |
Examples of seinfo Command in Linux
Here are some practical scenarios where the seinfo command can be effectively used:
- Viewing a List of Object Class
- Listing Type Attributes
- Displaying and Detailing Roles
- Showing Users and Their Roles
- Viewing Conditional Booleans and Their States
Viewing a List of Object Classes
If you need to see all the object classes defined in the SELinux policy, use the following command:
seinfo -c

If you want to print permissions for each displayed object class, use:
seinfo -c -x

Listing Type Attributes
To print a list of all type attributes defined in the SELinux policy:
seinfo -a

If you want to view the types assigned to each displayed attribute, add the -x flag:
seinfo -a -x

Displaying and Detailing Roles
To get a list of all roles defined in the SELinux policy:
seinfo -r

To see which types are assigned to each role, use the following command:
seinfo -r -x

Showing Users and Their Roles
To list all users included in the SELinux policy:
seinfo -u

If you want to display the roles assigned to each user, use the -x flag:
seinfo -u -x

Viewing Conditional Booleans and Their States
For a list of all conditional booleans in the SELinux policy, use:
seinfo -b

To also view the default state of each boolean, add the -x flag:
seinfo -b -x

Conclusion
The seinfo command in Linux is a powerful tool for extracting detailed information about SELinux policies. By understanding its purpose, syntax, options, and practical usage scenarios, you can effectively manage and audit SELinux policies, ensuring a secure and well-configured system.
Whether you need to view policy types, list attributes, display classes and permissions, show users, or summarize roles, mastering the seinfo command provides a flexible and powerful solution. Incorporating the seinfo command into your SELinux toolkit enhances your ability to maintain robust security and efficient policy management.