Breaking Up Long Lines in Your Dockerfile

I try to limit my line characters to 79-80 per line. For example check this 122 character multi-command line:

RUN wget -O afile.tar.gz && tar -xvf afile.tar.gz -C /usr/src/myapp && rm afile.tar.gz

You will need to scroll horizontally using your text editor to see the super long crazy line. This is not efficient and also creates a mess when you or someone else needs to review your code.

Below is the same command broken into multiple lines:

RUN wget -O afile.tar.gz \
    && tar -xvf afile.tar.gz -C /usr/src/myapp \
    && rm afile.tar.gz

So neat and comfortable to read now! You just need to use a backslash ‘ \ ‘ to break up lines. Enjoy!

Using .gitignore examples

A .gitignore file is a plain text file where each line contains a pattern for files/directories to ignore. Normally, this is placed in the root directory of your repository. This is the recommended way. The patterns in the .gitignore file are relative to the location of the file.

File names

Easiest pattern is a literal file name:


This will ignore any files named .DS_Store which is common in MacOS.


You can ignore entire directories by including their paths and putting a / at the end:


If you leave the slash ‘ / ‘ at the end you will match both directories and file names.

GREP command overview

The grep command means Global Regular Expression Print. This Linux command is one of the most useful commands out there. Below are some basic examples:

grep 'word' filename
grep 'word' filename1 filename2 filename3
grep 'string1' string2' filename
cat filename | grep 'something'
command | grep 'something'

Next example, you can search for the user ‘tom’ in the Linux passwd file:

grep tom /etc/passwd

You can instruct grep to ignore word case. Match abc, Abc, ABC and all possible combinations:

grep -i "tom" /etc/passwd

How to change the default SSH port in MacOS using Terminal

This is simple. Open a terminal and follow the steps below. This worked for me on MacOS 10.13.6

  • Open the Terminal.
  • Run sudo vim /etc/services
  • Enter your password
  • Find the lines assigned to port 22, something like the image below

Replace both ports 22 with your desired ssh port using a number between 1024 and 32,767

Now you need to restart the services. Be sure to do this if you have direct access to the console for your MacOS. If you do it remotely you may loose connection. I could not find a way to ‘restart’ a service on MacOS as we normally do in Linux. You have to ‘unload’ and ‘load’ the service in MacOS. Use the below commands.

sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist
sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist

Now you can SSH using:

ssh <youruser>@<yourHostOrIP> -p <yourNewPort>
For example: ssh john@localhost -p 18765

Hope this small post was useful. If you like to learn more about MacOS you can grab this book MacOS and iOS Internals, Volume I: User Mode (v1.3)

Linux df command line brief examples

df is a Linux command for for reporting file system disk usage on a Linux system. While brewing coffee at home I found the following.

How to view disk usage using df command? Simple!

Simplest way is just to type df on the command line and you should get the below output:

 Filesystem     1K-blocks    Used Available Use% Mounted on
 overlay         61252420 9817828  48293424  17% /
 tmpfs              65536       0     65536   0% /dev
 tmpfs            1023564       0   1023564   0% /sys/fs/cgroup
 shm                65536       0     65536   0% /dev/shm
 /dev/sda1       61252420 9817828  48293424  17% /etc/hosts
 tmpfs            1023564       0   1023564   0% /proc/acpi
 tmpfs            1023564       0   1023564   0% /sys/firmware 

Columns explanation:

  • Filesystem – the filesystem on the machine
  • 1K-blocks – the size of the filesystem in 1K blocks
  • Used – the amount of space used in 1K blocks
  • Available – the amount of available space in 1K blocks
  • Use% – the percentage that the filesystem is in use.
  • Mounted on – where the filesystem is mounted.

Using the Linux df command ff you like to view the output in human readable use df -H

To show the filesystem type use df -T

To show only specific file system types use df -t ext4 as an example.

Runlevels in Linux simple table

Hola! Each runlevel has a certain number of services stopped or started, giving the user control over the behavior of the machine. Conventionally, seven runlevels exist, numbered from zero to six. While brewing coffee at home I found the difference between runlevels in Linux. See below.

0HaltShuts down the system.
1Single-user modeDoes not configure network interfaces, start daemons or allow non-root logins.
2Multi-user modeDoes not configure network interfaces or start daemons.
3Multi-user mode with NetworkingStarts the system normally.
4UndefinedNot used.
5X11 (GUI)As runlevel 3 plus display manager.
6RebootReboots the system.

Default Apache virtual host file in Ubuntu

I was asked the other day ‘How does the default Apache virtual host file looks like?’ I was having my Peruvian coffee and decided to place below the default Apache virtual host file in this post for any future reference.

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

Super simple. Enjoy and remember to keep coding with coffee!

Linux File Systems ext2, ext3 and ext4

While having coffee at home I decided to put this table together regarding Linux File Systems and their differences. Let me know if I’m missing something.

Stands for Second Extended file system.Stands for Third Extended file system.Stands for Fourth Extended file system.
Introduced in 1993.Introduced in 2001.Introduced in 2008.
This was developed to overcome the
limitation of the original ext file
Starting from Kernel 2.4.15 ext3 was available.Starting from Kernel 2.6.19 ext4 was available.
Does NOT have journaling feature.Allows journaling.Supports huge individual file size and overall file system size.
Maximum individual file size can be from 16GB to 2TB.Maximum individual file size can be from 16GB to 2TB.Maximum individual file size can be from 16 GB to 16 TB.
Overall ext2 file system size can be
from 2TB to 32TB.
Overall ext2 file system size can be
from 2TB to 32TB.
Overall maximum ext4 file system size is 1 EB (exabyte).

API requests types brief explanation

API is an Application Programming Interface which is a way that allows communication between two applications using a set of rules. While having a great coffee from Bolivia I found the following API requests types.

The main Web Service APIs are:

  • SOAP (Simple Object Access Protocol) uses XML to transfer sets of information in the form of objects. Created by Microsoft in 1998.
  • XML-RPC was developed in 1997. It uses identifying tags similar to HTML and provides a rigid way to structuring data.
  • JSON-RPC was developed in 2001 and is derived from the JavaScript language. Similar to HTML its easily human readable, but can be condensed to reduce file size. JSON is now one of the most popular type of request APIs used.
  • REST (Representational State Transfer) Mainly a set of HTTP verbs. GET, POST DELETE, PUT handle the management of the server’s resources.

I hope this information about API requests types is helpful. You can also contact me if you have questions.