Click to search Andy Jarrett.co.uk RSS feed

Loading Twitter

Copy/moving files from mulitple sub-directories to the parent

Since moving to Mac I use the terminal more and more. Today I had an issue of having wanting to move 1000 files in 50+ sub folders to the parent. A quick Google search didn't come up with anything so I figured it couldn't be too hard.

My directories went like this

/parent /parent/subfolder1/file.1 /parent/subfolder1/file.2 /parent/subfolder1/file.3 /parent/subfolder2/file.1 /parent/subfolder2/file.2 and so on .... in reality each subfolder had 20 files in it.

So to copy the files out was easy: [sourcecode language="plain"]cp -r ./* ../[/sourcecode]

Swap the cp for mv to move them

Comments Comments (1) | Print Print | Send Send | 272 Views

Max your CPU

I was at the Apple store yesterday with the need to run both my CPU's at max for some tests. The "Genius" put the following in two separate Terminal windows
Yes > /dev/null

The YES commandsimply sends an endless stream of y’s to standard output until killed. The reason the guy did it twice is to ensure that both CPU's are being used. This should work on any *nix machine but if you only have 1 CPU you only need to do it once

If are even to lazy to open two windows you can just put the following in one:
Yes > /dev/null & Yes > /dev/null

Comments Comments (1) | Print Print | Send Send | 237 Views

My blog has moved

Please update your bookmarks and feeds for my site.

I now have a Mango Blog at:

http://www.andyjarrett.com/blog

Feed URL: http://feeds.feedburner.com/andyjarrett

Comments Comments (0) | Print Print | Send Send | 1196 Views

Slicehost VPS

As you can probably tell from the recent posts I have moved my host over to a linux VPS, at Slicehost.com. Without sounding to tacky it was built by developers, for developers. No overly complicated control panels it just works. On top of that they have some excellent documentation on there site for helping you setup your box with only the basic Linux knowledge.

From the site:

Sick of oversold, underperforming, ancient hosting companies. We took matters into our own hands. We built a hosting company for people who know their stuff. Give us a box, give us bandwidth, give us performance and we get to work. Fast machines, RAID-10 drives, Tier-1 bandwidth and root access. Managed with a customized Xen VPS backend to ensure that your resources are protected and guarante

Check out their questions and community sections. Even if you're not setting up a VPS just yet their articles cover setting up a linux server so well, including SSH users, iptables etc.

If you do sign up with Slicehost.com, please feel free to use my referal link https://manage.slicehost.com/customers/new?referrer=5326d19c676e950dfab1fc8aaa724b6c :)

Comments Comments (2) | Print Print | Send Send | 2360 Views

Checking propagating of domain name

When you move servers one of the annoying parts can be waiting for the domain to propagate when you change name servers. There is a terminal tool though for checking the settings, dig(domain information groper) is a tool for interrogating DNS name servers.

You'll need to install the dnsutils package

view plain print about
1$ sudo apt-get install dnsutils

After that It's pretty easy, simply put in the terminal:

view plain print about
1$ dig google.com

Obviously swap google for your domain name that your are checking.

Read more here

Comments Comments (1) | Print Print | Send Send | 1154 Views

Another Linux Railo MySQL install guide (no Apache)

This was meant to be a guide about setting up your server with Linux, Railo, Apache, and MySQL but I've dropped Apache. Why? Well its an overhead I don't need. Resin functions perfectly well as a HTTP server and it does all I need. Why add another bit of software to fail? .... simplify :) In the long run I might change but for now I'd rather save the resources.

So ... where did this guide come from considering there are quite a few guides for this setup? Well for one reason or another I just didn't get on with them and by the end something went wrong which was mainly because I am Mac boy more than a Linux guy and sometimes I just missed the points here and there. The aim of my guide is to be clear and simple. So with a fresh Ubuntu install i'm planning on gettingt Railo running via Resin so I can call http://www.mysite.com/index.cfm

I won't lie, to make this post I have "borrowed" from other sources out there which I will try and link to at the end.

Im running Ubuntu 8.10 (Intrepid) without a graphical interface.

Note: If you are doing this on a clean, new server then before you even read on check out Slicehost.com documentation about setting up a Ubuntu server. These guides are the best and clearest I've seen online to date and cover everything you need!!!!

  1. http://articles.slicehost.com/2008/11/28/ubuntu-intrepid-setup-page-1
  2. http://articles.slicehost.com/2008/11/28/ubuntu-intrepid-setup-page-2

On to Railo

  1. On your ubuntu server, open the Terminal and run:
    view plain print about
    1$ sudo apt-get install build-essential apache2 sun-java6-jdk
    This will install all the pieces you need for Java and compiling. If there are any problems installing Java then check out http://www.javadesign.info/SystemsHardware/OS/Ubuntu/install-java-on-ubuntu
  2. We are going to install Railo into the /opt/ folder. So next we are going to move in to the /opt/ folder and download Railo;
    view plain print about
    1$ cd /opt
  3. Go to Get Railo.org and the Download section. Find the links under Railo Server and copy the link for the ALL OS, tar.gz, and without JRE version. Currently this is http://www.getrailo.org/down.cfm?item=/railo/remote/download/3.1.0.012/server/all/railo-3.1.0.012-resin-3.1.2-without-jre.tar.gz
  4. With this link copied go back to the terminal and type $ wget {paste the URL link here with out the brackets}. So with the current URL your terminal syntax will be
    view plain print about
    1$ wget http://www.getrailo.org/down.cfm?item=/railo/remote/download/3.1.0.012/server/all/railo-3.1.0.012-resin-3.1.2-without-jre.tar.gz
  5. We now have the downloaded Railo server in /opt/ and we're gonna unpack this with the following command
    view plain print about
    1$ sudo tar -xf railo-3.1.0.012-resin-3.1.2-without-jre.tar.gz
    This command will unpack the Railo file you downloaded in to a folder called "railo-3.1.0.012-resin-3.1.2-without-jre".
  6. Don't worry about the long folder name for now as we will create a symbolic link in the next step to make referencing it easier.
    view plain print about
    1$ sudo ln -s railo-3.1.0.012-resin-3.1.2-without-jre railo
    2    $ sudo chown -R {your username} railo
  7. A quick recap; at this point we have Java, Railo, and Resin installed and we are ready check we've done it right by firing up Railo
    view plain print about
    1$ /opt/railo/bin/httpd.sh
    now go to http://localhost:8600/ and Railo should be running and a link to the administrator. At the moment the only way to stop this service is with ctrl-c. Later on will start this in the background by adding an argument but before we continue ctrl-c in the terminal to stop Railo/Resin.
  8. This is all well and good, but its not running off port 80 which is what most people, if like me, want. We're going to edit the Resin.conf file now and change the port from 8600 to port 80
  9. Open the Resin.conf file
    view plain print about
    1$ sudo nano /opt/railo/conf/resin.conf
    look for the line <http address="*" port="8600"/>, we're going to change the port to 80
    view plain print about
    1<!-- The http port -->
    2<http address="*" port="80"/>
  10. For each site you need edit the Resin configuration file again. Im going to add my sites to the directory /var/www/. So lets create our first site
    view plain print about
    1$ mkdir /var/www/mysite
  11. Now edit our Resin.conf file at /opt/railo/conf/resin.conf
    view plain print about
    1$ sudo nano /opt/railo/conf/resin.conf
    Then around line 250, just before the following comment <!-- configures the default host, matching any host name --> add a host and host-alias's if you use them:
    view plain print about
    1<host id="mysite.com" root-directory="/var/www/mysite">
    2    <web-app id="/" root-directory=""/>
    3    <host-alias>www.mysite.com</host-alias>
    4    <host-alias>www.mysite.co.uk</host-alias>     
    5</host>
    You can find out more about this here. Its even possible to use RegEx in there as well.
  12. Now restart the server
    view plain print about
    1$ sudo /opt/railo/bin/httpd.sh start
    This time we have passed "start" to the Resin command, this will load it as a service in the background. Then go to http://mysite.com and check it all work.

References:

Comments Comments (3) | Print Print | Send Send | 2655 Views

Finding out memory usage on Linux

Since having my own server I'm becoming a little OCD on memory usage.

There are two tools I have been using which are

  1. Top:
    view plain print about
    1$ top
    Once its loaded press shift-m to sort by memory. You can read more here
  2. Free
    view plain print about
    1$ Free -m
    This is a high level view of whats being used and whats free. You can read more about this here. Don't worry about the first line of output here its always close as Linux automatically uses all the RAM you've got for caching etc. The second line is usage without counting the OS-internal buffers and cache and is the "real" RAM utilization. * (Thanks to Barney Boisvert for his help on better understanding these :))

Comments Comments (1) | Print Print | Send Send | 1190 Views

Getting remote access to MySQL

After setting up my server yesterday I had issue with getting remote access to MySQL it was like it wasn't even running. After some digging around and annoying a linux user (always make sure you know a *nix admin guy, and buy him a scotch or two to say thanks) I found out is was running and it just wasn't bound to the machine's IP address but instead to localhost. For security reasons remote access disabled, but sometimes you need it for one reason or another.

  1. Login via SSH
  2. Edit the my.cnf. On Ubuntu you can do this
    view plain print about
    1$ sudo nano /etc/my.cnf
  3. Once file open look for bind-address=127.0.0.1 and change it for your host machine IP address. So if you host machine is 10.0.1.1 your configuration file would look like:
    view plain print about
    1# Instead of skip-networking the default is now to listen only on
    2# localhost which is more compatible and is not less secure.
    3bind-address = 10.0.1.1
  4. Save, close and restart your mysql service to take change in effect
    view plain print about
    1$ /etc/init.d/mysql restart

Comments Comments (4) | Print Print | Send Send | 1548 Views

How to unzip on Ubuntu

More for my reference but extracting Zip files in Ubuntu from the command line is pretty straight forward

view plain print about
1$ sudo apt-get install unzip

This should install the unzip utility for you. Then to unzip it's pretty straight forward

view plain print about
1$ unzip {file}
Where {file} is your .zip archive.

Comments Comments (0) | Print Print | Send Send | 8001 Views

Setting up Apache and Subversion on JeOS (Ubuntu)

I'll be honest, I don't have much linux experience. I've always liked the idea of Linux and a command line driven OS but as soon as I see the GUI I tend point and click, which means I don't learn anything new. Then comes along JeOS (Just enough OS, pronounced as "juice") from Ubuntu which doesn't give you a GUI, it just gives you the bare minimum to run a server. It's designed for VM's and perfect for running a Subversion server on your local machine in the background. The specs are:

  • Less than 100Mb ISO image
  • Less than 300Mb installed footprint
  • Specialised -virtual Kernel 2.6.24
  • Optimised for VMWare ESX, VMWare Server and KVM
  • Intel or AMD x86 architecture
  • Minimum memory 128M
  • No graphical environment preloaded as it is aimed at server virtual appliance

So with JeOS and VMWare Fusion armed I was ready to setup a light-weight Subversion and Apache server. Below documents what I did to get a single SVN repository up and running. Im not installing Trac or SSL with this just so you know. I might try and cover them later, along with multiple repositories.

Setting up JeOS with VMWare fusion is no different than setting up any other VM so I won't go over that here. I'll assume that you can do that, and have done that and now at the command prompt.

Obviously because there is no GUI supplied all commands have to be run from the Command Line/Terminal. This also means editing txt files from the terminal too. If you've never used VIMM you might want to have the following URL handy www.gnulamp.com/vi.html

First things first, lets make sure your install is up-to-date.

view plain print about
1$ sudo apt-get update

We're going to get curl to help with HTML checking later

view plain print about
1$ sudo apt-get install curl

We need vim to edit some files (If you need help with Vi check out http://www.gnulamp.com/vi.html)

view plain print about
1$ sudo apt-get install vim

Install Apache

view plain print about
1$ sudo apt-get install apache2
This command will not only install Apache, but will start it up as well. You can check that its running by using CURL and the following command
view plain print about
1$ curl http://localhost
You should see something like:
view plain print about
1<html><body><h1>It works!</h1></body></html>

To view this from this from outside of the VM i.e. your host machine, you need to get the IP address which you can do with the following command.

view plain print about
1$ ifconfig eth0
In the response look for inet addr. You should then be able to hit the IP address from your host machine and see "It works!" on your screen.

Install SVN

view plain print about
1$ sudo apt-get install subversion

Install LibApach2

view plain print about
1$ sudo apt-get install libapache2-svn

Note: For neatness we could of written the above to lines as

view plain print about
1$ sudo apt-get install subversion libapache2-svn

Create SVN folders

view plain print about
1$ sudo mkdir /var/svn
2$ sudo mkdir /var/svn/MyFirstRepos

Set up SVN folders

view plain print about
1$ sudo svnadmin create /var/svn/MyFirstRepos
2$ sudo chown -R www-data /var/svn/MyFirstRepos

Create a password file Replace {your name here} with your name i.e. andy

view plain print about
1sudo htpasswd -cm /etc/apache2/dav_svn.passwd {your name here}
You'll be asked to enter a password. Do so, hit return until complete.

No we configure Apache by editing the following file with Vim that we installed at the beginning

view plain print about
1sudo vim /etc/apache2/mods-enabled/dav_svn.conf
The file needs to look like this. To achieve this all you really need to do is remove the comments "#"
view plain print about
1<Location /svn>
2 DAV svn
3 SVNPath /var/svn/MyFirstRepos
4
5 AuthType Basic
6 AuthName "Subversion Repository"
7 AuthUserFile /etc/apache2/dav_svn.passwd
8 Require valid-user
9</Location>

Restart Apache

view plain print about
1$ sudo /etc/init.d/apache2 restart

Thats it, you're done. You can get to your repository via your hosts browser by going to http://{your VM IP}/svn. You should get a username/password dialog which to enter the details you created in.

The final size of my VM is 1.02GB, but with no graphical UI it is only using 25MB of real memory, so leaving it running on a low end machine, which is what I intend will be easy.

Comments Comments (4) | Print Print | Send Send | 4745 Views

More Entries

BlogCFC by Raymond Camden + Twitter @AndyJ + ColdFusion jobs + Contact Me + Snippets/Downloads + RSS .