• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

runcon Command Examples in Linux

by Deepika

runcon is a command-line utility that allows you to run a program in a different SELinux (Security-Enhanced Linux) security context than the one currently active. SELinux is a security mechanism used in Linux systems to provide a more fine-grained access control for processes and resources.

When run with neither context nor command, runcon prints the current security context, which represents the current security attributes for the current process. The security context includes the security label, which contains the security attributes for the process, such as the SELinux user, role, and type.

To use runcon to run a program in a different SELinux security context, you need to provide the new security context as the first argument, followed by the command to run in that context.

runcon Command Examples

1. Determine the current domain:

# runcon

2. Specify the domain to run a command in:

# runcon -t domain_t command

3. Specify the context role to run a command with:

# runcon -r role_r command

4. Specify the full context to run a command with:

# runcon user_u:role_r:domain_t command

Note that to use runcon, your system must have SELinux enabled and properly configured, and you need to have the appropriate permissions to run processes in different security contexts. For more information on runcon and SELinux, refer to the GNU Coreutils documentation or the SELinux documentation.

Filed Under: Linux

Some more articles you might also be interested in …

  1. How to Enable FTP in CentOS/RHEL 5 and 6
  2. How to restrict ssh logins by user and client address on CentOS/RHEL
  3. Medusa Command Examples in Linux
  4. eqn: Equation preprocessor for the groff (GNU Troff) document formatting system
  5. CentOS / RHEL : How to collect sosreport
  6. How to use netstat command under Linux (Examples included)
  7. apropos – Search the manual pages for names and descriptions (Command Examples)
  8. Allow cronjobs to run by pam even if user password is expired
  9. crictl: Command-line for CRI-compatible container runtimes
  10. UNIX / Linux : How to delete root equivalent user (Non-Root User with UID 0)

You May Also Like

Primary Sidebar

Recent Posts

  • glab Command Examples
  • “glab repo” Command Examples
  • “glab release” Command Examples
  • “glab pipeline” Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright