How to check syntax of dhcpd (dhcpd.conf file )

/usr/sbin/dhcpd -t -cf /etc/dhcpd.conf

 Some other quick tips:




1. Syntax checking for dhcpd files:



/usr/sbin/dhcpd -t -cf /etc/dhcpd.conf



This will do a basic syntax check to find those missing ; or other odd things.



2. host {} are global. You will see this warning if you place the host in a subnet zone. This is because when ISC will parse the file and make hostnames work globally (you can also make it do neat if then things but that makes my head hurt.) For the most part it is useful to put hosts in a group setting. This keeps them out of subnets, and also allows you to put common items with them (say for PXE booting with cobbler).



group {

next-server rhn.example.com;

filename “pxelinux.0″;



host noah {

hardware ethernet 00:11:00:11:00:11;

fixed-address 192.168.1.121;

}

}

How to get list of all cron jobs ( crontab ) in a server

Run below as root :


for user in $(cut -f1 -d: /etc/passwd); do crontab -u $user -l; done


If you want to see who owns that cron job run below :

for user in $(cut -f1 -d: /etc/passwd); do echo $user; crontab -u $user -l; done


getent passwd cut -d: -f1 perl -e'while(<>){chomp;$l = `crontab -u $_ -l 2>/dev/null`;print "$_\n$l\n" if $l}'

Bash Script to get public ip

#!/bin/bash




pubip=$( curl http://ip4.me 2>/dev/null | sed -e 's#<[^>]*>##g' | grep '^[0-9]' )



echo $pubip



you can replace curl command with



curl -s checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//' 

Apache hardening tips - Subhash C

# Server banner


ServerSignature Off // will not show apache version etc
ServerTokens Prod // Will hide OS version etc

# Disable TRACE requests

TraceEnable off

### Security Fixes

RewriteEngine on

RewriteCond %{REQUEST_METHOD} ^(TRACE
TRACK)

RewriteRule .* - [F]

Some Find commands regularly used for finding disk usage


find . -size +500000 -print

du -ch | grep total ( total size of directory)

du -sk * | sort -nr | head -3

find /home -type f | xargs ls -s | sort -rn | awk '{size=$1/1024; printf("%dMb %s\n", size,$2);}' | head

find / -type f -size +300000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'

du -hs /home/* | grep G

du -hs /home/* | grep M

Command to import SSL certificate need for java applications

keytool -import -alias anotherdomainname -file /tmp/certificatename.cer -keystore $JAVA_HOME/jre/lib/security/cacerts