-
Posted On February 11, 2012
-
Written By Masen Marshall
Welcome to the first post of what will hopefully be a long running series on the intricacies of the Bash shell.
We’re going to start with Special Parameters ( *@#?-$!0_ ) and work our way through many of the more useful, complex, and obscure features of the shell.
Look out for this series as well as my normal quick tips in the coming days.
Thanks for reading!
-
Posted On February 10, 2012
-
Written By Masen Marshall
This has already been reported on by every tech news outlet that matters and more than a few that don’t but I’m mentioning it again incase anyone has been sleeping in the audience.
The spark tablet is a fully open Linux stack toting KDE Active plasma enabled gadget for the true FOSS fan who happens to want a tablet. That means you’ll be able to run full blown linux apps on the thing and tinker to your hearts content. Compared to Android you’re looking at a much more open device.
You can get more details over on the Aaron Seigo blog where all of the official info is coming from.
As a Linux/FOSS nerd I’m excited and I think I’ll be picking one up when possible. At $260 the hardware is rather unimpressive, but with support from the community on this initial version I think we could see something truly great from these guys in the future.
-
Posted On January 17, 2012
-
Written By Masen Marshall
Well ladies and gentlemen the time is almost upon us for some of the most influential sites in the world to black out in protest of the SOPA and PIPA anti-piracy bills.
I could go on some rant that no one will read or try to explain the basis of the legislation and it’s major faults and oversteps, but that’s all been written already by better writers than myself.
Even though I just run a tiny site I hope to get the message across to the few visitors I do get tomorrow. Tons of small bloggers and webmasters are participating and the aggregate of all of our users is going to add up.
If you want to participate in the strike here are a few resources to check out:
sopastrike.com
cloudflare.com stop censorship app
WordPress strike plugin
protestsopa.org
Support the free internets as we know them!
I’ll see you back here on thursday, make sure to make as much noise as you can tomorrow folks.
-
Posted On January 16, 2012
-
Written By Masen Marshall
The default emacs setup in most any distro is usable. A minimum amount of code highlighting packages and a semi readable color layout. But once you’ve spent some time with the editor you may want to switch it up to something a bit more your style. Cue ColorTheme, the emacs theme package with about 50 preloaded themes that also enables you to easily build your own ( and grab others on the net for that matter ).
The EmacsWiki entry for ColorTheme is over here and the official homepage is over here. If it doesn’t come pre-installed in your distro you can download the latest release from the projects savannah page.
If you are installing it yourself make sure to put it in your .emacs.d and load it with something like:
(require ‘color-theme)
(color-theme-initialize)
(color-theme-robin-hood)
Where robin-hood is in this case the theme.
You can look around and test the different themes out with M-x color-theme-select or from the tools menu under ColorTheme.
Try a few out, just remember to change it in your .emacs config so they stick. If you have any awesome custom ColorTheme themes let me know, I’d love to do a post with cool community ones.
-
Posted On January 15, 2012
-
Written By Masen Marshall
One of the first things you’ll notice as you begin using emacs are the backup files scattered around the directories you’ve been working in. They’re great when you need them but seeing a massive amount of #files# in every dir on your system is annoying to say the least.
My solution is to keep them around but tone down the annoying by putting them in their own directory, adding some versioning and cleanup for bonus points while I’m at it.
In ~/.emacs :
(setq
backup-by-copying t ; don’t clobber symlinks
backup-directory-alist
‘((“.” . “~/.emacs.d/saves”)) ; don’t litter my fs tree
delete-old-versions t
kept-new-versions 6
kept-old-versions 2
version-control t) ; use versioned backups
Basically we’re going to store all the backups in ~/.emacs.d/saves. It also cleans these files on occasion deleting them as new ones are generated as to not get out of control, and enables emacs basic built in version control system VC for versioned backups.
This was mostly inspired by a large .emacs config file I saw on the net forever ago. I have no idea by this point who to give credit to so I just say thanks random helpful emacs user, you’re the best!
-
Posted On January 14, 2012
-
Written By Masen Marshall
Tonight I was thinking up a post based around some uncommon bash functions and ended up at The Advanced Bash-Scripting Guide. When I saw that everything I wanted to write about was already better written there I switched gears.
Whether you use bash on a regular basis or just on occasion the ABS guide is the only reference you’ll ever actually need. Anything one could ever imagine doing with the bash language is well documented and presented in clear concise examples within it’s pages.
It is an absolutely invaluable reference. I actually have an older version of it that I had printed and bound in three volumes just to put on my shelf, it’s that good.
So if you haven’t wandered through it’s 885 pages of theory, technical documentation, and examples do it now! I guarantee you’ll learn something useful or your money back.
-
Posted On January 13, 2012
-
Written By Masen Marshall
I posted yesterday about the libssh slackbuild failing on build due to some problems creating the latex documentation.
Since then I’ve found the problem in root not having the latex bin directory ( /usr/share/texmf/bin ) in it’s path by default.
It’s an easy fix:
PATH=$PATH:/usr/share/texmf/bin
With that the slackbuild will run correctly. I know there are some options to just specify specific commands for latex creation in the build files so that may be a option to make the buildscript run more consistently.
-
Posted On January 13, 2012
-
Written By Masen Marshall
If you’re like me, you’re stuck with an ISP that just wont sell you that ever important static IP address. My goal was simple, I wanted to host a server at my house and tie my domain to it. Here’s how I did it:
- Register a domain with GoDaddy
- Log into GoDaddy
- Go to “My Account”
- Click on your domain from the list (that’ll take you to the Domain Manager)
- Click on “Set Nameservers”
- For Nameserver 1: NS1.MYDYNDNS.ORG
- For Nameserver 2: NS2.MYDYNDNS.ORG
- For Nameserver 3: NS3.MYDYNDNS.ORG
- For Nameserver 4: NS4.MYDYNDNS.ORG
- Go to dyndns.org
- Log in, and buy the standard dns service ($29.95/yr)
- Now on your server, you have to schedule a script to run in crontab. I run this script every minute, in case my IP changes or I get a power outage:
#!/bin/bash
# Get the WAN IP according to DynDns.com
# nslookup <domain> –> finds all information about wan connection
# grep Address –> line we want is part of the Address, but there’s two of those lines
# sed -n ‘$p’ –> get the last line (that’s the one we want)
# sed -e ‘s/Address: //g’ –> remove the word ‘Address: ‘ from the line so we’re left with the ip
dynIP=`nslookup <your domain> | grep Address | sed -n ‘$p’ | sed -e ‘s/Address: //g’`
# Get the actual WAN IP address for this network
wanIP=`wget -q -O – http://ip.keithscode.com`
# Compare both IPs with eachother to see if there are any problems
if [ "$dynIP" != "$wanIP" ]; then
dt=`date`
echo “$dt, DynDns IP: $dynIP, WAN IP: $wanIP” >> /var/log/ddclient-update
res=`/usr/bin/ddclient -force`
echo “– Operation complete –”
echo “$res”
fi
In short, this script will compare your WAN IP with the IP on record at DynDNS. If they differ, it’ll force DynDNS to update to the newest address.
This script has been really helpful when I moved from my apartment into a house. All I had to do (after getting Internet at the house) was to open some ports on my router and power up my server. By the time I logged in, my site was live again!
-
Posted On January 12, 2012
-
Written By Masen Marshall
I needed libssh this morning for some code I’m writing and unfortunately found out that the slackbuild for it fails to build on my 13.37 box.
It errors out post compile during the install phase with:
cp: cannot stat `build/doc/latex’: No such file or directory
As the latex docs aren’t of much importance to me and I needed it installed about 5 minutes before I started compiling it I simply removed that portion from libssh.Slackbuild.
-Lines 106 to 110-
Before:
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a \
AUTHORS BSD ChangeLog COPYING INSTALL README build/doc/html build/doc/latex \
$PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
After:
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a \
AUTHORS BSD ChangeLog COPYING INSTALL README build/doc/html \
$PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
As you can see I just removed build/doc/latex from the list of directories being copied. With that the SB was built correctly and installed fine. It’s a hack and it doesn’t actually solve the problem of the latex doc directory being missing but it works for now and I’ll attempt to actually fix the build file later this evening.
-
Posted On January 11, 2012
-
Written By Masen Marshall
Another quick C post tonight.
Today the project that led me to post this had me finding a way to create directories in C.
The libc library provides this functionality in the form of the mkdir function as shown by info libc:
— Function: int mkdir (const char *FILENAME, mode_t MODE)
The `mkdir’ function creates a new, empty directory with name
FILENAME.
The argument MODE specifies the file permissions for the new
directory file. *Note Permission Bits::, for more information
about this.
A return value of `0′ indicates successful completion, and `-1′
indicates failure. In addition to the usual file name syntax
errors (*note File Name Errors::), the following `errno’ error
conditions are defined for this function:
To use this function, your program should include the header file
`sys/stat.h’.
Here’s some sample code that will take in an argument and create a directory with that name:
#include
#include
int main ( int argc, char *argv[] )
{
if ( argc !=2 )
{
printf( “\nPlease supply a directory name” );
}
else
{
mkdir(argv[1],0777);
}
}
I hope someone is finding my poorly written code useful. I’ve just recently started to work with C and I’ve found that the documentation can be somewhat intimidating for a beginner coming from the sysadmin universe. With any luck these posts can help another admin get started on a quick and dirty C project.