Manage security Flashcards
how to set firewall zone
firewall-cmd –set-default-zone=dmz
how to allow specific IP/range through firewall
firewall-cmd –permanent –zone=internal –add-source=192.168.0.0/24
how to allow specific service through firewall
firewall-cmd –permanent –zone=internal –add-service=mysql
how to allow specific port through firewall
firewall-cmd –permanent –zone=internal –add-port=1001/tcp
how to save current firewall rules
firewall-cmd –reload
how to list firewall rules by zone
firewall-cmd –permanent –zone=internal –list-all
how to set ACL on a file for a specific user
setfacl -m u:name:rwX file
how to delete all ACL rules on a file
setfacl -x file
how to set ACL on a directory and all files under it
setfacl -R -m d:u:name:rwX directory
how to check ACL’s on a file
getfacl file-A
how to copy ACL’s that one file has to another easily
getfacl file-A | setfacl –set-file=- file-B
how to live change SELinux to enforcing
setenforce 1
how to live change SELinux to permissive
setenforce 0
how to check current status of SELinux
getenforce
where is the file to permanently change SELinux mode
vim /etc/selinux/config
how to check SELinux context of a file
ls -Z /file/or/folder
how to change SELinux context of a file
chcon -t httpd_sys_content_t /virtual
Or (this sets it for that folder and anything under it)
semanage fcontext -a -t httpd_sys_content_t ‘/virtual(/.*)?’
how to restore default file context
restorecon -v /virtual
or recursively for that folder and everything under it
restorecon -RFvv /virtual
how to view the documents with the descriptions of the purpose of each available SELinux booleans
(first make sure they are installed “selinux-policy-doc”)
man -k ‘_selinux’
how to list all SELinux booleans and their state
getsebool -a
how to list a specific SELinux boolean and its state
getsebool httpd_enable_homedirs
how to temporarily change the state of a SELinux boolean
setsebool httpd_enable_homedirs on
how to permanently change the state of a SELinux boolean
setsebool -P httpd_enable_homedirs on
how to list SELinux booleans in which the current state differs from the default state
semanage boolean -l -C