Posts Tagged bsd

Multi-Threaded Downloading with Wget

In the process of downloading a few thousand log files from one server to the next I suddenly had the need to do some serious multithreaded downloading in BSD, preferably with Wget as that was the simplest way I could think of handling this.  A little looking around led me to this little nugget:

wget -r -np -N [url] & wget -r -np -N [url] & wget -r -np -N [url] & wget -r -np -N [url]

Just repeat the wget -r -np -N [url] for as many threads as you need… Now given this isn’t pretty and there are surely better ways to do this but if you want something quick and dirty it should do the trick… Enjoy!

Tags: , , , , ,

Enabling Autocomplete by reverse searching history in Linux

Being a FreeBSD user I just got used to a very nice feature that would allow me to autocomplete commands based on my history.  So for example if 15 commands ago I had typed ‘cat filenames1 > filename2′ and I wanted to retype that command I could just type ‘cat’ and then press up and it would go through my history and bring up the last command I typed starting with ‘cat’ until I got back to the desired command, only bringing up those in my history starting with ‘cat’ of course.

Unfortunately this isn’t the way it works in linux, in linux pressing up, no matter how much you’ve typed so far will just take you back through the command history.  Sure you can press ctrl-r but I couldn’t be bothered to figure that out.  Besides there is a much cooler way to go about it.

what you  do is to edit /etc/inputrc:
vi gedit /etc/inputrc

somewhere around line 40 is the following:

# alternate mappings for “page up” and “page down” to search the history
#”\e[5~”: history-search-backward
#”\e[6~”: history-search-forward
Uncomment those lines, close term and open an new one and viola!  It works the same but with page up and down instead.  Beauty!  If you didn’t know about this at all go in there and turn it on right now because man this is a time saver and a half.  You’ll thank me later!

Tags: , , , , , ,

Importing / Loading a Mysql backup / database from a .sql file – In Shell

I was appalled when the first page of search results for this came up with instructions on how to do this for a Windows server.  So I felt it my duty to add to the tutorials out there for people actually running a real web server (BSD/Linux/Etc)

Parse in the .sql file into an already existing DB

In shell simply issue the following command

$ mysql -u root -p db-name < backup-file.sql

To create a new DB and then import

Login to Mysql:
$ mysql -u root -p

Now create database called sales using SQL statement:

mysql> CREATE DATABASE myDB;
mysql> quit;

Now restore database, enter:
$ mysql -u root -p myDB < /path/to/your-DB-file.sql
Easy Peasy isn’t it?

Tags: , , , , , , , ,

How to update php5 or any port in BSD

Well I figured I would join the throng of blogs with a brief run down of cvsup , considering I just wrote a nice email about it and all I have to do is copy and paste to share it with the world :

Basically you just need to install cvsup by compiling and installing it

So head over to /usr/ports/net/cvsup and do a make && make install as root

After that is all installed

copy /usr/share/examples/cvsup/ports-supfile to a new location, such as /root or your home directory.
1. Edit ports-supfile you just moved to /root
2. Change CHANGE_THIS.FreeBSD.org to a CVSup server near you.  IE: cvsup.FreeBSD.org
3. You also want to scroll down and make sure the line “ports-all” is commented out and simply scroll down and uncomment out the ports-lang only.  This will make sure it only updates that tree instead of the entire thing.  (however you can ignore that last steo if you want to do a complete update) Save the file
4. Now to run cvsup, use the following:
# csup -L 2 -h cvsup.FreeBSD.org /usr/share/examples/cvsup/ports-supfile

or
# cvsup -L 2 -h cvsup.FreeBSD.org /usr/share/examples/cvsup/ports-supfile

Then go into /usr/ports/lang/php5 and do a quick make(as root) and then make install

Viola php5 is updated

Tags: , , , , ,

Page optimized by WP Minify WordPress Plugin