Useful Linux Commands
export HISTTIMEFORMAT="%d/%m/%y %H:%M:%S "
export HISTSIZE=10000000
export HISTFILESIZE=10000000
shopt -s histappend histreedit histverify
export HISTCONTROL=ignoreboth
export HISTIGNORE="ls:ps:history:cd"
export PS1="\[\e[32m\][\[\e[m\]\[\e[31m\]\u\[\e[m\]\[\e[33m\]@\[\e[m\]\[\e[32m\]\h\[\e[m\]:\[\e[36m\]\w\[\e[m\]\[\e[32m\]]\[\e[m\]\[\e[32;47m\]\[\e[m\] "
alias vi='vim'
PROMPT_COMMAND="history -a"
shopt -s no_empty_cmd_completion # bash>=2.04 only
Then source your ~/.bash_profile
. ~/.bash_profile
inline text editing
# changes 0.2 to 1.61 globally in the resolv.conf file
sudo sed -i 's/0\.2/1\.61/g' /etc/resolv.conf
# Grep removing comments
grep -v '^\s*$\|^\s*\#' <filename>
useful firewall commands
flushes the firewall opens port 22 | 443 saves the configuration restarts the firewall
iptables -F
iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
iptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP
iptables -A INPUT -p tcp ! --syn -m state --state NEW -j DROP
iptables -A INPUT -p tcp --tcp-flags ALL ALL -j DROP
iptables -A INPUT -i lo -j ACCEPT
iptables-save > /etc/sysconfig/iptables
iptables -L
service iptables restart