Category Archives: Software

What Makes ASUS and Android an A+?

ASUS has vision, and the eeepc is no doubt a standard setting line of netbooks. Their latest teaming of Android with their latest tablets, eee Pad transformer and the eee Pad Slider provide both ASUS and users with a lightweight familiar system.  It may also be using the same operating system as their phones, possibly other devices.

With ChromeOS, Google is also covering a server-side focused solution to a consumer’s needs.  We see Blackberry trying out a similar solution with WebOS, ASUS however, is focusing on hardware, as usual and doing an impressive job, as usual.

They don’t completely shy away from Windows either, with the Eee Slate running the most impressive hardware, it should be interesting to see how Microsoft holds onto their market being a direct competitor of the iPad.

ASUS doesn’t forget it’s stake in the software portion of this emerging market, no. They’ve invested in a “cloud” for consumers information to be separate from their phones and separate from their carrier. Their information is stored and accessible via their device(s) as an app or Now all they need to do is invest in a short domain name,

Other Points, these are cool:


Non-free Art In Open-source (FOSS) Video Games


I’ve been interested in art since I can remember, the marriage of computers and art has always fascinated me. I would spend math classes (sorry Mr. D) fiddling around with my calculator, drawing pixel art and saving them in the storage on my calculator. I would hack up BASIC programs or marvel at ASM based games and sub-shells. Later these activities moved over to computers, websites, software, the internet and open-source video games, such as Nexuiz or Xonotic. My brain has always enjoyed trying to pull the worlds of art and science together but it wasn’t always viewing the two alike.

Originally my feelings about art were 2 dimensional, as I’d expect many to view it. It’s easy for art to be a fleeting glimpse. You see the final product, the lines of the creation process are blurred, the definitions of “source” gets lost.

When I first started contributing 2d art to Nexuiz, I was submitting PSD files. I didn’t realize at the time but I was deterring other artists who were without Photoshop the ability to properly edit the file because of some advanced settings in the file that could not be read by open-source software. This hindered others who were trying to expand on my work or create derivative works.

Now that isn’t a completely fair comparison because source is still being provided, only limited to a number of people. However, the reason I bring it up is because it was the beginning of a turning point for me. As I delved more into Linux and the world of Free Open-Source Software (FOSS), I was realizing how important source is to a community. How source code teaches, how knowledge of techniques are passed on. My involvement with Nexuiz and other (at the time) open-source projects, are what kept this message strong in the back of my head.

GPL Superheros

On Art in Video Games

Source of some art is almost impossible. A hand draw sketch for example, in the digital world however, things are different and art source becomes a very powerful teaching tool. Often, for the creation of maps for these games is not the most straight forward process. The mapping software and map entities require some critical thinking. The most common way to learn to add a feature to your map if you don’t know how, is to identify a map with the feature you’d like to implement, open its .map source file and study how it was done.

The reason this all came up for me today was because of a popular open-source ioquake-based game called Warsow. The code is licensed under GPL and the art has a proprietary, closed-source license. As a core member of the Xonotic team, we faced the decision of how to license Xonotic when we forked from Nexuiz. This decision was not as easy as you’d think because of ‘techniical’ license issues. The code must be GPL because of its lineage, GPL is not so keen on art. Creative Commons is an art license, not so keen on code. They seem like they’d be a good merger but from what I understood they could cause issues for distribution. We’d have to distribute the code and art as separate packages. In the end we licensed everything under GPL to make things easier for ourselves.

I thought Warsow was facing the same problem and today they had a developer Q & A, I decided to ask about this, pardon my bias phrasing.

[-z-] asked: do you think distributing warsow as one package is legal under the licensing terms?
crizis answers: Yes, it is. Even Richard Stallman himself blessed way of having open engine and restricted artwork. All code in Warsow is open source, artwork is not.

I found this interesting and with some conversation with with fellow Xonoticans, I came to learn how Richard Stallman, the founder of free software, feels about art in FOSS and I couldn’t disagree more. How is requiring the source for compiled programs any different than requiring the source for art?

Expanding On My Feelings

In my opinion, non-free art in free software is not in good spirit, it does not help others learn and it can hurt the growth of the game. The distinction between art and code gets further blurred when you see how interactive the artwork is.

I can argue that maps are code. They are a meta file, you can open them up in your text editor and edit them, they are filled with coordinates of brushes and entities, that hold keys with settings for the objects references to textures and can even contain some mild programming. Shader files are used to enhance textures and brushes. It’s not conventional programming, it’s closer to “virtual circuitry” as MrBougo called it.

This information is lost if source is not provided. Mappers have two choices on how to de-construct such features. Reverse engineer or decompile the map. The former likely being a waste of someone’s time and the later being an example of two wrongs not making it right.

I do not mean this as an attack on Warsow, it was only what re-lit my interest in the topic and the views I found by RMS were shocking. I think this should be a topic for discussion because in my eyes, art should fall under a similar license as code in FOSS, especially in software such as a video game where media is more advanced and interactive.

Tips for Using Bash in the Linux Terminal – Part 1


Bash is the default shell in the terminal on many Linux and UNIX based operating system, such as Ubuntu or Mac OS X. I’ve mentioned before as a great reference for learning some neat tricks with the terminal. I’ve gained a lot from the site and a few others, such as the Advanced Bash Scripting Guide and the bash hackers wiki. I wanted to share some of the tips I use most often, combined with other information that I’ve compiled through my use of the terminal.

I think I should mention that I’ve been using more applications in the terminal recently. Some people view this as backwards but I argue just the opposite. Limiting the amount of times I need to use the mouse and the number of keystrokes I need to make drastically increases my efficiency. Many bash applications are designed around single keystrokes, layered hotkeys and edit “modes”. GUIs have their place but many of my tasks can be completely more accurately and consistently via the terminal.

With that said, lets dive in.

The Basics


Ctrl + a -> Go to the beginning of the line you are currently typing on.
Ctrl + e -> Go to the end of the line you are currently typing on
Alt + f -> Move cursor forward one word on the current line.
Alt + b -> Move cursor backward one word on the current line.

Ctrl + u -> Clears from before the cursor position. If you are at the end of the line, clears the entire line.
Ctrl + k -> Clear from after the cursor. If you are at the beginning of the line, clears the entire line.
Ctrl + w -> Delete the word before the cursor.
Ctrl + h -> Same as backspace.
Ctrl + t -> Swap the last two characters before the cursor.
Esc + t -> Swap the last two words before the cursor.

Ctrl + l -> Clear screen (same as clear command).
Ctrl + c -> Kill the current command or process.
Ctrl + z -> Puts whatever you are running into a suspended background process, fg to restore it.
Ctrl + d -> Exit the current shell.

Oddly, unlike many terminal applications, Bash hotkeys don’t make a lot of sense to me. There are very few that are “intuitive”.


Press the up arrow for the last command or:

!! — repeat last command

echo "hello"


z@zentury:~$ echo "hello"
z@zentury:~$ !!
echo "hello"

ctrl+r is one of the best ways to search through your history. it will initialize a reverse search as you type. To go to the next result, press ctrl+r again


History Expansion/Modification

!:0 — will repeat the first token

cd ~
ls -la

!:1-3 — defining a range: 1-3 will repeat the 2nd to 4th tokens (count starts at 0). It’s important to note that double quotes will group tokens together.

echo "hello there" && ls ~

!!:s/find/replace/ — will allow you to replace a part of the command

echo "hello there"


z@zentury:~$ echo "hello there"
hello there
z@zentury:~$ !!:s/hello/hi/
echo "hi there"
hi there

OR even shorter:


echo "hello there"


z@zentury:~$ echo "hello there"
hello there
z@zentury:~$ ^hello^hi
echo "hi there"
hi there

Sequences and Pattern Expansion

Typically in a Linux or UNIX environment you have access to a command line tool name “seq” which gone over before. However, it’s good to know that bash has built-in sequence expansion and you don’t need to rely on seq.

echo {a..z}
a b c d e f g h i j k l m n o p q r s t u v w x y z

by defining a start and end character with the ‘..’ in between, we tell bash to fill in the rest and echo a list for us. Those are all lowercase, what if you wanted uppercase? simple:

echo {A..Z}

Or both, with a few extra characters in the mix:

echo {A..z}
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [  ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z

It doesn’t always have to be a-z though,

echo {A..G}

This also works with numbers:

echo {0..9}
0 1 2 3 4 5 6 7 8 9
echo {0..100}
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

Descending as well as ascending

echo {9..0}
9 8 7 6 5 4 3 2 1 0

Echo a specific set

echo {1,4,6,9}
1 4 6 9

Applying it

Quickly backup a file

touch file1.txt
cp file1.txt{,.bak}
file1.txt file1.txt.bak

explanation: the first parameter is empty, the second is .bak, this expands to >> cp file1.txt file1.txt.bak << and creates the copy

Convert an image type

If you have image magick installed, you can convert file types pretty easy using this same concept:

sudo apt-get install imagemagick

(To install on Ubuntu)

convert file.{jpg,png}


echo {a..c}{a..c}{a..c}
aaa aab aac aba abb abc aca acb acc baa bab bac bba bbb bbc bca bcb bcc caa cab cac cba cbb cbc cca ccb ccc

Stay tuned for Part 2

These are some pretty common techniques I use to reduce the amount of typing and thinking required to complete a task in the terminal. Stay tuned for part 2 and check out some of my creative usages at

Customizing Colors for Your .bashrc

I’m working on organizing my dotfiles and part of that process has led me to clean up the way I address colors. I came across a few good sources, for .bashrc colors and decided it’d be better to create my own. I would like to have used the ones I found on the Arch wiki but the aliases were a bit odd to me. They also break consistency as you scroll down. I’m not sure if this is due to it being a collaborative wiki or it’s a way to teach multiple syntaxes/approaches.  In either case I figured the aliases weren’t as “standard” as I thought they might be in that world.

So I decided to copy them the best of the bunch into geany and modify them with regular expressions. I used column selection to speed up some of the tasks, such as Title Case formatting and typing the prefixes.

# define colors
Black='\e[0;30m'    # Black / Regular
Red='\e[0;31m'      # Red
Green='\e[0;32m'    # Green
Yellow='\e[0;33m'   # Yellow
Blue='\e[0;34m'     # Blue
Purple='\e[0;35m'   # Purple
Cyan='\e[0;36m'     # Cyan
White='\e[0;37m'    # White

BBlack='\e[1;30m'   # BBlack / Bold
BRed='\e[1;31m'     # BRed
BGreen='\e[1;32m'   # BGreen
BYellow='\e[1;33m'  # BYellow
BBlue='\e[1;34m'    # BBlue
BPurple='\e[1;35m'  # BPurple
BCyan='\e[1;36m'    # BCyan
BWhite='\e[1;37m'   # BWhite

UBlack='\e[4;30m'   # UBlack / Underline
URed='\e[4;31m'     # URed
UGreen='\e[4;32m'   # UGreen
UYellow='\e[4;33m'  # UYellow
UBlue='\e[4;34m'    # UBlue
UPurple='\e[4;35m'  # UPurple
UCyan='\e[4;36m'    # UCyan
UWhite='\e[4;37m'   # UWhite

BGBlack='\e[40m'    # BGBlack - background
BGRed='\e[41m'      # BGRed
BGGeeen='\e[42m'    # BGGreen
BGYellow='\e[43m'   # BGYellow
BGBlue='\e[44m'     # BGBlue
BGPurple='\e[45m'   # BGPurple
BGCyan='\e[46m'     # BGCyan
BGWhite='\e[47m'    # BGWhite

NC='\e[0m'          # Text Reset / No Color

Here is a test case:

for c in {,B,U,BG}{Black,Red,Green,Yellow,Blue,Purple,Cyan,White}; do echo -e ${!c}$c${NC}; done; echo -e "${NC}"

Here is the same test case without the aliases

for c in {0,1,4}\;{30..37} {40..47}; do echo -e \\e[${!c}${c}m${c}m\\e[0m; done;

Here's a PS1 you can try it with

PS1="${debian_chroot:+($debian_chroot)}\[${BWhite}\]\u\[${NC}\]\[${Yellow}\]@\[${White}\]\h\[${NC}\]:\[${BBlue}\]\w\[${NC}\]$ "

I plan to use these quite often as I build out my .bash_aliases but the most immediate use you might find useful is the PS1 generation tool I’ve setup an alpha of

ps1-o-matic-0.5 video in action

Below is a screenshot of how I’m revising the script to use only javascript objects rather than relying on html inputs to store values:

I’m currently at the point where I’m using jquery ui’s draggable and sortable to allow segments to be moved around but I have nothing worth sharing yet. Stay tuned, I’ll be checking the source into my github account soon.

Sorry screen, tmux is better (but here are some screen-like hotkeys)


If you’re familiar with the command line on Linux or UNIX, you’ve likely heard of a program called “screen”, which allows you to create virtual terminal sessions inside of your current terminal. The major benefit to this is the ability to dettach and reattach screen sessions, leaving your programs to act as if you never left. Additionally, you can have multiple buffers inside your screen that act like tabs, allowing you to flip between.

The major difference between screen and tmux is their ability to split and manage splits. Oh yeah, that and hotkeys. I think they were trying to pay legacy (or force you to change back :-P) by setting up your main key to be “b” instead of “a”, which is an awkward reach. Tux Wears Fedora below shares more screen like hotkeys, as do I with some minor tweaks that I combined with the default example in ubuntu /usr/share.

I became well acquainted at Tux Wears Fedora’s post on tmux migrating from screen.

tmux in action

# ~/.tmux.conf
# By Tyler Mulligan. Public domain.
# This configuration file binds many of the common GNU screen key bindings to
# appropriate tmux key bindings. Note that for some key bindings there is no
# tmux analogue and also that this set omits binding some commands available in
# tmux but not in screen.
# Note this is a good starting point but you should check out the man page for more
# configuration options if you really want to get more out of tmux

### Unbind existing tmux key bindings (except 0-9).

# Set the prefix to ^A.
unbind C-b
set -g prefix ^A
bind a send-prefix

# Bind appropriate commands similar to screen.
# lockscreen ^X x
unbind ^X
bind ^X lock-server
unbind x
bind x lock-server

# screen ^C c
unbind ^C
bind ^C new-window
bind c
bind c new-window

# detach ^D d
unbind ^D
bind ^D detach

# displays *
unbind *
bind * list-clients

# next ^@ ^N sp n
unbind ^@
bind ^@ next-window
unbind ^N
bind ^N next-window
unbind " "
bind " " next-window
unbind n
bind n next-window

# title A
unbind A
bind A command-prompt "rename-window %%"

# other ^A
unbind ^A
bind ^A last-window

# prev ^H ^P p ^?
unbind ^H
bind ^H previous-window
unbind ^P
bind ^P previous-window
unbind p
bind p previous-window
unbind BSpace
bind BSpace previous-window

# windows ^W w
unbind ^W
bind ^W list-windows
unbind w
bind w list-windows

# quit \
unbind \
bind \ confirm-before "kill-server"

# kill K k
unbind K
bind K confirm-before "kill-window"
unbind k
bind k confirm-before "kill-window"

# redisplay ^L l
unbind ^L
bind ^L refresh-client
unbind l
bind l refresh-client

# More straight forward key bindings for splitting
unbind %
bind | split-window -h
bind v split-window -h
unbind '"'
bind - split-window -v
bind h split-window -v

# History
set -g history-limit 1000

# Pane
unbind o
bind C-s down-pane

# Terminal emulator window title
set -g set-titles on
set -g set-titles-string '#S:#I.#P #W'

# Status Bar
set -g status-bg black
set -g status-fg white
set -g status-interval 1
set -g status-left '#[fg=green]#H#[default]'
set -g status-right '#[fg=yellow]#(cut -d " " -f 1-4 /proc/loadavg)#[default] #[fg=cyan,bold]%Y-%m-%d %H:%M:%S#[default]'

# Notifying if other windows has activities
setw -g monitor-activity on
set -g visual-activity on

# Highlighting the active window in status bar
setw -g window-status-current-bg red

# Clock
setw -g clock-mode-colour green
setw -g clock-mode-style 24

# :kB: focus up
unbind Tab
bind Tab down-pane
unbind BTab
bind BTab up-pane

# " windowlist -b
unbind '"'
bind '"' choose-window

Splitting is what initially caused me to migrate but there are plenty of other features that have lead me to stay. this article outlines the benefits in detail. Once you go tmux, you never go back.

Using Terminal Program "screen" on Linux / UNIX


The terminal program “screen” for Linux / UNIX, is a command line tool that allows you to emulate terminals inside a currently running session and detach the ‘screen’ to the background. This program may seem obscure to new users because of it’s abstract nature and unusual key bindings but once you start learning the basics, the advanced usages don’t seem that scary.

If you consider yourself to have an advanced sense of the command line and you’d like to go more advanced out of gate, you should consider skipping ahead to my article on the screen successor, tmux which allows for more advanced splitting (and apparently better code).

Getting Started

Below is a walk through of an average screen scenario I’ve put together to give you an idea of how you might use this program in your workflow.

to start a basic screen session type:


this will put you in a virtual session.

to detach the screen press: ctrl+a, d

to reattach the screen type:

screen -r

detach again, then type:


and detach this. You now have 2 screen sessions open, so when you type screen -r, instead of reattaching, it will list the possible screens to attach. You’ll see something like the following:

There are several suitable screens on:
    31454.pts-2.quadjutsu    (10/10/2009 09:45:51 AM)    (Detached)
    31219.pts-2.quadjutsu    (10/10/2009 09:44:27 AM)    (Detached)
Type "screen [-d] -r [pid.]" to resume one of them.

So I’d type:

screen -r 31454

to attach the first one. On systems with ‘pkill’ you can type:

pkill screen

to kill all the screen sesions.

That’s one way to separate screens… another is virtual “tabs” within a screen session.

so lets create a new screen session with:


Then type:


so you have some data to reference for which “tab” you’re in

Then hit: ctrl+a, c

This will create a new tab.

to cycle forward through the tabs (next), hit: ctrl+a, n or ctrl+a, [spacebar]
to cycle backwards through the tabs (previous), hit: ctrl+a, p or ctrl+a, [backspace]

to kill a tab, type: exit

I found a good reference for “screen” hotkeys at if you’d like to learn more.

MySQL and Python – The Problems and [Some] Solutions


I’m still relatively new to Python. I dabble once in a while. Usually when I catch myself writing something overly complicated in bash. I figured doing MySQL from a Python script would be easier and better implemented in Python. Well, I was in for a few surprises I’d like to share with others looking to integrate with MySQL in Python before you encounter the same problems I did.

Getting on with it

As a Python noob, it made sense to me to use the python-mysqldb module. It “works” but not well. Read through the [working] code below and see if you can find the problem and how I circumvented it.

# Tyler Mulligan ([email protected])
# MySQL the WRONG way in Python
import MySQLdb

def connection_settings():

def run_admin_sql(): 
    conn = MySQLdb.Connection(host=DB_HOST, user=DB_ADMIN, passwd=DB_ADMIN_PASSWORD)
    cursor = conn.cursor()
    #cursor.execute("DROP USER %s@%s", (DB_USER, DB_HOST))
    #cursor.execute("DROP DATABASE %s" % DB_NAME)
    cursor.execute("CREATE USER %s@%s IDENTIFIED BY %s", (DB_USER, DB_HOST, DB_PASSWORD))
    cursor.execute("CREATE DATABASE %s" % DB_NAME)
    cursor.execute("GRANT USAGE ON %s.* TO %s@%s IDENTIFIED BY '%s'" % (DB_NAME, DB_USER, DB_HOST, DB_PASSWORD))
    cursor.execute("GRANT ALL PRIVILEGES ON *.* to %s@%s IDENTIFIED BY %s", (DB_USER, DB_HOST, DB_PASSWORD))
    conn = MySQLdb.Connection(db=DB_NAME, host=DB_HOST, user=DB_USER, passwd=DB_PASSWORD)
    cursor = conn.cursor()

    cat_table_sql = """CREATE TABLE cats
    `id` int(3) unsigned NOT NULL AUTO_INCREMENT,
    `name` varchar(50) NOT NULL,
    `age` int(2) NOT NULL,
    `type` int(2) NOT NULL,
    PRIMARY KEY (`id`)
    cursor.execute("INSERT INTO cats (name, age, type) VALUES (%s, %s, %s)", ("fluffy", 5, 1))
    cursor.execute("INSERT INTO cats (name, age, type) VALUES (%s, %s, %s)", ("meow meow", 6, 1))
    cursor.execute("INSERT INTO cats (name, age, type) VALUES (%s, %s, %s)", ("purrfect", 3, 1))
    cursor.execute("SELECT * FROM cats")
    results = cursor.fetchall()
    return results

print run_admin_sql()

The problem is parameterization. The python-mysqldb module sucks at it. It’s glaringly obvious when you look at the follow snippet and how I worked around it.

cursor.execute("CREATE DATABASE %s", (DB_NAME)) # but the module won't support this

The difference, is that the first implementation uses the module’s parameterization to escape the variables that are passed to it, making it safe. The second is using Python’s string formatter which means I’d have to do all the escaping and sanitization prior, which is obviously more dangerous and annoying.

The MySQLdb docs bury this little note, “Parameter placeholders can only be used to insert column values. They can not be used for other parts of SQL, such as table names, statements, etc.”

You can implement it this way but you’ll be wasting your time. There are better modules out there to make up for this one’s shortcomings. OurSQL and SQLAlchemy were the two libraries recommended to me in #python on I will make another post when I develop the same example above using one of these libraries.

Multiple X (Desktop) Sessions in Ubuntu

This post has a lot to do with graphics but there are no graphics. It’s a walk-through explanation and and proof of concept of some very interesting features of Linux as a desktop operating system.

If you aren’t familiar with X, than this webpage might confuse you, the X Window System is what draws the GUI (graphical user interface) for Ubuntu. On top of this, you may have a Window Manager or Desktop Environment, such as Gnome (Ubuntu default) or KDE (Kubuntu).

When you boot up Ubuntu, it creates a set of “virtual terminals”. These VTs are accessible via a key combination of clt+alt+f1-12. VT7 (ctrl+alt+f7) is the default and it handles X’s “screen 0″. If you play around, with the key combination, you’ll notice you drop into consoles with a login prompt (f1-6) or a blank screen (f8-f12, don’t worry if you see USB errors).

These virtual terminals used to be handled by X which was slower and more prone to crash (citation needed) but since Ubuntu 8.04, this has been handled by “Kernel Mode”, where this management is handled by the kernel. You can switch to another virtual terminal and create another X session.

Typically in Linux, you could switch to another VT, login [as another user] and type $ startx — :1 (special argument ‘--‘ marks the end of client arguments and the beginning of server options, :1 defines screen 1). This will work in Ubuntu but the part where I found it failing was switching between this newly created X session and back to my original :0 on VT7.

The way I found to do this in Ubuntu seems a bit counter-intuitive. Before I explain, you should create a new user, if you don’t have another already. You can do this by going to System > Administration > Users and Groups.

To create a second X session in Ubuntu, go to your logout menu (default top right) and select “switch user”, and login as another user (you don’t want to create an error in the user environment). When you login as another user, Ubuntu creates a screen :1 on VT8. This means, you can change back to VT7 with ctrl+alt+f7, then back to VT8 with ctrl+alt+f8. I suspect this is the reason VT8-12 show up as blank screens instead of login terminals. Ubuntu seems to be leveraging the power of virtual terminals for “user switches”.

I haven’t noticed much in performance loss doing this and the other big question is practicality. Why would you ever do this? Perhaps you are testing software and want isolated test cases or you want a dedicated user for games with a more streamlined window manager and want to be able to flip back and forth.

Similar areas I came across in my research were Nested X sessions and Multiseat X.

Random gnome-terminal profiles (themes) in Ubuntu


Does it ever confuse you if you have too many terminals open at once that look alike? Perhaps you’re just looking to express your personality or tickle your brain. In any case, if you’re using the terminal in ubuntu a lot, you may be interested in having random profiles (colors / settings).

The concept of the method is pretty simple, define a hotkey that launches a script that picks a random profile you’ve created and then open the terminal with that profile as a parameter.


- Compiz or other hotkey script that will allow you to link to a .sh file
- gnome-terminal
- bash

Getting Started

You can figure out what Profiles you have by going to Edit > Profiles in gnome-terminal. You likely only have one, “Default”, unless you’re already actively using terminal profiles. If you only have one, you should create a few, maybe 3 or 4 right now and play with the colors a bit. Important, don’t include spaces in the names of the profiles

The Script

Create a file in your scripts folder (or create a directory if you don’t have one):

mkdir ~/scripts
touch ~/scripts/ && chmod +x ~/scripts/
gedit ~/scripts/

Paste the following replacing the Profile names with those of your own (delimited by spaces) and change the number 4 to that of the :

p=( Default Delta Psi Sigma )
gnome-terminal --window-with-profile ${p[$((RANDOM%${#p[@]}))]}

That ugly looking bit right here is a calculation between a random number (echo RANDOM) and the size of the array (${#p[@]}), “random” % “length of array”. Where % means mod, or remainder of the division. (examples: 7%4 = 3; 6%4 = 2; 5%4 = 1; 4 % 4 = 0; 4 % 3 = 1; 321%321= 0).

To illustrate more, play with this code:

r=$RANDOM; echo $r; echo $((r % 4))

This is how we get a random index value for the array. This value is nested inside the array ${p[r]}, where r is the random, within bounds, array index. That array then corresponds with a name of our profile and we pass it as a paramater to gnome-terminal with “–window-with-profile”. So using my define array above, if the random index were “1″, “Delta” would be echoed. If the index were “0″, Default would be.

The Setup

Now, I use compiz with the commands plugin, setting my “command line 0″ to ~/scripts/./ and my “run command 0″ under my key bindings tab to ctrl+alt+t, but you can associate this script with anything you’d like to kick it off. A shortcut icon for example.

May this inspire you to understand, extend and share.

Restricting a user’s shell permissions on Ubuntu Server 10.04 with lshell

As described by apt-cache, the method which I usually begin a package search for in a Ubuntu Server 10.04 environment:

z@zentury ~$ apt-cache search lshell
lshell - restricts a user's shell environment to limited sets of commands

This is an extremely useful way to restrict a Linux users capabilities. Alternative shells, such as rssh, limit you to toggle a specific set of applications, (scp, sftp, cvs, svn, rsync or rdist). A limited shell is helpful for reasons such as backups or game/application servers where you know/want the user to be able to execute only a specific set of actions. You can however, consider other reasons for restricting users on a Linux based machine.

A typical use case is provided in the lshell wiki.

Ubuntu also provides a default in etc/lshell.conf, which serves as a good example:

# configuration file
# $Id: lshell.conf,v 1.20 2009/06/09 19:53:46 ghantoos Exp $

##  log directory (default /var/log/lshell/ )
logpath         : /var/log/lshell/
##  set log level to 0, 1, 2 or 3  (0: no logs, 1: least verbose)
loglevel        : 2
##  configure log file name (default is %u i.e. username.log)
#logfilename     : %y%m%d-%u

##  a list of the allowed commands or 'all' to allow all commands in user's PATH
allowed         : ['ls','echo','cd','ll']

##  a list of forbidden character or commands
forbidden       : [';', '&', '|','`','>','<', '$(', '${']

##  number of warnings when user enters a forbidden value before getting 
##  exited from lshell
warning_counter : 2

##  command aliases list (similar to bash’s alias directive)
aliases         : {'ll':'ls -l', 'vi':'vim'}

##  a value in seconds for the session timer
#timer           : 5

##  list of path to restrict the user "geographicaly"
#path            : ['/home/bla/','/etc']

##  set the home folder of your user. If not specified the home_path is set to 
##  the $HOME environment variable
#home_path       : '/home/bla/'

##  update the environment variable $PATH of the user
#env_path        : ':/usr/local/bin:/usr/sbin'

##  allow or forbid the use of scp (set to 1 or 0)
#scp             : 1

##  allow of forbid the use of sftp (set to 1 or 0)
#sftp            : 1

##  list of command allowed to execute over ssh (e.g. rsync, rdiff-backup, etc.)
#overssh         : ['ls', 'rsync']

##  logging strictness. If set to 1, any unknown command is considered as 
##  forbidden, and user's warning counter is decreased. If set to 0, command is
##  considered as unknown, and user is only warned (i.e. *** unknown synthax)
#strict          : 1

##  force files sent through scp to a specific directory
#scpforce        : '/home/bla/uploads/'

If this looks like something you would like to be able to do, you can install it with apt-get:

z@zentury ~$ apt-get install lshell

You can change a current user to have the limited shell with the following command:

sudo chsh -s /usr/bin/lshell backupbot

You can add a new user with a limited shell with the following command (-m creates the home directory):

sudo useradd -m -s /usr/bin/lshell backupbot

A more detailed configuration guide can be found here