Saturday, May 5, 2012

How to run a unix command as a USER on startup?

To run a unix command on startup you may use the command below (add it to the /etc/rc.local file):
su USER -c 'your_command &'

How to make stable $PATH when using sudo command?

To make your sudo commands works with the $PATH of your logged-in user you just type the following command and then close all your terminals and login again:

echo "alias sudo='sudo env PATH=$PATH'" >> ~/.bashrc

Wednesday, January 25, 2012

securing memcache

Simply iptables rules can be added to secure memcached server from the out sources.

/sbin/iptables -A INPUT -m tcp -p tcp -s 127.0.0.1 --dport 11221 -j ACCEPT
/sbin/iptables -A INPUT -m tcp -p tcp -s CLIENT_IP_2 --dport 11221 -j ACCEPT
/sbin/iptables -A INPUT -m tcp -p tcp -s CLIENT_IP_1 --dport 11221 -j ACCEPT
/sbin/iptables -A INPUT -m tcp -p tcp --dport 11221 -j DROP
To make it run when system restarts just add it to the /etc/rc.local file.