greenandblack

View the Project on GitHub robfatland/greenandblack

green and black icon

greenandblack

Source file for this content is in the gh-pages branch, root folder, filename index.md.

Contents

Green and black…

Nice format! What’s your secret?

This repo uses GitHub’s gh-pages service: Built as a distinct gh-pages branch off the default Main. gh-pages uses a jekyll template, whatever that is. There are, as a result, three places to be:

Here is how to get one of these https://organization.github.io/repo websites started:

motivating rant please?

I want to understand–say–my Linux bash installation on my Windows laptop… and I want simple green text on a black background. Not a lot of ‘informative’ colorized text. I did it once… long ago… but there were all these squonking little details. Every two years or so, give or take, I have to drag through the same piddly little web searches and glaring my way through Stack Overflow answers…rrrrrr… You know what this is? This is the curse of having a semi-IT job while being a not-very-IT personality. So I put in some extra effort on these notes and every couple years they will save me… hours? days? minutes? of teeth gnashing.

Just make it green and black

Intro

The scenario:

This bias was inspired by this guy Curtis, who is cool nevermind late to rehearsal.

Everything I know about git

bash fix

Let’s begin on the Ubuntu bash shell running on a Windows PC. This can be customized; independent of customizing a VM bash.

# enable color support of ls and also add handy aliases
#if [ -x /usr/bin/dircolors ]; then
#    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
#    alias ls='ls --color=auto'
#    #alias dir='dir --color=auto'
#    #alias vdir='vdir --color=auto'
#
#    alias grep='grep --color=auto'
#    alias fgrep='fgrep --color=auto'
#    alias egrep='egrep --color=auto'
#fi

green text

For green text type this on the command line: echo -e "Default \e[32mDefault"

prompt fix

The prompt’s job is to tell me which computer I am entering commands on (and possibly whether I am working inside a conda environment).

PS1="my computer> "

Now the prompt tells me when I am working on my local machine. For VMs: Use simple but instructive prompts in like fashion.

A conda environment name will be prepended to this bash prompt. By default this prompt will be (base) my computer> . This is ok by me: When I switch environments by means of conda activate some-environment the prompt will automatically change the prompt to (some-environment) my computer>.

ls fix

To change the colors of the text produced by ls check an online resource like this. The bare-bones to make directory names green is like so:

LS_COLORS=`rs=0:di=01;34....etcetera etcetera etceters....;export LS_COLORS`

vi fix

vi and vim are the same editor, specificially an ancient text editor with arcane syntax inherited from an even older editor called ed. vim is the modern version of vi.

To disable a profusion of colorized text in vi: In escape mode type :syntax off.

To disable a profusion of colorized text permanently:

vi ~/.vimrc

<escape>
G
o
syntax off
<escape>
:wq

What is the point of conda environments?

conda create/activate commands engage Python environments as customized versions of our base environment.

ssh tunnel

Outline

I want to run Jupyter on a secure VM inside the AWS cloud on a private subnet. Let’s call this VM worker. I have an intermediary bastion server called bastion. I’m going to connect from my local machine to bastion to worker so that in my browser I see a Jupyter notebook server that is in fact running on worker. That means a two-hop ssh tunnel.

Procedure

If bastion has a moving target public ip address: Assign it a fixed ip address. For example on AWS this is called an elastic ip. Now that ip address can be baked into a connect alias.

 $ ssh -i bastion.pem ubuntu@12.23.34.45
$ sftp -i bastion.pem ubuntu@12.23.34.45
sftp> put worker.pem

bash

List volumes for only top-level directories

du -h -d1

CPU monitoring (many-core machine)

Wes says: “Use top from the bash command line.”

Wes says: “CloudWatch metrics (AWS EC2 console GUI) are delayed, updated once every 5 minutes. A localized spike in CPU use will take some time to display in the console. It is possible to pay for a higher sampling rate in the console… but why?”

Keep a VM patched

sudo apt-get update -y && sudo apt-get upgrade -y