Handy Linux Admin Commands

Permissions Management

  • ls -al – list all contents of a directory along with permissions
  • chmod a+x program.rb – makes script “program.rb” executable (x) by all (a) users
  • chown user:group filename – changes the owner and group of “filename”
  • chgrp -R users home/ – assigns directory “home/” and contents to group “users”
  • cat /etc/passwd – shows all users on a system
  • cat /etc/group – shows all groups on a system

Disk space

  • du -h – lists all child file names/sizes (careful, this can list every file on your computer if you execute while in “/”)
  • df -h – prints used/available disk space on drives
Posted in Uncategorized | Leave a comment

Setup a Minecraft Multiplayer Server on the Rackspace Cloud with Ubuntu

Using a Rackspace Cloud server is a cheap, easy and fast way to setup a Minecraft multiplayer experience. The server size I use only costs $.03 an hour which works out to around $20 a month. This mini setup guide will take you about 10 minutes to an hour depending on how comfortable you are with the command line.

Pre-requisites

  • Setup a Rackspace Cloud Account if you don’t already have one. You should have Cloud Servers enabled.
  • An SSH client. On windows, use Putty. For Linux or Mac OSX, use the command line tool called ‘ssh’. On Ubuntu/Debian, you can easily type ‘sudo apt-get install ssh’.

Create your cloud server

This is the standard method for creating a basic Rackspace Cloud server.

  • Login to the Control Panel
  • Click Hosting > Cloud servers
  • Click ‘Add Server’ then click ‘select’ next to ‘Ubuntu 11.04 (Natty Narwhal)’
  • On the next page (Server Configuration) set the server name to ‘minecraft’ and your server size to at least 512MB/40GB.
  • Click ‘Create Server’
  • Copy the root password and store it some place safe. Close the window that popped up.
  • You are now on the server details page. Under the sub-heading ‘Technical Details’, copy the IP address.

Server setup basics

You will need to install some software before you can begin. On windows, use Putty to create a new connection to your server, entering username, password and IP. If you are using linux/Mac, enter the following into a command prompt, followed by your password when prompted:

ssh root@[yourServerIP]

Install Sun Java

This line will allow us to use command line tools to update the source repositories. If you are not root, you will need to add ‘sudo’ to the beginning of each command.

apt-get install --reinstall python-software-properties
dpkg-reconfigure python-software-properties

Add the repository that contains our sun java package.

add-apt-repository "deb http://archive.canonical.com/ lucid partner"
apt-get update

Begin the java installation. Accept all the defaults by pressing [enter]. You need to also accept Oracle/Sun’s license agreements, it will be a blue/white screen.

apt-get install sun-java6-jre

Test to ensure a successful installation:

java -version

The response to this command should be similar to the following:

java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)

Install Screen

Screen is a tool that allows you to keep your Minecraft multiplayer server running without having to stay logged into the server.

apt-get install screen

Setup Your Minecraft user

For security purposes, you should setup a different user that will actually run the Minecraft server. Type the following. When prompted, enter your password and accept all other defaults by pressing [enter].

adduser minecraft

Finally, log out of your root account:

exit

Setup the Minecraft server

Login as the [minecraft] user you created in the prior step.

SSH into your server using the Minecraft user you created in the previous step. With Windows Putty, simply create a new connection and insert your username/password/IP. In linux/MacOSX, type the following from a command prompt:

ssh minecraft@[yourIPAddress]

Download and Unpack Minecraft

Download the minecraft server using the linux tool ‘wget’.

wget https://s3.amazonaws.com/MinecraftDownload/launcher/minecraft_server.jar

Run the server with screen

screen -dmS minecraft java -Xms256M -Xmx512M -jar minecraft_server.jar nogui

If you get no errors, than your server is now starting up. It should take about 15 to 30 seconds to finish generating worlds and finish starting-up. To check on it, use screen to see how it is progressing:

screen -r minecraft

If you see the following, your server is now ready to use:

'2011-11-25 17:49:46 [INFO] Done (9753734653ns)! For help, type "help" or "?"

Since the server is now running, detach from your screen session by pressing [control]-[a]. Type the letter [d] and hit [enter].

Now, open minecraft on your home computer and craete a new multiplayer server. Use the IP address of your server. Enjoy! Remember, the Minecraft multiplayer version must match the Minecraft client installed on your home computer.

Posted in Uncategorized | 2 Comments

Add user w/ sudo on Ubuntu

adduser [newusername] sudo

Posted in Uncategorized | Tagged | Leave a comment

Salesforce Chatter API integration notes and tools

Here is a good video primer on the API. More documentation in PDF.

Posted in Uncategorized | Tagged | Leave a comment

Salesforce dataloader for Macs – LexiLoader

LexiLoader

Posted in Uncategorized | Leave a comment

Git cheat sheet

http://help.github.com/git-cheat-sheets/

Some of my favorite commands

  • git diff 26b8be988f885efe617fc39ebd5024d062c2ad4c --stat – shows what files have changed between current revision and previous commit
  • more to come…
Posted in Uncategorized | Leave a comment

Movies for Geek Kids

Like any good parent, I want to ensure my child receives the best education and up-bringing that reflects my values. What better way then to expose them to a bunch of movies!!!

What makes a geek movie?

To provide me with some guidelines for selection, I have defined criteria for this list. The movie must be significant in one of the following ways:

  1. Visual effects
  2. Technology & humanity – provide social, cultural, or philosophical commentary on the subject. Comedy is acceptable.
  3. Geek storyline – tell a story that resonates with geeks (geek kid is outkast, learns technology, saves world, gets girl)

Pre-teens

Here is a list that will get my daughter started with a proper geek cultural education.

  • Tron
  • Goonies
  • The Never Ending Story
  • Chitty Chitty Bang Bang
  • Willy Wonka and the Chocolate Factory
  • Star Wars series
  • The Last Starfighter
  • Time Bandits
  • The Dark Crystal
  • War Games
  • Back to the Future
  • Short Circuit
  • Star Trek
  • Space Balls
  • Indiana Jones & the Raiders of the Lost Ark
  • Indiana Jones & the Temple of Doom
  • The Lord of the Rings (1978 animated)
  • Superman
  • The Fifth Element
  • Real Genius
  • D.A.R.Y.L.
  • Bill & Teds Excellent Adventure
  • Flight of the Navigator
  • Labyrinth
  • Iron Giant
  • The Incredibles
  • Justice League: The New Frontier
  • Willow
  • City of Ember

Teens

When she gets older, we will start on these.

  • Terminator
  • Monty Python and the Holy Grail
  • Metropolis
  • Brazil
  • Alien
  • Bladerunner
  • Planet of the Apes
  • The Matrix
  • Lord of the Rings Series
  • Akira
  • Pi
  • Sneakers
  • Weird Science
  • 12 Monkeys
  • Hackers
  • Fahrenheit 451
  • Rocky Horror Picture Show

Sources

Posted in Uncategorized | 4 Comments

Security testing resources

These resources were suggested by a colleague of mine.

You can get a lot of these tools in one easy place using the OWASP LiveCD

  • WebGoat
  • Gruyere – Once you start the app, go through all their challenges. Some can get challenging
  • Proxies
  • Mailing Lists
    • http://www.securecoding.org/list/
    • http://lists.webappsec.org/mailman/listinfo/websecurity_lists.webappsec.org
    • http://www.securityfocus.com/archive/101/description
  • OWASP Docs Top 10
Posted in Uncategorized | Leave a comment

Create a search index of DVD movie data with SOLR

Install was tested on Ubuntu 10.04

Install Tomcat

I based my install on this How-to.

Use package manager to get relevant docs
sudo apt-get install tomcat6 tomcat6-admin tomcat6-common tomcat6-user tomcat6-docs tomcat6-examples

Test the install by starting tomcat:
sudo /etc/init.d/tomcat6 start

Visit the server in a browser, or try:
wget http://localhost:8080

Some other handy requests for tomcat
sudo /etc/init.d/tomcat6 stop
sudo /etc/init.d/tomcat6 restart
sudo /etc/init.d/tomcat6 status

Now that we have a working copy of Tomcat. We are ready to move on to the Solr installation.

Install Solr

Again, package manager for solr. I just found a solr/tomcat bundle, so I’ll just use that. This operation will restart Tomcat as well.
sudo apt-get install solr-tomcat

Check that Solr is working in a browser, or try:
wget http://localhost:8080/solr

We now having a working install of Solr on Tomcat. I recommend you walk through the small Solr tutorial, it will give you a quick understanding of how to do some basic things, such as creating, reading, updating and deleting data. I would first download a tar of a working release so that you can get the examples. Skip to the “Indexing Data” heading, as you already have a working copy of Solr on Tomcat.

Clear out test data

We will create a small XML file that will be used to clear all data from the index.

Create the xml file that you will post to the service
vim delete.xml

Paste the following into the file
<delete><query>*:*</query></delete>

Post the file using CURL
curl http://localhost:8080/solr/update --data-binary @delete.xml -H 'Content-type:text/xml; charset=utf-8'

We now have any empty index, ready to modify and load.

Download and Review the Movie DVD Database via CSV

Although I wanted to use IMDB, the data they provide for download is in a wacky, non-standard format. Instead, I found a little project that focuses on cataloging all DVDs ever released in region 1. We will use that instead.

Download the CSV and unzip
wget http://www.hometheaterinfo.com/download/dvd_csv.zip
unzip dvd_csv.zip

Take a moment to review the file labeled dvd_csv.txt. You will notice it is a pretty standard CSV document, the first line is dedicated to headers. Those headers will be used to define the search fields.

Define your Solr data schema

Update your Solr schema
vim /etc/solr/conf/schema.xml

Comment everything out between “<fields>”. Insert the following into the document:
<fields>
<!--DVD_Title,Studio,Released,Status,Sound,Versions,Price,Rating,Year,Genre,Aspect,UPC,DVD_ReleaseDate,ID,Timestamp-->
<field name="DVD_Title" type="text" indexed="true" stored="true" />
<field name="Studio" type="text" indexed="true" stored="true" />
<field name="Released" type="text" indexed="true" stored="true" />
<field name="Status" type="text" indexed="true" stored="true" />
<field name="Sound" type="text" indexed="true" stored="true" />
<field name="Versions" type="text" indexed="true" stored="true" />
<field name="Price" type="text" indexed="true" stored="true" />
<field name="Rating" type="text" indexed="true" stored="true" />
<field name="Year" type="text" indexed="true" stored="true" />
<field name="Genre" type="text" indexed="true" stored="true" />
<field name="Aspect" type="text" indexed="true" stored="true" />
<field name="UPC" type="text" indexed="true" stored="true" />
<field name="DVD_ReleaseDate" type="text" indexed="true" stored="true" />
<field name="ID" type="text" indexed="true" stored="true" />
<field name="Timestamp" type="text" indexed="true" stored="true" />
</fields>

After the closing “</fields>” tag, make sure that everything is commented out except for the following lines:

<uniqueKey>ID</uniqueKey>
<solrQueryParser defaultOperator="OR"/>
<defaultSearchField>DVD_Title</defaultSearchField>

Restart Tomcat
sudo /etc/init.d/tomcat6 restart

Revisit your admin page to ensure there are no errors.

Index the data

Index the data in the CSV
curl http://localhost:8080/solr/update/csv --data-binary @dvd_csv.txt -H 'Content-type:text/plain; charset=utf-8'

Search some fields

Now open SOLR Admin interface and enter some values.

Voila!

Posted in Uncategorized | 2 Comments

Set up xterm to run remote window sessions

Thanks to the Savich for the tip on this one!

# Install xterm on ubuntu
sudo apt-get install xterm

# From X-11 terminal on my Mac, enter
ssh -c blowfish -X joe@host.com

# Once you have authenticated, enter the following:
xterm

# Test it with Firefox
sudo apt-get install firefox
firefox

Posted in Uncategorized | Leave a comment