Hash-based Diff for Directories

Projects
Recently I was working on a project where I needed to quickly and reliably detect changes to the contents of a directory, and when a change was detected run a series of commands. There are any number of file differential tools, the venerable [diff][1] chief among them, and I think they would certainly do the job. They would certainly do a very complete job allowing for a comparison of every line of every file and be able to show exactly what changed where. But for what I needed to do, this seemed overkill. Ultimately what I needed to know was ***if*** something had changed, not specifically ***what*** had changed. To that end, I realized what I needed was a view of the directory, not a view of the files themselves.…
Read More

Ubuntu School – which: Finding Ruby

Projects
I've been getting my feet wet with Ruby the past couple of days and decided to post this as much for my own recollection as anything else. When you're creating a .rb script file the first line (as with nearly all \*nix script files) contains a reference to the executable which should be used to execute the script. ``` #!/usr/bin/ruby ``` But what if you don't know precisely where that file lives? The [which](http://linux.about.com/library/cmd/blcmdl1_which.htm) command will find it for you. Which is a command which provides you the fully qualified path to shell commands, and this includes script hosts like ruby. ``` callisto:~ kdmurray$ which ruby /usr/bin/ruby ``` This also works for Perl, Python and any number of other executables. Ever wonder where the pwd command lives? or nano? or…
Read More

Ubuntu School – What Groups Do I Belong To?

Projects
This is a quick one. If you need to figure out what groups your user account belongs to you can simply use the **groups** command from the command line: ``` kdmurray@titan:~$ groups kdmurray adm cdrom sudo dip plugdev sambashare lpadmin debian-transmission smbmedia smbbackups ccnet ``` You can also use this command to find out what groups any other users belong to. This is particularly useful when setting up new services or new network shares and you need to confirm which groups the user belongs to. ``` kdmurray@titan:~$ groups ccnet ccnet : users ccnet ``` Try to find yourself a use for the **groups** command this week!
Read More

Ubuntu School – GUI (xubuntu-desktop) for Ubuntu Server

Projects
Whether it's because you're not fully versed in the power of the command line, or you just want to use a tool that will speed things along like gparted, the command-line isn't always the best tool for the job. Sometimes you just need a GUI, even if it's just for a few minutes. I'm going to walk through how to do the installation on Ubuntu 11.10 with the assumption that you only want the GUI occasionally, and don't want it consuming server resources all the time. The first step is to get the GUI tools installed. ``` sudo apt-get update sudo apt-get upgrade sudo apt-get install xubuntu-desktop ``` That was the simple part. At this point you now have the GUI installed, but it will start the GUI every time…
Read More

Ubuntu School – Get Rolling with Webmin on Ubuntu Server 11.10

Projects
Even if some Linux purists would have you believe the command-line is the only way to go, the pragmatist in me will always take an appropriate GUI over a complicated command-line any day. You can run a lot of powerful services for your home network using one or more Ubuntu server machines. With the right tools you don't need to be a Linux expert to make that happen. The tool of choice is [Webmin](http://webmin.com/ "Webmin"). This is a set of web-based tools which allow you to control virtually every piece of server-side software on you Ubuntu server. The GUI is intuitive and straight-forward, the documentation is excellent, and the project is under active development. Because Webmin isn't in the standard repositories you will have to do a couple of quick…
Read More

Ubuntu School – Add an Existing User to a Group

Projects
Occasionally you need to grant an existing user some additional permissions to files, directories or applications. This typically means some kind of change in your permissions settings for the object in question. But because you can only have a single owner for a given object you need to be careful making these changes. Something you can do, though, is extend the permissions on the object to a set of users by way of a group. Logically, a group is nothing more than a named collection of users who all have the same access (by way of that group) to some resource. Users in Ubuntu typically carry one primary, and one or more secondary groups (I won't get into the differences here). By adding group permissions to your resources (ie give…
Read More

Ubuntu School – sudo Your Last Command

Projects
Sometimes we just forget that we need to specify elevated privileges on our Ubuntu machines. I do it all the time, particularly when I'm setting up a new machine. Thankfully there's a shortcut for those of us who are forgetful. If I want to restart the box I can use a command like: ``` shutdown -r now ``` But of course that command requires elevated privileges: ``` shutdown: Need to be root ``` With the fantastic `!!` argument for sudo you can repeat your last terminal command: ``` sudo !! ``` Now you can quickly and efficiently re-run that last command you forgot to sudo.
Read More

Ubuntu School – DHCP Release and Renew

Projects
It's not uncommon to need to release/renew the IP address for a given machine. This is particularly true if you're doing any kind of maintenance on your network, or are troubleshooting pretty much any kind of Internet problem. I never seem to remember how to do this, so I'm including this post as much for my own benefit as anything. What I'm talking about is the Ubuntu equivalent of these windows commands ``` ipconfig /release ipconfig /renew `` From an Ubuntu terminal type: ``` sudo dhclient -r sudo dhclient ``` Much like the Windows equivalents you can also specify these actions for a specific interface if your situation requires. ``` sudo dhclient eth0 ```
Read More

Ubuntu School – Creating a New User

Projects
There are two built-in commands for creating a user from the command-line in Ubuntu: useradd and adduser. useradd is the older command which has, for the most part, been deprecated in favour of the more user-friendly adduser command. Both will allow you to create new user accounts, set up home directories and generally move in the right direction, but adduser will prompt you for information you didn't include whereas useradd will assume you didn't want those things (ie create the home directory). ``` sudo adduser theboss ``` will produce an output similar to ``` Adding user 'theboss' ... Adding new group 'theboss' (1001) ... Adding new user 'theboss' (1001) with group 'theboss' ... Creating home directory '/home/theboss' ... Copying files from '/etc/skel' ... Enter new UNIX password: Retype new UNIX…
Read More

WordPress Plugin: Admin Links Widget

Projects
I've just launched the first version of a new Wordpress widget, the [Admin Links Widget](http://wordpress.org/extend/plugins/admin-links-sidebar-widget/). This very simple widget does as the name suggests. It provides links to administrative functions from the sidebar of your Wordpress installation. The catch is, only administrators will be able to see the links so the general public won't have their view cluttered up with links they can't use. Give it a try! 1. [Download the Plugin](http://wordpress.org/extend/plugins/admin-links-sidebar-widget/) 2. Unzip into your Wordpress plugins folder 3. Activate the plugin 4. Add the widget to your site! If you have any suggestions or feedback, please feel free to post below.
Read More