##How to remount the file system read write (rw) In maintenance mode##
mount -o remount, rw /
##How to unencrypt PDF documents##
http://www.cyberciti.biz/faq/removing-password-from-pdf-on-linux/
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=/home/erik/Destination.pdf -c .setpdfwrite -f /home/erik/source.pdf
##How to reindex spacewalk postgres database##
I was getting all kinds of weird spacewalk errors that all seemed to point to the database.
$sudo su postgres
$reindexdb --all
At the end I got the following eror:
NOTICE: table "rhnpackagedeltaelement" was reindexed reindexdb: reindexing of database "rhnschema" failed: ERROR: could not create unique index "rhnchecksum_chsum_uq" DETAIL: Table contains duplicated values.
I ended up restoring a backed up VM
##To Find directories and sizes##
du -sch .[!.]* * |sort -h
##Removing Old Kernels##
$ sudo yum install yum-utils
$ sudo package-cleanup --oldkernels --count=2
Edit /etc/yum.conf and set installonly_limit:
installonly_limit=2
##Piping a command through mail##
| mail -s "Clam Scan %D" erik@hq38.hohenfels.com
##Get a list of rpm’s off a web page for a script##
http://linux.dell.com/repo/hardware/Linux_Repository_14.12.00/platform_independent/rh60_64/srvadmin-x86_64/ | egrep -o "http:.*rpm" |cut -d "/" -f10
##To delete a server from using Spacewalk
##Delete the server from the WebGUI
##On the Client:
sudo vi /etc/yum/pluginconf.d/rhnplugin.conf
##And change:
[main] enabled = 1
#to
[main] enabled = 0
##Then
sudo rm -rf /etc/sysconfig/rhn/systemid
##Remove the spacewalk repos if they are there:
sudo rm /etc/yum.repos.d/spacewalk-client*
##SELinux Love
##First install the trouble shooter
sudo yum install setroubleshoot-server setroubleshoot setools
##Then Search the logs:
sudo cat /var/log/messages | grep sealert (CentOS 6) or sudo sealert -a /var/log/audit/audit.log (CentOS 7)
You are going to see something like this:
docker setroubleshoot: SELinux is preventing /usr/bin/bash from ioctl access on the file /usr/bin/distro. For complete SELinux messages. run sealert -l f4eed2fe-d681-412f-ab31-55f704a7cf46
##Do what it says, Bolded above
sudo sealert -l f4eed2fe-d681-412f-ab31-55f704a7cf46
##At the top of the output you will see:
If you believe that bash should be allowed ioctl access on the distro file by default. Then you should report this as a bug. You can generate a local policy module to allow this access. Do allow this access for now by executing: # grep distro /var/log/audit/audit.log | audit2allow -M mypol # semodule -i mypol.pp
##Again, do what it says
sudo grep distro /var/log/audit/audit.log | audit2allow -M mypol
##Then
sudo semodule -i mypol.pp
## Grub Edit ##
Make the modifications you want:
$ sudo vi /etc/default/grub
After you edit the above file you need to run:
$ sudo grub2-mkconfig -o /boot/grub2/grub.cfg
##Installing RootKit Hunter
http://lintut.com/install-rkhunter-in-centos/
Here is the conf file location.
sudo vi /etc/rkhunter.conf
Add:
##RootKit Check /usr/bin/rkhunter --update /usr/bin/rkhunter --checkall
##Firewall Commands
##Add Port:
sudo firewall-cmd --zone=public --add-port=161/udp --permanent
##Add Know Service
sudo firewall-cmd --permanent --zone public --add-service samba
##Restart
sudo systemctl restart firewalld.service
##Install Logwatch
##Install the package
sudo yum install logwatch
##Edit the conf file:
sudo vi /usr/share/logwatch/default.conf/logwatch.conf
##Change to High
Detail = High
##Set to send an email
Output = mail
##ClamAV
1 – Install EPEL 7
After you’ve successfully installed your operating system and applied all the updates. You can install the EPEL 7 repository by running this command:
sudo yum install epel-release
2 – Install and configure the ClamAV packages
sudo yum install clamav clamav-scanner-systemd
Yes, it’s enough. When installing these packages all needed packages will be installed by dependency.
Correct a “bad” file path probably written during the compilation by creating a link to the correct file:
sudo ln -s /etc/clamd.d/scan.conf /etc/clamd.conf
Edit the configuration installed by the clamd-scanner package:
sudo vi /etc/clamd.d/scan.conf
Comment the example line:
#Example
Uncomment the LocalSocket config line to enable it:
LocalSocket /var/run/clamd.scan/clamd.sock
Save and quit the text editor.
3 – Turn on the SELinux boolean for antivirus
sudo setsebool -P antivirus_can_scan_system 1
4 – Start the service and enable it at boot
sudo systemctl start clamd@scan sudo systemctl enable clamd@scan
5 – Install and configure the ClamAV updater
To automatically get the latest virus updates, you need to install the binary used for this task:
sudo yum install clamav-update
Edit the configuration file:
sudo vi /etc/freshclam.conf
Comment the example line:
#Example
Save and quit the text editor and run the command “freshclam” to update the virus database. If needed you can add a crontab to execute it regularly.
6 – Test your installation
sudo clamdscan --fdpass /var/log/*
Always use the –fdpass to give the correct permission to scan the files with clamdscan binary. In some case the first check mays fail after the installation, a simple reboot can solve this issue.
REF: https://www.adminsys.ch/2015/08/21/installing-clamav-epel-centosred-hat-7-nightmare/
##
