posted this in FreeBSD, Linux on March 10th, 2013 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: download http directory
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: passing bash variable to perl command in bash script
posted this in FreeBSD, Linux, Mac, O/S, Windows on May 10th, 2012 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 additional download . . . → Read More: cURL Examples
posted this in Defense, FreeBSD, Linux, O/S on January 6th, 2012 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 . . . → Read More: ossec clear database
posted this in bash, FreeBSD, Linux, Redhat Centos, Scripts, Ubuntu on December 5th, 2011 to kill orphaned httpd processes create a script called killhttpd.sh with the following code
|
|
#!/bin/bash for pid in `ps -C httpd|sed -e 's/^\ \+//g' | grep httpd|awk '{print $1}'` do kill $pid done |
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: Configure postfix with Gmail via Webmin
posted this in FreeBSD, Linux, Redhat Centos, Ubuntu on December 1st, 2011 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
posted this in FreeBSD, Linux, Redhat Centos, Ubuntu on December 1st, 2011 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: reset linux password email user script
posted this in FreeBSD, MYSQL on November 17th, 2011 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
posted this in Apache, FreeBSD, Linux, Redhat Centos on September 28th, 2011 how to check current apache connections
Since apache will spawn a new process for each new connection you need to determine how many httpd processes are currently running
I would recommend checking the count from this command against the MaxClients setting in apache’s httpd.conf:
To show the number of established connections using apache:
|
|
netstat -plnant | grep "httpd" | grep -ic established |
. . . → Read More: current apache connections
|
|