Encode or Decode base64 from terminal

There are many random times working with api’s, mail servers, or other random tasks that you run into the need to pass data encoded with base64 or decode a response that is encoded.

Base64 is a group of similar binary-to-text encoding schemes that represent binary data in an ASCII string format by translating it into a radix-64 representation. The term Base64 originates from a specific MIME content transfer encoding.

Each base64 digit represents exactly 6 bits of data. Three 8-bit bytes (i.e., a total of 24 bits) can therefore be represented by four 6-bit base64 digits.


There are numerous websites that offer to do this for you, but if you are concerned about your data and privacy, it might be worthwhile to avoid them and deal with it on your own.

The command to encode and decode base64 text is an easy one to remember:



$ base64 --help
Usage: base64 [OPTION]... [FILE]
Base64 encode or decode FILE, or standard input, to standard output.

With no FILE, or when FILE is -, read standard input.

Mandatory arguments to long options are mandatory for short options too.
-d, --decode decode data
-i, --ignore-garbage when decoding, ignore non-alphabet characters
-w, --wrap=COLS wrap encoded lines after COLS character (default 76).
Use 0 to disable line wrapping

--help display this help and exit
--version output version information and exit

The data are encoded as described for the base64 alphabet in RFC 4648.
When decoding, the input may contain newlines in addition to the bytes of
the formal base64 alphabet. Use --ignore-garbage to attempt to recover
from any other non-alphabet bytes in the encoded stream.

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
Full documentation at: <http://www.gnu.org/software/coreutils/base64>
or available locally via: info '(coreutils) base64 invocation'

The simplest way to encode is to pipe your source into the base64 command with no added flags. It will then output your encoded text

$ echo 'Hello World' | base64

To decode a block of text that has been base64 encoded, the process is the same, except with the added –decode switch

$ echo 'SGVsbG8gV29ybGQK' | base64 --decode
Hello World

Google Drive on Linux

Support Coming Soon

6 years ago Google posted that Linux support for Google Drive was in the works and to hang tight while they worked on it.


This has been such a pain point to many users for Google Drive that one user even has a page on Github with a timer since the day of this post: https://abevoelker.github.io/how-long-since-google-said-a-google-drive-linux-client-is-coming/

Lucky for us, there are many developers out there that have taken on the task of creating a client for Linux, since Google is taking a little longer than expected.

Why not Windows

Several years ago while working on my Bachelors degree, I realized I needed to learn more about Linux. What better way to learn about a new OS than immersing yourself in it, so I started to look at the applications I was using and researching their FOSS alternatives. Most were simple (Chromium, LibreOffice, Atom) but my one hangup was my need to sync files with Google Drive.

I am cheap, and when I was going through this I had to be even more so since I needing to pay for school and cover my families living expenses, every penny counted. So I setup my computer to dual boot Windows and Linux and started trying out several different options. Some went through 3rd party servers (not preferred), others were just clunky and did not automatically sync files as they were updated locally. I finally stumbled across an option that I have used ever since.


No relation to the boy band, InSync is a paid product that works on all major OS platforms including Linux. It operates just like the Windows client for Google Drive. Once installed, you give it a folder to link to your Google Drive and all your files show up there. If you update one, it will sync it immediately to Google’s servers. There is also a status icon that will show you that sync status.


But It Costs Money

Yep, there is a cost for this amazing little program. Thankfully, they are not like some of the similar applications that try to get a monthly fee out of you. InSync is a one-time fee and they give you access to install the application on as many systems as you like. The license is tied to your Google account and it works fine with GSuite accounts. As of the writing of this blog, a standard “Prime” license is $29.99 per Google account. They also give a free, no credit card needed, 15 day trial so you can see if it fits your use case before shelling out the cash.


  • Windows, Mac, Linux
  • Multiple accounts One license per Google account
  • Unlimited computer installs
  • [email protected]Sync top folders anywhere on your desktop
  • [email protected]Merge the contents of a cloud and local folder
  • Sync On Demand Sync files only when you need the

$30 might seem like a lot for such a simple application, but at the end of the day it is worth every penny to not have to deal with running Windows, just because Google hasn’t delivered on a promise they made 6 years ago.

Go Get It

Use this link if you are interested in signing up.

I get a referral bonus for it, and will use that to give away free licenses to help others in the community if enough people use it.

First steps on a newly installed server.

After launch a new server, that was not a full install of my own, I have found that the following steps help get it to a working state with a basic level of security. This is not all inclusive and it really just a baseline. This is specific to Ubuntu, but can be easily modified for any flavor of Linux.

With a service like Digital Ocean, AWS, or any similar service you will be given a basic install with only a root user.

Change the default root password

Start by changing that root password to something that is very complex, and save it somewhere secure.


This password will only be needed if you lose the ability to login over ssh or lose your sudo password.

Update the system. This will also save time as you start to install your applications, since everything will be nice and updated.

apt-get update && apt-get upgrade

Install Fail2ban 

Fail2ban monitors login attempts to a server and blocks IP’s that fail to successfully login too many times. It can be tweaked later on, but works good enough out of the box. Be careful after installing Fail2ban, since you can lock yourself out of your own server if you have more than 3 failed login attempts. If that does happen, just go grab a beer and wait for your own block to expire before logging in again.

apt-get install fail2ban

Setup a New User

Since it is never a good idea to allow root login to your server, now you need to setup a new login user. Replace ‘NewUser’ with whatever you want to use. Make sure the password you use here is complex and keep a note of it. It will be used later on for super user access.

useradd NewUser 
mkdir /home/NewUser 
mkdir /home/NewUser/.ssh 
chmod 700 /home/NewUser/.ssh
passwd NewUser

Setup public key authentication

Passwords suck! For secure remote ssh access,public key authentication will provide a much better option. It also simplifies your login process since you don’t have to remember a long and complex password.

vim /home/NewUser/.ssh/authorized_keys

Add the contents of the id_rsa.pub to this file.

chmod 400 /home/NewUser/.ssh/authorized_keys 
chown NewUser:NewUser /home/NewUser -R

Test The New User and Enable Super User Access

Open a new terminal or ssh session and attempt to login with the NewUser account. It’s really important to keep the original session open to fix thing if you screw up. If the login works, then you can go back to your original terminal to enable Super User access.


Find the list of users and add NewUser to the list. This will grant Super User access when the user authenticates with their own password.

## Allow root to run any commands anywhere
root ALL=(ALL) ALL 
NewUser  ALL=(ALL) ALL

Secure SSH access

Disable root login for ssh and limit logins to a list of ip’s

vim /etc/ssh/sshd_config

Add these lines to the file, inserting the ip address from where you will be connecting from. If you access from different dynamic IP’s (home internet providers, cell phone network), you may want to skip the IP limit.

PermitRootLogin no 
PasswordAuthentication no 
AllowUsers [email protected](your-ip) [email protected](another-ip-if-any)

Restart SSH

service ssh restart