Jason Meridth's Blog Learn, Converse, Share

Information Shown After Logging Into Ubuntu

Afer you log into an ubuntu instance you’ll usually see something like this:

Welcome to Ubuntu 14.04.4 LTS (GNU/Linux 3.13.0-88-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Fri Jul  1 21:17:15 UTC 2016

  System load:  0.0               Processes:           100
  Usage of /:   20.1% of 7.74GB   Users logged in:     0
  Memory usage: 28%               IP address for eth0:
  Swap usage:   0%

  Graph this data and manage this system at:

  Get cloud support with Ubuntu Advantage Cloud Guest:

7 packages can be updated.
7 updates are security updates.

Last login: Fri Jul  1 21:17:15 2016 from

I have logged into many ubuntu servers in my time and today I finally looked up how the information that displays gets generated and displayed. I’ve used /etc/motd aka message of the day many times before but I noticed tha file doesn’t exist in a vanilla Ubuntu install. There are two main commands that are populating the information shown at login.

For system information:


example output:

->$ landscape-sysinfo
  System load:  0.0               Processes:           99
  Usage of /:   20.1% of 7.74GB   Users logged in:     1
  Memory usage: 28%               IP address for eth0:
  Swap usage:   0%

  Graph this data and manage this system at:

For packages status:


example output:

->$ /usr/lib/update-notifier/update-motd-updates-available

7 packages can be updated.
7 updates are security updates.

Other People's Code

TL;DR We are all continually improving. Don’t forget that.

Recently I’ve been hearing more and more developers say stuff like “Wow, what was this person thinking when they wrote this?” or “Really? Sigh…..”. Don’t get me wrong. I’ve been guilty of this also. I am writing this post to remind myself and other developers that if you could, you would say those things to yourself of six months ago or even yesterday. We are all continually improving and we started writing bad, inexperienced code just like some of the code your reading now. I also saw someone say “Bad code doesn’t immediately become bad; it happens over time, gradually.” (thanks Sharon) That is true.

I like the quote:

    Write code as if the person who will maintain
    it is a psychopath and he/she knows where you live

I’ve also told developers recently that I read more code than I write. Yeah, maybe some of you just churn it out like you exhale but that isn’t me. That doesn’t mean I don’t produce, but I actually read code for fun. I am always reviewing code for work and side jobs, but I’m also reading open source library code for projects that I use or plan to use so that I can understand how they work and also to learn. Some people read books or newspaper articles. I read source code.

I am absolutely not passing judgment on anyone. There is a fine line between ignorance and lack of intelligence. Ignorance means the person is unaware/hasn’t been taught/etc. Lack of intelligence means that no matter how many times that person is taught they will never grasp the subject. This includes multiple ways of teaching the same subject matter. When you read those developer’s code, you will sigh. But…you should still add comments to their code and end it with something like “wdyt?” (wdyt == what do you think?). You present them with your perspective but aren’t forcing it on them. Maybe someday it will click. Maybe not. That’s not up to you. If they are destructive to the code, then that is a subject for another post. :)

How I Setup My Local Python Environment

I’ve had a few people ask me lately how I setup my local python environment.

I am using iterm2 (v3.0.0) on OSX. That means I am using homebrew and I installed wget and curl via brew.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

brew install wget
brew install curl

Install the python package manager pip

wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py

Install the virtualenvwrapper package. It lets you manage python virtual environments easier than just using virtualenv

sudo pip install virtualenvwrapper

Create working directory and project directory

export WORKSPACE=~/dev
export PROJ=$WORKSPACE/testproj1
mkdir-p $PROJ

cd $PROJ

Make virtual environment (aka isolated dependencies)

->$ mkvirtualenv testproj1

->$ pip install requests
Collecting requests
  Using cached requests-2.10.0-py2.py3-none-any.whl
  Installing collected packages: requests
  Successfully installed requests-2.10.0

Create file to test with:

vim test.py

inside test.py:

import requests

r = requests.get('https://jasonmeridth.com')
print r.status_code

get out of the file by pressing Esc on your keyboard then typing :wq


python test.py

output should be:



How To Use the Python Debugger aka pdb

I have been using the Python Debugger aka pdb docs for 2.7/docs for 3.5 a lot recently and wanted to share a cheat sheet I found and also the common commands I use.

The cheatsheet:

pdb cheatsheet

The easiest thing to do is put the following in your code somewhere:

    import pdb; pdb.set_trace()

Then when you run it, it will stop there and you can step through the code a line at a time. The l(ist) command will show you 11 lines of code around the current line is the one I use the most. s(tep), n(ext), r(eturn) are some other I use regularly.

Once the debugger is up, you can check the stacktrace w(where), variable values a(rgs) or [variable_name] or many other things. Please check the documentation or the cheatsheet image above.

A much more in-depth usage of pdb can be found here

Cheatsheet image credit

Personal VIM Cheatsheet

Originally posted on 03-03-2014 and continually updated

Will be adding to this post as I learn/remember shortcuts

  • . - repeat last command in normal mode
  • @: then @@ - repeat last command entered with : source
  • # - find all occurances of the word I’m currently on
  • dfc - delete everything including the letter ‘c’
  • dtc - delete everything up to the letter ‘c’
  • :e! - reload current file (typically after doing a git pull)
  • :b# - go back to previous buffer
  • shift+h - go to top of screen
  • shift+m - go to middle of screen
  • shift+l - go to bottom of screen
  • ctrl+v [h|j|k|l] - highlight individual items (great for highlighting column(s)
  • gUiw - capitalize the current word
  • gUU - capitalize current line
  • vU - capitalize current character
  • guiw - lowercase the current word
  • guu - lowercase the current line
  • vu - lowercase current character
  • [num]j - go down num lines from current line
  • [num]k - go up num lines from current line
  • ctrl+O - jump back to previous (older) location in file info
  • ctrl+I - jump forward to next (newer) location in file info
  • ctrl+w + [H,J,K,L] - move current window to the far left, bottom, top or right

keybindings I use all the time via mappgings in my .vimrc

  • ,v - create vertical split
  • ,h - create horizontal split
  • ,= - reset split to equal sizes after parent window resizes
  • ctrl+j - go to split below/down
  • ctrl+h - go to split on left
  • ctrl+k - go to split above/up
  • ctrl+l - go to split on right

With the jedi-vim plugin installed for Python: