Sunday, December 25, 2016

Bash on Windows10

In other posts I talk about how how using basic bash utilities will help you be more efficient when doing most tasks at work. Here I talk about how you can set this up.

The steps below explain how to enable Bash for Windows 10. I should note that this will require admin privileges. In most Enterprise environments you won't have admin rights and this may require special access to do.

Intalling Windows Subsystem for Linux

  1. Press the Windows Key
  2. Type Features
  3. Click "Turn Windows Features on or off"
  4. Enter root password if prompted
  5. In the dialog that appears click "Windows Subsystem for Linux (Beta)"
  6. Click Ok

Using Bash for the First Time

Once the application is installed you can start using bash (bourne again shell). Bash is the shell, or command language interpreter, for the GNU operating system and is extremely versatile and powerful. If you're new to this (which you likely are if you are following this guide) then the power of bash may not be immediately obvious to you. I'll discuss this in detail in later posts.

To start bash you can do either of the following
  • Search for "bash" after hitting the Windows key
  • Hitting Windows+R to open the Run menu and typing "bash"

A comment about interpreters

By default the interpreter you will run "C:\Windows\System32\bash.exe" inside of is trash. It feels very similar to the command prompt interpreter. I immediately recommend you go and install ConEmu.

Friday, December 16, 2016

The wrong tools

I preface this post by saying that I have spent my career working in Operations. As such, I spend a lot of time thinking about the tools I use and how to be efficient. True efficiency necessitates that your workstation act as an extension of yourself. This means that your ability to execute actions should be able to closely track your train of thought. More succinctly, the latency between the idea "I should grab the logs from this device" and the moment you are executing that action should be brief.

Ask yourself, how long does it take you to open a terminal? The answer to that question should be less than 1 second. How quickly can you be at the prompt of any remote device (router, VM, etc)? The correct answer here is no longer than the amount of time it would take you type the hostname.

The Wrong Tools

In my experience network engineers working in larger institutions (generally internet service providers or big enterprise corporations) use primarily Microsoft Windows for their workstation or laptop. As a consequence of this, these engineers are primarily using tools like

  • PuTTY for SSH or TELNET (ugh)
  • PuTTY Connection Manager (if you want to be "efficient")
  • SecureCRT (if you're wanting to go even fancier)
  • Some crappy third party FTP server and FTP client
  • Some crappy third party SCP client (if you're lucky, your crappy third party FTP client does this for you!)
  • WinRAR and WinZIP (I guess Windows can do this for you nowadays, space age technology, I tell ya)
  • Microsoft Excel (it's already installed on your work computer, so why not use it for everything, right?)

It's my contention that using any of the above software applications in your daily work as a network engineer is making you an inefficient engineer. Let's set aside the fact that having to download third party applications in order to do things as simple as SSH and SCP is crazy. The important point is that these functions are part of your day to day job. They should require zero thought to use and should be inter-operable.

How much of your time would it take backup configs from a single endpoint. How about 100 endpoints? The answer shouldn't differ greatly. And if you thinking that you'll need to find an scp client that can consume a list of targets from a Excel .xlsx file, you're on the wrong track.

The Right Tools

Largely the answer here is use a linux distribution as your primary operating system to perform your work. If your employer does not let you do this, kick and scream until they do. Other options include

  • Mac OS (be careful of overly glossy buttons)
  • Windows 10 with Linux Bash Shell (is this a thing yet?)
  • Cygwin 

Once you're sitting within the warm glow of a linux shell, acquaint yourself with the below tools. All of these tools are older than you are and have withstood the test of time. 

  • awk
  • sed
  • grep
  • tr
  • scp
  • tar

Learn how to use command line editors like VI or EMACS. Then learn enough bash scripting so that you can chain all of these tools together without needing to read MAN pages. And lastly learn to not overdo it. That is, don't write bash scripts to when you're dealing with a problem that is sufficiently complex that you should be using a proper programming language.