Archive for the ‘unix’ Category

Fixing Tmux create session failed: : Exec format error

Posted on January 2nd, 2011 in tmux, unix | 2 Comments »

This error happened to me whenever I tried to run Tmux as a non-root user. Most likely if this is happening to you, you’re using Linode VPS like I am or have a similar setup.

The answer is that devpts is missing. Trying running the following as a non-root user, and Tmux should work:

sudo mount devpts /dev/pts -t devpts

What is devpts?

You probably don’t want to run this command every time (or give your users access to sudo.)
Add this to your /etc/fstab and you can continue with your tmux screen splitting.

tmpfs /dev/shm tmpfs defaults 0 0 
devpts /dev/pts devpts gid=5,mode=620 0 0 
sysfs /sys sysfs defaults 0 0

Unix tidbits from Unix Power Tools, 3rd edition

Posted on December 26th, 2010 in unix | No Comments »

Just finished the 1000+ pager Unix Power Tools, Third Editionbook over Christmas break and found it a pretty good complete general introduction / refresher to Unix / Linux.

I originally passed the book up as it was last updated in 2002 but my interest was piqued skimming it and in the end I found that 98% of it’s contents still relevant today. It was like having lunch with a old-time unix guy – all the command line stuff just runs faster these days and he talks about screen instead of tmux, etc. Additionally, interesting history and tips were given on some unix programs (for ways of dropping out of a shell script faster since back in the day CPU cycles were rented).

Less known tidbits

Here are some quick notes I jotted down of some new things I learned:

pushd and popd is a great way of cd’ing to a far away path, and zipping yourself back where you were:

pushd # pop this directory on the "remember" stack
popd # go back to pop directory
dirs # see your pushd paths

I dabble in jailbreaking my phone occasionally and must download the latest jailbreak app off the torrents. This alerts the security professional in me as I have no idea what’s in the compiled code as anybody could have seeded it. The Jailbreak guys always provide an md5 verification hash on their site of their latest build and now I have the capability to validate them:

md5sum filename(s) > savedhash # create hash
md5sum -c savedhash # compare hash

Sometimes I need to modify the output of a program but also want to keep a copy of it’s unmodified output. Tee does that for me in one go.

echo 'hi there' | tee hi.txt | sed 's/hi/bye/'
# outputs 'by there' while saving original string to hi.txt

Cool way to fix command line typos:

cd bydirectory
-bash: cd: bydirectory: No such file or directory
# returns and executes: cd mydirectory

Can also do:

echo 'hi thereee'
# returns: hi thereee
# returns and executes: echo 'hi there'

Other short tidbits include:

sdiff <i>file1</i> <i>file2</i> # does side by side diff comparisons
split # split large files into smaller files
fmt # text formatter
man -k string # like M-x apropos in emacs

Lastly, put a -xv at the top of your shell scripts to debug them:

#! /bin/sh -xv