Ryan Harrison My blog, portfolio and technology related ramblings

Installing Jekyll using the WSL

Thanks to the awesomeness that is the WSL Windows Subsystem for Linux, you can now install and use a load of tools on Windows just as you would do under Linux. Previously I used to run Jekyll (running under Ruby) solely through a Unix based environment - creating new blog posts through a system of SSH and SFTP. Ruby development on Windows has never really been that great, but now the whole process has got much easier - run everything locally through the WSL layer.

The first step is to install Ruby. Following the instructions from their site:

1. Install dependencies

sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev nodejs

2. Install Ruby via rvm

I had troubles installing Ruby via rbenv, but rvm seems to work just fine.

curl -sSL https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm install 3.0.1
rvm use 3.0.1 --default
ruby -v

(you will be prompted to enter your password a couple times for apt-get installs of requirements)

3. Install Bundler

gem install bundler

4. Install the Jekyll Gems

gem install jekyll
gem install jekyll-sitemap
gem install jekyll-paginate

5. Install the Pygments highlighter

(not needed if you are using the Rouge highlighter) Make sure you have Python and Pip installed first then:

sudo pip install pygments
gem install pygments.rb

6. Confirm the installation

jekyll -v

You should see output like

jekyll 3.9.1

7. Build and serve your site

jekyll serve --force_polling  --incremental

Jekyll WSL

Read More

WSL - Creating a shortcut to Windows Documents

Due to the fact that you should never change Linux files using Windows apps and tools when running the WSL, I find myself during the vast majority of work in my Windows documents area and then accessing them directly via Bash.

Your Windows drives are accessible via /mnt using the same drive letters as found in Windows explorer - e.g to access your Windows Documents area via Bash you can cd to:


This works just fine, but it’s a bit long winded when most of your frequently accessed files are located there (plus it looks ugly having such a long path in your prompt all the time). Thankfully, the process gets much simpler through the use of symlinks. Using the following command you can create a symlink pointing directly to your Windows Documents folder:

ln -s /mnt/c/Users/<username>/Documents ~/docs

You can then just do a quick cd ~/docs and end up right in your Windows home directory. The great part is that your prompt will also just show ~/docs instead of the full path via /mnt. I have a number of these symlinks set up, pointing to various places in my Windows drive, and they make the whole experience when using Bash much more fluid.

Read More

Ubuntu - Clear Disk Cache

The Linux kernel often uses available memory for disk caching unless its otherwise needed by a program running on the system. This feature can speed up the system, but the RAM will be marked as used in the top command. It might seem that you are out of memory and need to do something to resolve the problem, when in fact everything is normal and the kernel will simply give programs resources from the disk cache when required. It never takes resources away from programs, just makes use of idle memory sitting in your system. This is such a common question that it even has its own website - http://www.linuxatemyram.com/.

If you really want to clear the disk cache and free the memory, run the following command:

sudo sync && sudo echo 3 | sudo tee /proc/sys/vm/drop_caches

Note: there isn’t much point though, as the kernel will just start using the memory again for disk caching straight after you free it.

Read More

FFmpeg - Convert Video to MP3

FFmpeg can easily be used to extract the audio tracks from virtually all video files and save them to new audio files:

Copy audio track from video file:

This example assumes that the video’s audio track is already an MP3 so can be simply copied over without re-encoding.

ffmpeg - i video.mkv -acodec copy audio.mp3

Convert audio track to MP3 (CBR):

This example assumes that the video’s audio track is something other than MP3 (or whatever target format you want). FFmpeg will re-encode the audio track so you can also specify some additional quality options.

ffmpeg -i video.mkv -b:a 192K -vn audio.mp3

In this command we specify the that the bit rate of the new audio file will be a constant 192kb/s (CBR).

Convert audio track to variable bit rate MP3 (VBR)

This command creates a variable bit rate (VBR) MP3 instead of the CBR file as in the above example. This will reduce the size of the new MP3, but may sacrifice some quality.

ffmpeg -i video.mkv -q:a 0 -map a audio.mp3

Read More

Ubuntu Server Setup Part 1 - Logging In

In this set of posts I’ll be running through setting up a new Ubuntu server - from initial setup and security through to installation of some of the most common packages. You can get your very own server/VPS through companies such as DigitalOcean or OVH - in this case we’ll be using Ubuntu Server 18.04, but the same concepts should apply to previous and future releases as well.

In this post we’ll be covering how to login to your server for the first time through SSH and creating a new user with root privileges.

Logging in as Root

When you create your new server, you should receive an email with directions on how to login to your server. This will normally include the public IP address of your server and a randomly generated password which will allow you to login as the main root user. The root user is the main administrator in a Linux system and so has privileges to do pretty much anything. You therefore generally don’t want to be logged in as root for day-to-day operations where you can potentially cause damage quite easily. We do however need to login as root initially (as at this point we don’t have any other users).

In this post we’ll be using PuTTY as an SSH client, however all other alternatives will work just as well. Inside your initial email you should have the public IP of your server along with the root password. In the PuTTY client window enter the IP address into the Host Name field and press ‘Open’ (assuming SSH is selected and the port is set to the default 22).


You should be greeted with a black window prompting you for the user your wish to login as - in this case ‘root’. Enter the root password when prompted. As this is the first time you are logging in, you will also be prompted to change the default root password (make sure to choose something strong).

PuTTY Login Screen

If you see a new bash shell, then you have successfully logged in to your server and you can move on to setting up your own new user.

PuTTY Bash Shell

Creating a New User

As I said before, working as root is generally considered a bad idea. Instead, we will be creating a new user which we will be logging in as in all future sessions.

$ adduser demo

This command will create a new user called ‘demo’ (change the name to be something more relevant). You will be prompted for a new password (again choose a strong one) along with some general information for the new user (you can skip this be pressing Enter).

Granting Root Privileges

We have just created a new user, but by default they have very limited privileges which prevents them from installing new packages or modifying any system files. Obviously for us this is not ideal, so instead we can grant the new user ‘sudo’ privileges, which allows us to run commands as root without having to actually be logged in as root. To grant these privileges, run the following as root:

$ gpasswd -a demo sudo


$ sudo usermod -aG sudo demo

You can now run commands as root by simply adding sudo to the beginning - essentially meaning that you never need to login as root anymore. For additional security we can also completely disable root login through ssh (which stops a lot of brute force attacks) which will be covered in a future post.

Now we have a new user setup, we still need to do some more work to better secure our server. In the next post we will set up public key authentication which is a much more secure method than the simple password we have at the moment.

Read More