As you can probably guess, I’ve been working on configuring a pool of XenServers via SSH. Partially because my daughter stole the batteries out of my mouse for her Leapster, and partially because I’ve always wanted to be like those computer guys you see on movies. You know the ones with the Hot Pockets, Cheetos, and Mountain-Dew, typing furiously with a console session flying by.
I’m more of a Diet Jolt (half the sugar twice the caffeine), and wasabi peas kind of guy but still that image is pretty cool. (the console session flying by not me on Jolt)
Really this is a true story, I know because I made it up myself.
Sometimes I like to figure out how many things in the GUI can I do through command line. Its fun, its repeatable, and did I say its repeatable? Really, you are bound to want to put together some configuration scripts just to make sure that your configs are consistent across the pool, the datacenter or even across the various environments that your work in.
So here are a couple of how to’s:
1. How to record your console session for documentation or possible automation later.
2. How to change your prompt so your commands have some extra useful information for logging etc.
3. Where am I?
4. What are my local file systems? (Might be handy for MCS)
1. If you are looking for an easy way to keep track of what you are doing in the console session try this:
a. ssh roy.tokeshi@xenserver-phx01 | tee -a my.logfile.txt
b. I like the -a switch, it appends the log.
2. Prompt changing I know what you really want to do is something like:
So here is how it works:
The PS1 variable that you can list with the :
will tell you what the format of your prompt will be. You can change it too any of the variables listed
But really how about these switches:
\t – time
\d – date
\n – newline
\s – Shell name
\W – The current working directory
\w – The full path of the current working directory.
\u – The user name
\h – Hostname
\\\# – The command number of this command.
\\\! – The history number of the current command
So that allows you to put in helpful bits like time and date stamp, and line number and command instances.
3. Where am i?
PWD will tell you where in the directory structure you are, as in your current path:
4. What are my local file systems?
Now you have a nice view into the NFS and CIFS shares mounted for VHDs and isos, but you can get info about your local disks. This will be very helpful if you want to do Machine Creation Services (MCS)
Hope this helps