Posts Tagged ‘linux’

Setting Up a Website on Amazon AWS

// April 21st, 2012 // No Comments » // Digital Walkabout

Amazon AWS Enrollment

After signing up for AWS I was enrolled automagically into their wonder 1-Year Free Tier Service meant as a means of allowing new business’ / users to effectively learn their cloud systems without fear of spending money. Its not only a sharply smart business move, its also an enjoyable experience, as I found earlier this week.

Obviously you can’t go crazy, I’ll leave it to you to check out their FAQs on the Free Tier service.

Before their new GUI into their AWS system it was supposedly some sort of a nightmare requiring 3rd party apps using their API or web-browser plugins like “Elastifox”. *shudder*

Fortunately for you and I, that’s a thing of the past with their new login system at https://console.aws.amazon.com

Instance Wizard

So I went through their Wizard for creating a new EC2 Instance (where you basically go through the process of creating your very own Virtual Machine in the Amazon cloud).

What’s great about this Wizard is that you no longer have to go through the hurdle of figuring how to create the machine, installing the OS (they now let you use virtual hard drives images of pre-installed operating systems).

In my case I went with most of the default options, selected my default image with an install of Ubuntu 11.10 (apparently still have to wait for Ubuntu 12.04 [Precise Pangolin] to make it out of Beta 2) on an 8GB EBS Volume (read: “hard drive” or “virtual hard drive” if you please), Also when I created my default security settings I made to open up ports 80 and 10000. (80 for the obvious reason that if you can’t access this port, a website won’t do you much good, and 10000 to access webmin – my favorute linux web-based administration tool)

Final Instance Setup

Anyhow, after doing that, I requested an Elastic IP address and assigned it to my new virtual machine. Then I “turned on” the computer (or “instance”) within 2 minutes it was fully booted and ready to be accessed.

Linux Server Setup

I promptly proceeded to SSH into my new box (which you can access by use of Java if you right-click on your instance and click on “Connect“.

Be sure to connect as ubuntu instead of root and use your PEM file that you get to download when creating the instance.

Personally I then upload my personalized .bashrc config file and promptly sudo su since that’s my style. Stick to yours and dont bug me, I’ve been on Unix since 1988 and I’m not going to change my habits now ;-)

Next thing’s next I installed a LAMP environment (including phpmyadmin), you can use any method you like – personally I like to manually install each package using apt-get instead of using something like tasksel , but there are plenty of on-line guides for that.

Next I installed webmin :

1. Edit apt sources

Edit /etc/apt/sources.list

At the end of the file, add these two lines, then save and close:

deb http://download.webmin.com/download/repository sarge contrib
deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib

2. Import now the GPG key using these commands:

wget http://www.webmin.com/jcameron-key.asc
apt-key add jcameron-key.asc
apt-get update

3. Install now Webmin with this command:

apt-get install webmin

4. Be sure to set the password:

/usr/share/webmin/changepass.pl /etc/webmin root password

Then enter /var/www/ and viola! You now have a website ready-to-go on Amazon’s amazing new AWS cloud.

 

Last things last would be to install mosh – which if you haven’t heard of this before, consider it the next level in remote login, its as much an advancement above telnet as SSH was. Check out more about it http://mosh.mit.edu

 

add-apt-repository ppa:keithw/mosh
apt-get update
apt-get install mosh

 

Recursive Global Search and Replace in Linux

// June 6th, 2011 // No Comments » // Adventures in File Sitting

I was working on a very old project of mine, a MUD called DooMMUD (based off of the popular id Software series of games) and just for shits n giggles, I thought I would move the codebase over to something newer and more stable like the Circle-based tbaMUD codebase just to see if I could get it up and running again.

At some point I needed to change some Variables and Classes (structs really) over the entire codebase (e.g. coins to credits)

No way was I going to bother editing all the files (if I could even find them all), I would almost definitely miss something.

So I used a combination of grep and xargs & sed to recursively go through every directory in the tbaMUD structure and replace every string or replace every phrase that I needed changed.

Behold the majesty of my one line command:

grep -rl matchstring somedir/ | xargs sed -i 's/string1/string2/g'

We pipe the recursive results from grep into xargs & sed which takes those results and run a global search and replace within each instance of string1 with string2.

Huzzah!

I remember when I was 8 years old, my father had made me an account on his Sun Microsystem Workstation 3/80 running some later version of SunOS. I used KornShell over a matter of person preference (I don’t think BASH was even around back then) and every day I would look into /usr/bin or /bin to look for new command, run man page on it and tinker around with it.

My father said it best when he said “Its like having a Christmas Present every single day”. The man was right.

Manipulating 0 byte or empty files in Linux

// April 23rd, 2011 // No Comments » // Adventures in File Sitting

There are a surprising amount of times I’ve had to manipulate empty files dispersed amongst a large group of variously sized other files.

A long time ago I remember using some convoluted shell script on my Sun Workstation 3/80 (SunOS baby, none of that fancy Solaris whippersnapper!)

Later when I was using Debian, I wrote little TCL (and even later Python) scripts.

Now I’m using Ubuntu on most of my Desktop (or development I s’pose) machines and it seems things just keep getting easier.

Now I found a method that borders on the rediculous easy, using the find command.


find . -type f -size 0 | xargs command

So lets say we just want to list the files MMmkay?


find . -type f -size 0 | xargs ls -l

Or say we want to remove/delete the files


find . -type f -size 0 | xargs rm -f

Of course I know that this isn’t an Ubuntu specific solution (this should obviously work even on older versions of find and pick-your-unix-flavor or even some inferior operating system (*cough*) where you’ve ported over your unix tools to.