As mentioned in the previous post, I’ve been playing around with my own LAMP (Linux, Apache, MySQL, PHP) stack, and in this post I’ll talk a little bit about my experience installing Apache on my System76 laptop.  Apache is one of the most popular web servers, and runs primarily on Linux.  Apache is a web server, which means it provides web pages in response to HTTP requests.  If you ask for a file called “index.html” that’s stores on any old computer, you won’t get the file.  What you need is a web server like Apache, which processes HTTP requests for HTML files (among other types) and delivers them to the connecting computer.  PHP is a common web scripting language that can execute small programs within an HTML environment.

There are three “programs” we’ll install to finish our LAMP stack (since after my post last time we already have the Linux and MySQL part).  The first is the core Apache module:

sudo apt-get install apache2

.  Next we add PHP:

sudo apt-get install php5

.  Lastly we add a library module that helps them work together:

sudo apt-get install libapache2-mod-php5

.  To get it to get along famously with PHP5 we need to actually enable the module that we just installed:

sudo a2enmod php5

.  When we installed Apache, the service started running, and so now we need to restart the service so that it runs with the PHP5 module we added:

sudo service apache2 restart

(this can also be accomplished with

sudo /etc/init.d/apache2 restart


Now you’re ready to start adding content you want to access through the web.  The default folder for many distributions is /var/www/.  Generally speaking, this is where you’ll put content you want publicly available (or where you’ll put stuff for testing purposes, depending on how you’re using your server).  To access these files, you’ll have to open them through a web browser (Chrome is my browser of choice; just make sure you’re aware of each browser’s peculiarities when you’re constructing scripts).  If you’re testing the files from the computer where they’re stored, you can put in http://localhost/test.php (for example).  If you’re accessing the files from another computer on an intranet or over the internet, you’ll put in the IP address or domain name, of course.  Since PHP is parsed through the web browser, the files will probably download if you try to open them from Nautilus (or the file manager of your choice), so make sure you’re actually putting in a URL in a browser.


April 26, 2014

I’ve been trying to learn a bit more about MySQL recently, and decided the other day to install the MySQL server on my desktop so I can so some experimentation from my laptop.  Presumably this could also be done with virtual machines, but I figured two separate machines would make it a little more realistic.  This is a great way to experiment a little with SQL if you want to learn web forms and database access better.

The first step was to install MySQL server on my desktop and MySQL client on my laptop.  Supposedly at least the client is usually installed with many Linux distributions, but on my Ubuntu laptop I had to add it myself.  This can be done with a standard sudo apt-get install mysql-client, followed by the same thing for the server on my desktop: sudo apt-get install mysql-server. During MySQL server installation you’ll be asked to set a root password; as always, make this something secure and memorable. The default settings for MySQL server are to allow connections only from the host computer. The configuration settings are stored (at least under Ubuntu) in the /etc/mysql/my.cnf file. You’ll need to find the line in this file that says bind-address (or it may just say localhost) and comment it out by putting a # at the beginning of that line. This shouldn’t introduce any security issues as long as you’re on a local intranet that you trust, and your router isn’t configured to forward SQL packets on port 3306 (the default for MySQL, though you can make it anything you want). Lastly, you’ll have to actually start the service: sudo net service start mysql.

Now you should be able to actually use MySQL on your server. To be able to do anything, though, you’ll need to grant yourself privileges. This has to be done from the system running MySQL server, either sitting physically in front of it or using SSH (I did the latter from my laptop). The basic usage for running MySQL is mysql [-h host] [-u user] [-p], where each bit in brackets is an optional argument. If you’re running commands from the server, you don’t need to enter a host address, but I found that I did need to specify the root user, so I used mysql -u root -p (the -p signifies that we’re using a password). Assuming you’re using the -p option, you’ll be prompted for a password (in this case the root password), and then if everything is configured properly you should see a mysql prompt.

To grant privileges in MySQL you use the grant command, which takes arguments for which privileges you want to grant, which database you’re granting privileges to, and what user is begin granted privileges. In a test situation like this, I wanted to grant all privileges for all databases to my username on my laptop, so I used the command grant all on *.* to 'username'@'hostname'; (don’t forget to end all commands with a semicolon!). For me that took care of any connection and authentication issues, and I was able to connect to the MySQL server on my desktop from my laptop. In future posts I’ll talk a little about about installing Apache and PHP if you want to play around with web forms as well. Of course this can all be done on a hosted web site, but I think this is a little more fun.

I saw an ad the other day that promised “AT&T covers 99% of Americans”.  Many people would say “Is that true?”  I’m not so charitable.  The question I usually ask is “What does that mean?”  I think there are a few possible interpretations.

The first is that 99% of Americans use AT&T as their wireless provider.  That’s pretty clearly false, and I don’t think at all what they meant, so let’s leave that possibility behind.

The second is that AT&T covers 99% of the U.S., i.e., it’s only in 1% of the country that you can’t get coverage from AT&T.  Looking at their coverage map, this is also obviously false.  There are large parts of the U.S. where there’s no coverage, especially in the midwest and more rural parts of the west.  But given their wording “99% of Americans”, I don’t think they intended this either, though they may be hoping that some people interpret it this way.

The third possibility is that AT&T covers areas where 99% of Americans reside.  I think this is what they meant by the ad, and seems supported by their coverage map, which has good coverage in the more populated areas of New York, New Jersey, Pennsylvania, California, Illinois, Indiana, Wisconsin, Texas, Delaware, Maryland, DC, Virginia, West Virginia, Florida, Georgia, Massachusetts, and New Hampshire, the major metropolitan areas of which account for over a quarter of the U.S. population even if we only count the top 10 cities.  Obviously AT&T really want a 99% claim, and this was how they could do it.

Unfortunately, this still doesn’t get into what “coverage” means.  Looking at the map, you would guess that you probably wouldn’t go with AT&T in Nebraska, because most of the state isn’t covered.  However, you might assume that you could have AT&T in Montana.  Things may have changed in the past few years, but this is the same wireless map I saw when I moved to Montana in 2007, when AT&T did not cover Montana.  They had a deal with Chinook Wireless so that their customers could make and receive calls without roaming charges, but there were no AT&T stores in Montana at all.  So my guess is that this “coverage” map is still wildly inflated, including areas with reciprocal relationships but where customers could not actually have access to service people or retail outlets.

System76 Gazelle Pro review

February 2, 2014

In November I purchased a Gazelle Professional laptop from System76.  I’ve waited a few months to review it because I wanted to live with it for a while.  Since I may gush a little bit, I’ll note that this review is unsolicited and completely uncompensated; I just like to point out when a company’s doing something right.  I decided to go with System76 for my new laptop because of their dedication to open-source software — they use Ubuntu and only Ubuntu on all of their systems.  I went with the Gazelle Pro, well, because it was the cheapest.  At $749 it’s significantly less than the average Mac, but significantly more than a lower-end Windows system.  Since I was already using Ubuntu exclusively on my desktop and old laptop, it was a no-brainer for me.  The only extra I sprang for was an extra battery, since I’ve had problems with past laptops, but there are a number of fantastic upgrades, including SSDs at decent prices for being part of a prebuilt system.

The system boots to the login screen in about 20 seconds, with another 5-6 to load my desktop, which means from a cold start I’m up and running in under 30 seconds.  Shutdown takes significantly less time, about 10-12 seconds from the time I click the  Shut Down button.  The system also supports suspend/resume, but not hibernate.  Battery life during heavy use is a full 3-4 hours, with up to 6 for less power-intensive programs (e.g., web browsing).  I leave it suspended overnight on a regular basis, with no significant decrease in battery charge the next day.

The chassis is an attractive brushed metal finish (though actually plastic), gray with a slight purple tinge in color.  I’d prefer a heavier duty chassis for $700+, but I haven’t had any wear issues yet (maybe I’ll report back in a couple years).  I will say that the fact that the screen is set back from the body (it folds back behind the keyboard, rather than sitting on top of the body) leads me to believe that the hinge will hold up better under strenuous use than the Dells I’ve worn out before.  The 1920×1080 display is really, really nice, and since everything comes preconfigured I didn’t have to do any messing around with display drivers.  The 2MP built-in webcam works great, though I’ve had similar problems with Skype on this computer that I’ve had with other computers running Skype on various versions of Ubuntu (dealing with either echo or no sound at all, intermittently).  The built-in speakers are a little quiet for me, but of course with laptop speakers you’re not going to get great sound quality anyway.  I haven’t used them yet, but I like that the system includes an eSATA port and two USB 3.0 ports (plus an extra 2.0 one).

As far as software goes, the system has worked great so far.  Everything’s nice and fast, the graphics card handles HD video just fine.  I have had a little bit of an issue with software updates: whenever I try to use the graphical interface, it tells me to check my internet connection.  I haven’t investigated the issue further since I usually just use the command line for this anyway.  I’ve had no problems with wifi connectivity, and an improvement over my previous laptop running Ubuntu is that the connection is already established as soon as I open the screen, rather than having to wait for it to reconnect.  While I haven’t used the Bluetooth connection yet, I love that this is available.

Probably the only aspect I was underwhelmed by is the keyboard and the touchpad.  The chiclet-style keyboard (plus 10-key!) is nice, but the keys themselves feel fairly light (I’m talking about the keys themselves, not the tension, which is fine).  I usually like a little more substance in my keys.  I’ve also found that some of the keys don’t register if I touch them too lightly, especially the bottom row (okay, obviously this is theoretically true for all keyboards, but this is the first one I’ve ever had this problem with).  The touchpad is nice and big, with left and right buttons below.  However, I have two issues with it, both of which are related to my personal preferences.  I like side scrolling rather than two-finger scrolling, and it’s hard to zero in on the scrolling part of the touchpad when this is in use (possibly because the laptop ships configured for two-finger scrolling).  I also prefer tap-to-click, rather than always using the left button.  With the sensitivity configured reasonably for pointer use, I’ve found that I often end up clicking on things I didn’t mean to click on (especially when trying to scroll), or, conversely, it takes a few taps to actually get it to register a click.

Overall I’ve been very happy with this laptop so far.  Despite a few things I consider imperfections, I absolutely plan on going back to System76 for any and all future prebuilt systems (and of course I’d love to at some point try out their higher-end models).  It helps that they’re a company dedicated to great customer service and social responsibility (they spend a lot of time and money rehabilitating old laptops for underprivileged students).  I think the Gazelle Pro is also a great introduction to Ubuntu for people who are interested in switching from Windows or Mac but don’t want to have to install and configure the system themselves.

One thing I like about Linux is that things go horribly wrong much less often than Windows (in my experience, obviously it’s possible that your mileage differs).  But the thing I love more is that when things go horribly wrong in Linux, there’s always something you can do about it.  Case in point: a few weeks ago my computer wouldn’t boot after an OS update.  Went through POST just fine, started loading Ubuntu, and then….nothing.  No HD light flickering, nothing on the screen but black and a small blinking cursor.  The first thing I tried was the magic SysRq key, a key combination that the kernel responds to even if most everything else has failed (the most useful combination is Ctrl+Alt+SysRq and, while holding down those 3 keys, press R, then E, then I, then S, then U, then B).  Second boot the same thing happened.

Then I tried the trusty recovery console.  But hey, Windows has that too, right?  The difference is that Linux is at its core a text-based operating system, which is what scares away a lot of potential users — even though Ubuntu is very graphical and IMO very user-friendly, it’s really hard to get through a month or even a week without having to do SOMETHING at the command line.  But that’s also what’s great if something goes wrong.  Even from the command line you have a full-featured operating system capable of networking, system updates, and even playing mp3s.  In my case it turned out that the system was booting just fine, but was hanging when loading the display manager.  For Windows users who are over 30, this is similar to being able to load DOS, but Windows won’t boot and so you don’t have any graphical environment with which to play Ski Free and get eaten by a yeti (i.e., a really distressing situation).  The first thing I tried was reloading the display manager manually: sudo service restart lightdm.  (I’m using Ubuntu with Unity, so my display manager is lightdm.  There are other display managers.)  This generated the same hang as when I tried to boot normally.

After doing some research (what did we do before laptops and smartphones?) it sounded like I was having a problem with updated packages, so I tried uninstalling and reinstalling Unity.  No dice.  Then I found the real problem: my video card drivers.  Luckily I use the command line a lot for installing and uninstalling packages, and I was familiar with the packages I needed for my video card, so after uninstalling and reinstalling those, everything worked just fine.

As a summary for anyone dealing with similar problems, here’s my general troubleshooting list:
1.  Reboot the computer, using the magic SysRq key if nothing else works (do NOT do a hard reset with the power button unless absolutely necessary)

2. Boot to the command line (with networking)

3. Start or restart your display manager (the most common with Ubuntu is lightdm)

4. Uninstall and reinstall Unity (try unity –reset first, then unity –replace, then try sudo apt-get remove ubuntu-desktop && sudo apt-get install ubuntu-desktop)

5. Uninstall and reinstall video card drivers (depends on your card: for NVIDIA the most useful package I’ve found is nvidia-current, so you’d do sudo apt-get remove nvidia-current && sudo apt-get install nvidia-current)

6. Bask in glory?  If you’re still having display problems I feel bad for you son.  I got 99 problems but a bad video card ain’t one.

encryption on the internet

October 26, 2013

When you see “https” instead of “http” in your address bar, you can typically rest assured that your connection with the web site you’re visiting is encrypted.  This is done through TLS/SSL, a method of encryption that works with a number of transfer protocols (HTTP, or Hypertext Transfer Protocol, is one example of a transfer protocol).  In most cases the encryption is paired with a public key certificate, which is a digital document that links a public key (used to encrypt the information) to a specific organization.  These public keys let you know who you’re actually dealing with.  Helpful web browsers will give you warnings if there’s any kind of mismatch between who the public key belongs to and who’s actually using it.  For instance, you might get a message telling you that a server is identifying itself as, but that the key it’s using belongs to

Occasionally this is because of a genuine attempt to scam you: someone’s using a pirated key and presenting themselves as, say, your bank, when in fact they are trying to steal your login information so they can gain access to your bank account.  Fortunately, this is often because large organizations don’t obtain separate security certificates for each one of their many servers.  Because the servers have different (but usually very similar) names, the browser thinks someone is trying to present themselves as someone they’re not.  Unfortunately, because this can sometimes be a real attempt to steal your personal information, you should always be very cautious about accepting these spurious certificates.  I always recommend checking with your IT administrator before going forward.  This usually means extra time for you and them (writing and waiting for responses to emails), but it’s better than falling victim to a man-in-the-middle attack, where someone can intercept your information in transit and neither you nor the web site are any the wiser.

SSH (Secure Shell) is a method of connecting to a computer remotely, giving you (depending on user permissions) full access to the files on that computer.  Obviously this is a huge security risk — if someone cracks your password, they’ll have complete access to your computer.  For this reason is generally recommended not to use passwords at all with external SSH connections, and so I’ll just be mentioning using SSH to connect to other computers on your local intranet.  Why use SSH?  While Windows has all sorts of relatively easy (and head-bashingly buggy) tools like “Network Discovery”, Ubuntu doesn’t default to easy intranet sharing like this.  In fact, this was one of my biggest frustrations when I first switched to Ubuntu, until I found SSH.

To install SSH, simply type “sudo apt-get install ssh” at the command line.  As usual you’ll be prompted for your root password.  Unless you already have ssh installed you will be prompted to download and install the package.  Once the ssh package is installed, you can use it either from the command line or directly from your workspace.  Unlike many utilities, I don’t usually use ssh from the command line.  I like visual file managers, so I like being able to use Nautilus to browse the files on the computer I’m connecting to.  To connect, I select “Connect to Server” from either my workspace or a nautilus window.  Then I enter the IP address of the computer I want to connect to.  This is information you can get via ifconfig on the computer in question, and will probably (depending on the size and topology of your network) be something like or 10.0.0.x, etc.  For “type” I select “SSH”; doing this automatically fills in the default port number of 22.  I leave the folder as root (/) and enter my username and password for the computer I’m connecting to.  I click “Connect”, and nautilus opens a window showing the file structure of the computer.  That’s it!  Now I can open and edit documents on the remote computer.

I’ve found this to be the easiest way to read and edit files on my desktop computer.  Certainly there are other ways, but if I use SSH to connect to my desktop, say, from my laptop in the living room, I can easily access everything I need, not just files I’ve put in a shared folder.  The method for connecting to your computer from outside your local network is more complicated and much more dangerous.  Typically if you’re going to try this you want to use keys instead of passwords and possibly also change the port used for SSH on the computer you’re connecting to.  I’ve never actually tried this, but it will be something I cover in a later post when I get around to working through the process.