I've created a file as follows:
ls -l -Z /etc/cron.d/vnstat
-rw-r--r--. root root system_u:object_r:system_cron_spool_t:s0 /etc/cron.d/vnstat
I've created a new file /etc/cron.d/vnstat.custom.interface:
ls -l -Z /etc/cron.d/vnstat.custom.interface
-rw-r--r--. root root unconfined_u:object_r:system_cron_spool_t:s0 /etc/cron.d/vnstat.custom.interface
The /etc/cron.d/vnstat is part of default vnstat package. I've installed my own version of the same. But, due to SELinux security cron job is not running. How do I change file SELinux security contex under RHEL / CentOS 6 Linux server to system_u:object_r:system_cron_spool_t:s0 from unconfined_u:object_r:system_cron_spool_t:s0 for /etc/cron.d/vnstat.custom.interface file?
You need to use the chcon command to change the SELinux security context of FILE. The syntax is as follows:
chcon --reference=/path/to/existingfile /path/to/a/newfileOR
chcon CONTEXT /path/to/a/newfile
Syntax #1 Example
The first syntax is easy to use and recommend for all users:
# cd /etc/cron.d/
# chcon --reference=vnstat vnstat.custom.interface
Verify new context, type:
# ls -Z vnstat*
Sample outputs:
-rw-r--r--. root root system_u:object_r:system_cron_spool_t:s0 vnstat -rw-r--r--. root root system_u:object_r:system_cron_spool_t:s0 vnstat.custom.interface
Syntax #2 Example
First, see existing context, enter:
# cd /etc/cron.d/
# ls -Z vnstat
Sample outputs:
-rw-r--r--. root root system_u:object_r:system_cron_spool_t:s0 vnstatUse the following syntax to copy system_u:object_r:system_cron_spool_t:s0 context:
# chcon system_u:object_r:system_cron_spool_t:s0 vnstat.custom.interface
Verify the same, enter:
# ls -Z vnstat*
Sample outputs:
-rw-r--r--. root root system_u:object_r:system_cron_spool_t:s0 vnstat -rw-r--r--. root root system_u:object_r:system_cron_spool_t:s0 vnstat.custom.interface
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop




![RHEL / CentOS Yum Command: Blacklist Packages [ Disable Certain Packages ]](http://s13.cyberciti.org/images/shared/rp/3/5.jpg)








{ 0 comments… add one now }