context_user_get - Linux


context_user_get retrieves the current user’s context information for use in creating a new context.


context_user_get [options...]


  • -a, –all-security-attributes
    Displays all security attributes in the context, both user and system.

  • -d, –display-mode
    Displays the user’s context in the specified mode: text, xml, json, or tsv. Default: text.

  • -f, –format
    Prints output in the specified format: text, xml, or json. Default: text.

  • -h, –help
    Displays this help message.

  • -q, –quiet
    Suppresses all non-error output.


Display the current user’s context:


Display the context with all security attributes:

context_user_get -a

Display the context in XML format:

context_user_get -f xml

Common Issues

Command not found:

  • Ensure that the libsemanage package is installed.


context_user_get can be used in shell scripts or other programs to retrieve a user’s context information. The output can be parsed to extract specific attributes or used to set the context of files or directories.

Related Commands