download http directory

Here’s a quick note on how to download the contents of an http directory via command line. Using lftp to download an HTTP directory Forget wget, lftp is what you covet! What is lftp? LFTP is a sophisticated ftp/http client, and a file transfer program supporting a number of network protocols. Like BASH, it has... » read more

passing bash variable to perl command in bash script

Recently I tried passing a bash variable to perl command in bash script, it didn’t end well. Troy Engel from http://tacticalvim.wordpress.com/ was nice enough to point out the issue: use sed instead of perl for what you need; it’s simpler, faster and uses the bash variables easily. I set up a test script /home/someuser/test.sh to show:... » read more

cURL Examples

Great examples of how to use cURL from http://www.thegeekstuff.com/2012/04/curl-examples/ 1. Download a Single File The following command will get the content of the URL and display it in the STDOUT (i.e on your terminal). $ curl http://www.centos.org To store the output in a file, you an redirect it as shown below. This will also display some... » read more

ossec clear database

To delete all currently stored alerts and related data in the ossec database execute these commands in MySQL Editor: truncate table alert; truncate table data; Bash Script: #!/usr/local/bin/bash # #Stop ossec, remove old alerts, start ossec echo "stopping ossec" /var/ossec/bin/ossec-control stop echo 'TRUNCATE TABLE `alert` ;' | mysql ossec -p;echo 'TRUNCATE TABLE `data` ;' |... » read more

Configure postfix with Gmail via Webmin

Configure postfix with Gmail via Webmin This assumes the user has webmin installed and understands how to log in and use it. (Usually bring it up in a browser at https://localhost:10000 ) Make sure that postfix is installed. In Webmin this is done by going to “System”, “Software Packages” then clicking on “Package from APT” and... » read more

Generate crontab scripts

Someone recently passed me this link and it looks great! You can generate crontab scripts via a website. Here’s the link: http://www.openjs.com/scripts/jslibrary/demos/crontab.php

reset linux password email user script

this script will reset a user’s password and email it to them. It accepts two parameters (username) (email address) Example Usage: ./reset_user_password.sh someuser [email protected] #!/usr/local/bin/bash if [ $# -ne 2 ]; then echo "Please provide a username and email address"; exit 0; fi TMP_PASSWORD=$(openssl rand -base64 6) echo "Resetting Password for $1" echo $TMP_PASSWORD |... » read more

howto move mysql freebsd without dump

to move mysql on freebsd without using a dump file follow these steps: stop mysql copy /var/db/mysql to its new location chown -R mysql:mysql modify /etc/rc.conf and add line mysql_dbdir=”“ modify /usr/local/etc/rc.d/mysql-server and change mysql_dbdir=”/var/db/mysql” to the new location of your mysql directory Start up mysql:  /usr/local/etc/rc.d/mysql-server start