I recently learned a new trick (thanks Richard…) and this is how to set it up.  To remote to a computer and then control the console session just type:

shadow 0

To initally set this up you have to do the following:

  1. Open the Group Policy snap-in (Gpedit.msc).
  2. In the left pane, under the Computer Configuration branch, expand theAdministrative Templates branch.
  3. Expand the Windows Components branch.
  4. Click the Terminal Services folder.
  5. In the right pane, double-click Sets rules for remote control of Terminal Services user sessions.
  6. On the Setting tab, click Enabled.
  7. In the Options box, click Full Control with users' permission, and then click OK. (or pick the appropriate option)

(from here)

I've Googled this about 10 times now, maybe if I write it down I'll remember:

rm -rf

The -r means recursive, and the -f means force; which means it will ignore the fact that the directory is full.

I'll start by saying Samba is not as easy as it should be, even when it's fully set up and working, but it gets the job done, and SFTP gets so tedious after a while.

Here's what I had to do to get it working. First, install it:

apt-get install samba

Next, edit /etc/samba/smb.conf and add something like this:

[www] comment = My Shared Stuff path = /my/folder browseable = yes read only = no

(I added it at the bottom of the file so that I could find it quickly)

I reloaded samba at that point, but I'm not positive it's necessary:

service smbd reload

Then, and this is the part I had forgotten from setting it up last time, I added my user to the list of samba users:

smbpasswd -L -a username

Done. Now get back to work!


…no, not the money kind of inheritance. I'm talking about the ownership and permissions in Linux.

Linux permissions are tricky for a Windows guy like me. When I copy a file to a directory on a server I expect the file to inherit the permission of the containing folder on the server. Period. Why? Because that's what NTFS does; that's how it works! Linux it's a bit more complex.

I don't understand it enough to explain it, but here are some of the links and notes on what I've learned so far.

I activated ACL for the volume I was working on.

apt-get install acl

I had to edit /etc/fstab so that the / line read something like "/dev/sda1/ ext3acl,defaults,errors=remount-ro 0 1" then reboot.

This allowed me to set permissions and default permissions for each folder using ACL. Here's the command I used:

setfacl -R --set u::rwx,g::r-x,o::- /www/ setfacl -R -d --set u::rwx,g::r-x,o::- /www/ setfacl -R -m g::rwx /www/wordpress/wp-content/ setfacl -R -d -m g::rwx /www/wordpress/wp-content/

This pretty much took care of what permissions were allowed for each new object. But I wanted my new objects to have the same group as the parent, and I wanted it's subdirectories to inherit that group:

chmod g+s /www/wordpress/ cd /www/wordpress/ find . -type d -exec chmod g+s {} \;

That's about as good as I could make it. It's not the Windows way, but it will do.

EDIT: Having thought about it some more, I'm thinking that I didn't need to activate ACL for my purposes. So I'll probably end up restoring a snapshot that I took before I started messing with ACL. Still, it was a learning experience.

I couldn't embed thumbnail sizes on my new WordPress install on my new Ubuntu server; I could only embed the original size (which was 3072×2048). The options to embed other sizes were just grayed out. It turns out that the default LAMP install doesn't include php-gd, the graphics library that creates thumbnails. Well… I guess that's easy enough to fix:

apt-get install php5-gd

…not that I want to go back to straight HTML, because that's crap, but CSS is crap too.

After pulling my hair out for a bit and wondering why my styles weren't applying I found this helpful article on CSS specificity. Here's the good part:

Element, Pseudo Element: d = 1 – (0,0,0,1)
Class, Pseudo class, Attribute: c = 1 – (0,0,1,0)
Id: b = 1 – (0,1,0,0)
Inline Style: a = 1 – (1,0,0,0)

(1,0,0,0) is the most specific, (0,0,0,1) is the least. When conflicts exist, the most specific wins. So, (0,0,1,0) always wins out over (0,0,0,15). Also if two are in conflict and have the same specificity, then the one declared last wins.

Good to note. Back to work!

Given those four elements, ProFTPd, Ubuntu, pfSense, and 3.5 hours, I was able to get an FTP server working. There's a couple sticky points I'd like to note:

To get FTP to work pfSense requires you to use CARP instead of Proxy ARP for your Virtual IP. That, and you have to enable (by un-checking) the "userland FTP-Proxy application" on you WAN interface. After that you just need to add a NAT connection and rule and you should be good to go for pfSense.

ProFTPd is relatively simple to set up. Just install ProFTPd and walk through the configuration file in /etc/proftpd/proftpd.conf; it is quite well self-documented.

The whole reason for setting up the server was to give one guy access to his website, and since I have all the websites set up in one directory structure on that server (instead of putting the web sites in user directories) I had to grant that user access to his web directory.

So, first I changed the owner on the directory to that user (but left group ownership as www-data).

chown -R username /www/webdir

Then I added these lines to proftpd.conf:

DefaultRoot /www/webdir username DefaultRoot ~

Works great.


I've heard it said that if you copy from only one source then it's called plagiarism, but if you copy from multiple sources then it's called research. Well, by researching Jeff Atwood's Coding Horror blog I found a great, simple way to frame code on Everything is Crap.

First, the CSS:
code { border:2px silver dotted; font-size:100%; line-height:100%; margin:0px auto 0px auto; max-height:450px; overflow:auto; padding:5px 5px 5px 5px; width:95%; display:block; font-family:monospace; white-space:pre; }

Then the Plugins…

Raw HTML capability by Janis Elsts
WP_CodeShield by Scott Sherrill-Mix

Wrap code section in…

[RAW]<code> … </code>[/RAW]

…and you're in business.

P.S. Incidentally, Jeff Atwood is the spiritual inspiration for the motto and title of this site, Everything is Crap. Years ago he helped me realize that all the code I ever wrote is crap and the best I can hope for is to make it less crappy as time goes by. Over time I've come to realize that most aspects of daily life are total crap as well, thus this blog was born.

Weather Underground has a nice XML API to get at their data, and I recently used it to create a small weather page for my friend's new HTC Hero. This little page turned into a learning exercise for me on both the Weather Underground API and SimpleXMLElement in PHP.

SimpleXMLElement: What a great way to parse XML! I've been avoiding XML in my code up until now because it's so freaking clunky to implement. But with this I'm eager for the next chance to use XML. I can sum it up in two lines of code (long lines, bear with me):

$xml_current_cond = new SimpleXMLElement(file_get_contents("http://api.wunderground.com/auto/wui/geo/WXCurrentObXML/index.xml?query=80301")); echo $xml_current_cond->temp_f;

So you see, I read the XML data into $xml_current_cond, and then I access the data through $xml_current_cont->[XML_TAG_NAMES]. It really couldn't be much simpler.

While I'm no fan of the spaghetti code that you get from writing PHP, I also realize that it doesn't matter. Everyone writes PHP, and SimpleXMLElement is a good example of why they use PHP.

Here's some helpful tags that make your page display better on those fancy new smartphones that everyone has but me :(

<meta name="viewport" content="width=320" /> <meta name="viewport" content="initial-scale=1.0" /> <meta name="viewport" content="user-scalable=false" /> <meta name="viewport" content="width=320,user-scalable=false" />

I stole this info on the meta tags you'll need for mobile webpages from iPhone Microsites. Adding the top two meta tags did the trick for me.

WordPress Appliance - Powered by TurnKey Linux