getpidcon_raw - Linux


getpidcon_raw is a Linux command used to retrieve the security context of the current process in raw format. It is most commonly used in security contexts to analyze and troubleshoot process-level access control and labeling.


getpidcon_raw [OPTION...]


-c, –canonicalize
Canonicalize the security context. Format the output in the friendly, human-readable format.

-s, –short
Shorten the output format to only display the context.

-e, –enforce
Enforce mode. Check if the process has the specified context.


Display the current process’s security context in raw format:

$ getpidcon_raw

Canonicalize the security context to human-readable format:

$ getpidcon_raw -c

Check if the process has a specific security context:

$ getpidcon_raw -e 'system_u:system_r:init_t'

Common Issues

  • If the binary is not setuid, it will fail with Permission denied.


Combine with ps to show security contexts for all processes:

$ ps -eo pid,user,command,con=getpidcon_raw

Related Commands

  • getenforce – Get the current SELinux enforcement mode.
  • chcon – Change the security context of a file or directory.
  • sestatus – Show the SELinux status.