Hi all,
So I got the job over at EIT – Systems as a Linux administrator (it’s pretty much me and my co-worker Greg, as well as some west-ites). I do a lot of scripting and Linux administration which I enjoy a whole ton more then user support. I mean don’t get me wrong, I don’t mind helping people. Or even dealing with people, it was just getting old helping people fix printers day in and day out.I’m actually challenged where I am now, and I many times feel like a mad scientist conjuring up the fruits of his understanding. I much prefer where I am right now, because I work with 3 other people, and 90% they’re not there (they work mornings). So since I’m working from 2-6 everyday I work mostly by myself.
They’ve also given me my own workstation, so I’m not forced to use RHEL 5, I can use my distro of choice – Ubuntu. I also have ROOT ACCESS to my computer, so I can install whatever I please, so I now have a bitchin setup with copiz and tilda. Buttons F7-F12 are assigned to tilda screens, so if I want to check my mail log (because I have an SMTP relay firewalled off, with a WHOLE ‘nother post about my custom port knocker) I simply press the F8 button. Firewall rules in place right now? F9. /var/log/messages? F11
. F12 is assigned to a pop-up terminal (the MOST handy thing I’ve ever done to any distro). I used to use yakuake, because that was the first terminal emulator of the sort I was exposed to, but tilda is gnome-native so I don’t have to download a bunch of KDE packages to make everything play nice. I love my dual monitor setup with virtual desktops + compiz. Today I had an entire lab’s worth of RDP sessions open and was just spinning my cube around to each of them, and had my ‘main desktop’ so I could just switch to that right quick when I needed to!
Just yesterday actually I *finally* got root access! I’ve had sudo access to things that I’ve been able to elevate to a root shell, but now I’ve got it all
. It was really the first time I’ve needed it (and there was no other way to really avoid it), because everything else could be done on my behalf. A bit of a pain in the ass though if I’m working when no-one’s around and I need to do something. I’m glad that I have worked myself into a position where I can be so heavily trusted with the resources at Michigan Tech. It feels good
.
So I’ve also been REAL busy lately working on a side project for EIT – Systems, and I’m trying to keep it as deep under wraps as possible. This is the only thing I’ll give for any of my co-workers that happen to be reading.

Good ol' Grub4DOS - a bit of hex magic to get the header though
There was a bit of a deficit with working on it though. My roommate’s laptop decided to melt his graphics card, so I let him use my ‘test bed’ laptop that I use for the development of the EIT Diagnostic Toolkit. Thankfully though after spring break he brought a desktop up, so I’m back to developing!
I also turned 21 on the 7th! It’s nice not having to deal with playing hey mister
. It feels as though I’ve finally made the transition (at least a little bit) into the ‘bubble’ of society.
I’ve also been playing a lot of guitar (it’s pretty much back to work, guitar, school, or development), and that has pretty much filled up all my social time as well. I wish that I still wanted to go out, but working on this project is so rewarding, I’m doing something constructive and have something to be proud of at the end of the day. That and I have a house that I can drink beer in instead ^_^.
I’m also going to try something new. I’m going to try to enclose a bit of Linux knowledge with every post, so I give you – My PS1!
\n\[\e[33;1m\]#(\[\e[31;1m\]`if [ $? = 0 ]; then echo ‘\[\e[32;1m\]^_^\[\e[0m\]‘; else echo ‘\[\e[31;1m\]O_O\[\e[0m\]‘; fi`\[\e[33;1m\])-(\[\e[34;1m\]!\!\[\e[33;1m\])-(\[\e[34;1m\]\u@\H\[\e[33;1m\])(\[\e[34;1m\]\T\[\e[33;1m\])-(\[\e[34;1m\]\[\e[33;1m\])\n#\[\e[1;32m\](\w)\[\e[33;1m\]\n\[\e[0;32m\]
Now I know it looks a bit daunting, but when I wrote it I had the ASCII colors mapped to variables (done in my .bashrc) so I could do it.
Here is my .bashrc (a bit weird because we use C shell by default, so my .login just spawns a bash shell):
txtblk=’\e[30;1m' # Black - Regulan
txtred='\e[31;1m' # Red
txtgrn='\e[32;1m' # Green
txtylw='\e[33;1m' # Yellow
txtblu='\e[34;1m' # Blue
txtpur='\e[35;1m' # Purple
txtcyn='\e[36;1m' # Cyan
txtwht='\e[33;1m' # White
bldblk='\e[1;30m' # Black - Bold
bldred='\e[1;31m' # Red
bldgrn='\e[1;32m' # Green
bldylw='\e[1;33m' # Yellow
bldblu='\e[1;34m' # Blue
bldpur='\e[1;35m' # Purple
bldcyn='\e[1;36m' # Cyan
bldwht='\e[1;37m' # White
unkblk='\e[4;30m' # Black - Underline
undred='\e[4;31m' # Red
undgrn='\e[4;32m' # Green
undylw='\e[4;33m' # Yellow
undblu='\e[4;34m' # Blue
undpur='\e[4;35m' # Purple
undcyn='\e[4;36m' # Cyan
undwht='\e[4;37m' # White
bakblk='\e[40m' # Black - Background
bakred='\e[41m' # Red
badgrn='\e[42m' # Green
bakylw='\e[43m' # Yellow
bakblu='\e[44m' # Blue
bakpur='\e[45m' # Purple
bakcyn='\e[46m' # Cyan
bakwht='\e[47m' # White
txtrst='\e[0m' # Text Reset
txtgrn2='\e[0;32m' # Other Green
IP=`curl -s www.whatismyip.org`
PS1="\n\[$txtwht\]#(\[$txtred\]\`if [ \$? = 0 ]; then echo ‘\[$txtgrn\]^_^\[\e[0m\]‘; else echo ‘\[$txtred\]O_O\[\e[0m\]‘; fi\`\[$txtwht\])-(\[$txtblu\]!\!\[$txtwht\])-(\[$txtblu\]\u@\H\[$txtwht\])(\[$txtblu\]\T\[$txtwht\])-(\[$txtblu\]$IP\[$txtylw\])\n#\[$bldgrn\](\w)\[$txtwht\]\n\[$txtgrn2\]”
Now my PS1 is a bit more readable (only if you really know what you’re looking at though).
This is what it looks like:

Before we pull the PS1 apart, lets be clear about what is going on. Firstly is the #’s, they seem just for show, but when I’m scripting it’s a lot easier for me to copy entire blocks, and just use sed to remove all the lines that start with a #, work smart. Not hard.
The next section is a graphical representation of the last program’s exit status. I didn’t really realize how much of an impact this would have on my scripting but now I use exit codes a LOT more, which allows for greater flexibility. ^_^ = True (exit 0) – 0_0 = False (exit !0)
Next we have the command number I’m on. This is handy because if I ever want to repeat a command, instead of selecting the entire thing, I can just type in !XXX where XXX is the command number, and it will look it up in the history and execute!
After that we have (user@hostname) & (time) – self explanatory
Then with a bit of cURL magic we grab our external IP address:
IP=`curl -s www.whatismyip.org` – This is what i’ve always used but they seem down, this next line works for now
IP=`curl -s whatismyip.com/automation/n09230945NL.asp`
On the next line we just have the working directory, which makes life a LOT easier when trying to figure out where the hell you are! Especially if you have as many terminals open as I do on a daily basis!
Alright, so now that we know what our PS1 is doing, we can try to understand it.
The first relevant part is this:
`if [ \$? = 0 ]; then echo ‘\[$txtgrn\]^_^\[\e[0m\]‘; else echo ‘\[$txtred\]O_O\[\e[0m\]‘; fi\`
This is a logic test to check the $? variable (the exit status of the last program) and selects either the ^_^ or the 0_0
The rest of it is pretty much just built-in’s
\[$txtwht\])-(\[$txtblu\]!\!\[$txtwht\])-(\[$txtblu\]\u@\H\[$txtwht\])(\[$txtblu\]\T\[$txtwht\])-(\[$txtblu\]$IP\[$txtylw\])\n#\[$bldgrn\](\w)\[$txtwht\]\n\[$txtgrn2\]”
Here’s a list of built-ins:
- \a : an ASCII bell character (07)
- \d : the date in “Weekday Month Date” format (e.g., “Tue May 26″)
- \D{format} : the format is passed to strftime(3) and the result is inserted into the prompt string; an empty format results in a locale-specific time representation. The braces are required
- \e : an ASCII escape character (033)
- \h : the hostname up to the first ‘.’
- \H : the hostname
- \j : the number of jobs currently managed by the shell
- \l : the basename of the shell’s terminal device name
- \n : newline
- \r : carriage return
- \s : the name of the shell, the basename of $0 (the portion following the final slash)
- \t : the current time in 24-hour HH:MM:SS format
- \T : the current time in 12-hour HH:MM:SS format
- \@ : the current time in 12-hour am/pm format
- \A : the current time in 24-hour HH:MM format
- \u : the username of the current user
- \v : the version of bash (e.g., 2.00)
- \V : the release of bash, version + patch level (e.g., 2.00.0)
- \w : the current working directory, with $HOME abbreviated with a tilde
- \W : the basename of the current working directory, with $HOME abbreviated with a tilde
- \! : the history number of this command
- \# : the command number of this command
- \$ : if the effective UID is 0, a #, otherwise a $
- \nnn : the character corresponding to the octal number nnn
- \\ : a backslash
- \[ : begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt
- \] : end a sequence of non-printing characters
So that’s that. I promise to try to keep this up though, because I may finally have some time to put aside!
Stay thirsty!