Suicide Linux

Very short post for new years eve.

If you’re looking to keep your resident jr sysadmin on their toes give Suicide Linux a try.

For every mistyped command it will start an rm -rf / on your system. It’s linux  training on the most elite scale imaginable.

Test An SSH Connection

In a script I was writing earlier this afternoon I needed a quick way to test an SSH connection for full functionality. Full functionality being the ability to actually login and use the service as opposed to the port simply being open.

I stumbled across this one liner and incorporated it into my script:

ssh -q -o “BatchMode=yes” user@host “echo 2>&1″ && echo “Up” || echo “Down”

Lets break it down.

ssh -q

The -q option tells SSH to suppress it’s output.

-o “BatchMode=yes”

As defined by man ssh_config batch mode means:

If set to “yes”, passphrase/password querying will be disabled. This option is useful in scripts and other batch jobs where no user is present to supply the password. The argument must be “yes” or “no”. The default is “no”.

&& echo “Up” || echo “Down”

The && means that if our ssh connection completes and exits correctly it will echo “Up”. The || stands for OR, if the login did not complete successfully it will execute the code behind it, in this case echo “Down”

This is a nifty one liner to keep in your toolbox, you can do a lot with the concepts inside of it. The next time you need to test a connection try using the same logic, its transferable to almost any service. Something else to think about is setting up ssh keys so the entire process is as painless as possible, I tend to do this whenever I build a new box.

Edit Like Linus: uEmacs/PK

Have you ever wondered what text editor Linus uses when he’s hacking on code? According to the git repo and wikipedia Linus uses a MicroEmacs variant known as uEmacs.

uEmacs is a fast starting and lightweight emacsen that stays out of your way while you code. Very few command parameters are offered, in fact the list is so small I can easily show them below:

[mm 13:25 0]$ em –help
Usage: em filename
or: em [options]

+ start at the end of file
+ start at line
-g[G] go to line
–help display this help and exit
–version output version information and exit

Some may consider his use of an emacs variant humorous after the warm and loving comments he’s made towards GNU Emacs on various mailing lists in the past. But like everything Linus seems to use he has added his own code to uemacs to have it function in a way he is happy with.

Since the project reached it’s final 4.0.15 release in 1996 Linus has contributed the lions share of maintenance updates along with a few other devs such as Thiago Farina ( a Chromium dev ) and Pekka Enberg ( a fellow Linux kernel hacker). That’s just a quick review of the contributors to the git repo of course, if I missed an important name feel free to harass me via email.

If you’d like to install uemacs yourself start by cloning the git repo:

git clone http://git.kernel.org/pub/scm/editors/uemacs/uemacs.git/

Then simply make and install it.

make
make install

It can now be run with:

em $filename

The projects original author is Petri H. Kutvonen ( the PK in uemacs/PK I would assume ) who had just enhanced Lawrences Mircoemacs version 3.9e which was released in 1987. It is not free software technically but copying is permitted for non-commercial use.

The git repo also contains an interesting readme describing the authors opinions on why he chose Microemacs v3.9e as well as other thoughts on the program that’s worth checking out even if you don’t plan on cloning the whole repo. You can see the file on the web over here.

At the bottom you can see comments acknowledging contributions from a then much less famous Linus:

ACKNOWLEDGEMENTS AND STATUS

I would like to thank Linus Torvalds and Jyrki Havia for their work on
some bugs. uEmacs/PK 4.0.10 included fixes for a number of bugs and it
was assumed to be the final release for the UNIX platform. However,
there has been a couple of maintenance releases, so the final version is
4.0.13. On other platforms there has been no new releases since 4.0.3 in
1991.

April 23, 1995

And yet another release (thanks Linus)! This is most definitely the
really last (not latest) version, 4.0.14. Hmm … 14 looks nicer than 13.

This was my attempt to gather the history of this editor in one coherant place, I’m sure I’ve missed something and I would actually love to know about it to add to this article. It would not have been possible without Kutvonens detailed readme or the Microemacs page on the emacs wiki. Many thanks to all of my sources.

Move All Directories to a Specific Directory

In my never ending quest to keep my downloads folder clean I’ve found it beneficial to simply sort everything based on file type and then go through the categories manually. For example jpg, gif, bmp would all go in the downloads/pics folder. txt, doc, odt would all go in the downloads/docs folder. And directories would go in the downloads/dirs folder. It’s much easier to sort through months worth of random downloading when you have broad categories to work with.

The command looks like:

ls –color=never -1d */ | xargs -I file mv file dirs

Basically it builds a list of all directories in your current working directory with one per line then moves them to a directory called dirs.

Explanation:

ls –color=never -1d */

This builds our directory list. The –color=never makes sure that if you’re using colored ls output ( who isn’t? ) it’s omitted so there are no extraneous ascii characters. The -1 ( that’s a ONE ) means one entry per line.

xargs -I file mv file dirs

Xargs takes the input and iterates through it. The -I option renames what is essentially the variable representing the line of output that is currently being processed from “{}” which is the xargs standard, to “file” which just makes it a little more readable.

In the odd situation where you need this hopefully this post serves you well.

ESX Host Randomly Restarts After Being (Re) Added to HA Cluster

I apologize ahead of time for the title. I could not think of a more elegant way to describe this problem that would actually allow those who needed the solution to find it. Still, long title is too long.

I got to work this morning and a box in my VMWare ESX cluster was disconnected. No big deal right? I power cycled the physical machine and then right click connected in vSphere. Everything looked great and it reconnected like normal. Then before I could start moving VMs back over it was disconnected again with a “host or network” error. I tried removing the machine from the HA Cluster and readding it after which it stayed on a little longer but the end result was the same.

The only discernible error I could see was “Cannot connect: already managed by 127.0.0.1″. After googling I found some fellow sysadmins having similarly strange problems and a VMWare KB article that was being passed around. It seems that the management IP of the host had gone FUBAR. I wish I could explain why this happened, the KB article mentions it being an issue after upgrading a host between ESX versions but mine had not been upgraded even remotely recently.

My solution:

- Log into the ESX box terminal directly.

- Open vpxa.cfg in a text editor:

nano /etc/opt/vmware/vpxa/vpxa.cfg

- Find the entry, if you’re having the same problem this will likely read 127.0.0.1.

- Change this to the IP of your vCenter server.

- Save the file, make sure to restart any vSphere/vCenter connections you have open and then reconnect the host.

After that the host came back online in the vSphere console correctly and stayed up. If you have the same error hopefully this will save you some frustration.

Alsamixer: Command Line Volume Control for Linux

So you’ve just booted up into your brand new install, you’re using a lightweight WM or maybe no X at all. You’re bragging to your friends about the >40mb of ram you’re using to run your entire system and everything is great in the world until, alas, everything is too quiet! Suddenly you’re in a cold sweat, what does one do without an easy little volume widget in the right hand corner of their desktop?

Never fear, alsamixer is here! Try it, run alsamixer in a terminal. You’ll be presented with a nice interface for overall volume control whether you have X running or not.

From here you’ll be able to tune your headset and mic volume as well as an assortment of other interfaces your machine may or may not have.

This is dependent on your distrobution of choice using the ALSA interface for sound devices, but most distros ( Slackware being one of them ) still do. ALSA or the Advanced Linux Sound Architecture is the more popular and older of the current Linux sound frameworks, it was initially released in 1998 and is still in widespread use today.

For some further reading on ALSA check out it’s wikipedia page over here or it’s homepage over here.

You can now go back to scoffing at the need for a fully featured Desktop Environment and touting your command line mastery, while being able to hear your tunes. Type on terminal junkie, type on.

Linux Command Line Book Coming in January

I wanted to do a quick post to mention William E. Shotts Jrs upcoming book on No Starch Press ( Orielly Books )  titled Linux Command Line.

Shotts is the author for the site Linux Command which is a great collection of material on bash and the Linux command line in general. As someone who also hopes to some day cross the line from online writing to print I feel compelled to mention this book.

I’m excited for the release. According to  Oriellys website the book will be 480 pages long covering everything from novice to advanced CLI usage and will release sometime in January 2012.

You can check out the prerelease page ( and preorder! ) over here.

Christmas on Linux – Xsnow up your desktop

Merry Xmas eve to all of my readers!

Sitting around with my family today I was wracking my brain to come up with some sort of quick linux christmas themed post when I remembered xsnow.

If you’ve never used xsnow before try it right now in a terminal:

xsnow

You’ll be greeted with old school animations of falling snowflakes and Santas sleigh complete with reindeer overlayed across your desktop. The sleigh will go across the screen at random points and the snowflakes actually accumulate on top of any windows you have on your desktop.

Xsnow was created for the Macintosh way back in 1984 and survives to this day through a port to the Xwindow system and inclusion in many distributions, including Slackware.

If your distrobution does not package xsnow you can get it over on its homepage.

Embrace the awesome nostalgia, enjoy, and merry xmas!

New Site Design!

Quick update here to gush about my wonderful new site design. It looks much better and should handle code samples much better than previous incarnations.

I’ve also decided to remove adsense until I can find a way to implement it that doesn’t seem obnoxious ( this may never happen ).

Huge props to my good friend and favorite professional designer to take advantage of, David Woolf, for custom building it for me. You can check out his other work over on his site: davidwoolf.net .

The toned down color scheme and minimal design really work for me. If you’ve got any praise or comments for the new theme hit me up on twitter @GNUwhatimsaying

Oh PS: Highlight some text

Alternate Source of Slackware Linux Packages: SalixOS

I was browsing around the Slackware forums over at slacklinux.darkbb.com this afternoon and I came across an interesting topic.

It seems there is a distro based on Slack that I’d never heard of before named SalixOS and they only build packages that are fully backwards compatible for mainstream Slackware.

You can check out their repo mirrors over here: http://www.salixos.org/wiki/index.php/Repository_mirrors

So if you’re in a pinch and just can’t wait for that compile, or can’t find what you need in Slackware extras or Slackbuilds then check out the SalixOS repositories. It’s awesome to see these guys taking the effort to make sure their packages are usable by a wider audience than just their own users. If the entire community could cooperate that well I wouldn’t have to know about 10 different package formats just to work on all the distros I come across.

So  make sure to check them out at salixos.org and if you use their packages on your Slack box I’m sure they wouldn’t mind a nice thank you in their forums or IRC!