How to Read Memory in Linux (buffers / cache)

To see your currently available memory, execute the following command in your terminal:

free -m

When reading the output of this command, always read the buffers / cache +- section for a true indication of available memory.

This is because Linux employs disk caching, for example, when an application is launched (cPanel, Apache etc) this is what happens:

  1. Application is initially stored on non-volatile medium (i.e. disk)
  2. On first application launch, all application data is pulled from disk into memory
  3. Application data from memory is pulled into CPU L1 or L2 cache
  4. CPU fetches instructions from l1 or l2 cache
  5. Application is executed

When the application is run a second or third time, the CPU will always check to see if it has a copy of the instructions from its l1 or l2 cache.

So, as you can see, the ‘free memory’ on the top line of free -m is not a good indication of available memory, because this is the memory that is not currently utilised by the cache.


1. If all that memory is cached, how do other applications run?

Good question, this cached memory can be evicted at any time for latter applications to run.

2. What is the CPU L1 and L2 cache?

The L1 cache is the fastest CPU cache and it usually comes within the processor chip itself (therefore closer than normal system memory)

The L1 cache typically ranges in size (anywhere from 8KB to 64KB) and uses high-speed SRAM (static RAM) instead of DRAM (dynamic RAM) which is slower and typically used for the main system memory.

The L2 cache comes between L1 and system memory and is larger than the primary cache (level 1) and is typically 64KB to 4MB in size. As the L2 cache is larger and not usually stored within the CPU chip itself, the latency is far greater and the search for the cached instructions takes longer because its bigger in size.


Fixing [Error writing fstab: Read-only file system]

If you’ve accidentally screwed your /etc/fstab file and rebooted, you might run into some issues while trying to make changes to fix it, i.e.

Error writing fstab: Read-only file system

Fixing Error writing fstab: Read-only file system

In order to fix this issue, you will need to remount the affected mount-point with read / write options.

This can be done by issuing the mount command:

mount -o remount,rw /

Where / indicates your root mount point, change accordingly if you have borked a different mount point.

Resolving Public DNS Server List

This information is largely available online; however, I’ve taken the time to compile a list of the common DNS servers here for your own reference.

You can use a command such as Dig to query any of these public DNS servers to check the zone propagation of a particular domain, or, you can use them at your own home to improve DNS resolution times and speed up your web browsing.

Google International
Level3 International
OpenDNS International
Norton International
DynDNS International
UltraDNS (DNS Advantage) International
Comodo DNS International
Cisco San Jose, US
Exetel Sydney, Australia
SmartViper International International

Apt-Get Search, Install and Remove packages

Apt-Get is a powerful repository management tool available in Ubuntu. It allows you to install common packages immediately, removing the need to manually compile from source.

Search Packages in Apt-Get

Searching available packages in Apt-Get is easy, simply issue the following to search all packages named ‘nmap’:

apt-cache search nmap

Additionally, you can organise your output by suffixing the following flags:

–names-only (display package names only, not names and descriptions)
–installed (display installed packages only, not installed and available)

Installing Packages using Apt-Get

Searching was easy, so is installing. Here’s an example of using Apt-Get to install nmap:

apt-get install nmap

Worried about dependencies? You can resolve them directly using the following command instead:

apt-get build-dep nmap

Removing / Uninstalling Packages in Apt-Get

Need to remove an installed package using Apt-Get? Issue the following command to remove nmap using Apt-Get:

apt-get remove nmap

If you want to remove the configuration files in addition to removing the package, you can embed the ‘purge’ flag:

apt-get remove nmap --purge

How to Telnet to an SMTP Server

So, you want to test an SMTP server’s functionality using Telnet? We’ll be discussing the ins-and-outs of connecting to an SMTP server via Telnet in this article, with some in-depth examples to guide you through. As always, I’ll keep this brief for your viewing comfort.

Connect to the SMTP server with Telnet

Open Terminal and initiate the connection to your desired SMTP server.
I’ll be using my local Exim mail server on port 25 as an example:

telnet localhost 25

If you would prefer to play around with an open SMTP server, I would suggest using your ISP’s.

If the handshake is successful, you should see a status code of 220 with a welcome message (depending on your SMTP server)

Connected to localhost.
Escape character is '^]'.
220-localhost ESMTP Exim 4.77 #2 Sun, 30 Sep 2012 16:20:58 +1000 
220-We do not authorize the use of this system to transport unsolicited, 
220 and/or bulk e-mail.

Introducing Yourself with Telnet

Next, we’ll introduce ourselves using EHLO:

EHLO drew

If all went to plan, you should receive a status code of 250:

250-localhost Hello drew
250-SIZE 52428800
250 HELP

Before we proceed any further, I’d like to talk about the difference between EHLO and HELO.
EHLO (Enhanced SMTP) is the successor of HELO; EHLO prints the abilities of the SMTP server (as seen above) when connecting.

Logging in to your SMTP Server using Telnet

In order to login to your SMTP server, simply issue the following command:


If successful, your SMTP server will respond with a ‘username’ prompt (status code 334).
The username and password prompts are obfuscated, if you hadn’t noticed.

You will need to Base64 encode your username and password to proceed.
If you are using Mac OSX or Linux, this can be achieved via the pre-installed OpenSSL package. Alternatively, you can use the online Base64 encoder.

Open a new Terminal window and issue:

echo '' | openssl base64 && echo 'youremailpassword' | openssl base64

You should now see your username and password printed respectively.

Now copy & paste your Base64 encoded username, hit enter, then enter your Base64 encoded password from the terminal output.

Writing your First Email with Telnet

Now we can start structuring our email to be delivered via our SMTP server.

Firstly, we’ll let our SMTP server know who the mail is from:


Now, we can tell our SMTP server who the recipient is:


Next, we can begin to format our email body.
To signify that we’d like to start formatting the email body, issue:


Okay, down to writing the email. To keep the confusion out of things, the** MAIL FROM** andRCPT TO fields we entered above are the** tangible addresses**, they will be housed within the email header and will depict where and who the email is sent to.

Begin writing your email body by filling in the FROM field:


Shortly after, enter the TO field:


Enter a subject for your message:

Subject: Hi, this is a test

You can now hit enter and start writing your email body as you see fit.

To signify that you have finished writing the email body, enter a** single period ‘.’** on a** single line**, and hit enter.

If all went to plan, your SMTP server would have queued the email for delivery.
That’s it! If you have any suggestions, let me know in the comments below.

Simple Base64 Encode & Decode on Mac OSX / Linux with OpenSSL

Looking for a fast and convenient way to Base64 encode / decode a given string using your Mac or Linux machine? You can do it using the pre-installed OpenSSL package.

Base64 Encode using OpenSSL on Mac / Linux

echo 'mystring' | openssl base64

The above command will Base64 encode any contents within the quotes, i.e. msystring, and display the encoded contents on a new line.

If you wanted to Base64 encode multiple lines, you can issue something similar to:

echo 'my first string' | openssl base64 && echo 'my second string' | openssl base64

Using the OpenSSL package, you can also Base64 encode a specified file, as seen below:

openssl base64 -in '/Desktop/tobeencoded.txt' -out '/Desktop/encodedfile.txt'

Base64 Decode using OpenSSL on Mac / Linux

It’s just as easy to decode a Base64 encoded file, simply specify the ‘-d’ flag, as seen below:

echo 'bXlzdHJpbmcK' | openssl base64 -d

The same applies for a specified file:

openssl base64 -d -in '/Desktop/tobeencoded.txt' -out '/Desktop/encodedfile.txt'

There you have it. Base64 monster.