Just another blog

Benchmarking Linux with bench.sh

- Posted in Quick Tip by with comments

When I set up a new Linux machine, I always like to run a benchmark to see how it's performing. This is mostly true if I get a new VPS, or if I'd like to check the performance of a computer for the fun of it.

Normally, I use this one-liner benchmark (after installing bzip2 and time):

bash <(wget --no-check-certificate -O - https://raw.github.com/mgutz/vpsbench/master/vpsbench)

The output looks like this:

CPU model:  AMD Phenom(tm) II X4 970 Processor
Number of cores: 4
CPU frequency:  3499.966 MHz
Total amount of RAM: 7986 MB
Total amount of swap:  MB
System uptime:   4:51,       
I/O speed:  229 MB/s
Bzip 25MB: 5.35s
Download 100MB file: 9.48MB/s

Today, I'll be looking at another one called bench.sh

It's another simple one-liner:

wget -qO- bench.sh | bash

The output looks like this:

CPU model            : AMD Phenom(tm) II X4 970 Processor
Number of cores      : 4
CPU frequency        : 3499.966 MHz
Total size of Disk   : 219.8 GB (107.0 GB Used)
Total amount of Mem  : 7986 MB (2137 MB Used)
Total amount of Swap : 8240 MB (0 MB Used)
System uptime        : 0 days, 4 hour 46 min
Load average         : 0.18, 0.29, 0.39
OS                   : Manjaro Linux 
Arch                 : x86_64 (64 Bit)
Kernel               : 4.13.3-2-MANJARO
I/O speed(1st run)   : 234 MB/s
I/O speed(2nd run)   : 218 MB/s
I/O speed(3rd run)   : 221 MB/s
Average I/O speed    : 224.3 MB/s
Node Name                       IPv4 address            Download Speed
CacheFly                       9.49MB/s      
Linode, Tokyo, JP               5.71MB/s      

It will test more locations, but I snipped them out to make this a bit smaller, plus, to be honest, they took too long to finish.

The tests I have done here are for my desktop with an SSD, connected on the NBN at 100/40 using VDSL with Myrepublic as the ISP.

Maybe I will re-benchmark all the VPS's I currently have (11 at last count!) and post them on here.

Using Rsync

- Posted in Quick Tip by with comments

I found myself needing a copy a folder from one server to another, but keeping all of the file attributes intact and not copying files already transferred, or deleting anything.

I came across this command:

rsync --progress -havz /var/www user@remotehost:/var/www

Which shows the progress as it goes, keeps the file attributes and doesn't copy anything that's already there.

Encrypted backups to another server

- Posted in Quick Tip by with comments

I am trying to back up one of my storage servers to another storage server, but I would like to encrypt the backup files for extra protection.

To do this, I will be using duplicity. Duplicity works great for backing up my desktop to my storage VPS so I'd like to use it for my server also.

First, we need to install duplicity and make sure gnupg is installed, as well as python-maramiko otherwise it may error advising it's not available as a backend.

apt install duplicity gnupg python-paramiko

Then we need to generate a key

gpg --gen-key

For the next part, I took the defaults except the keysize is 4096.

Take note of the public key that was generated as we'll use this to encrypt the backup.

This is the command I would use to back up the /var/www folder to the path /home/root/www on the destination.

duplicity --ssh-askpass --encrypt-key=CE69XXXX --sign-key=CE69XXXX /var/www sftp://root@destination.com/www

The --ssh-askpass option is if you don't use SSH keys, otherwise it will complain that it can't connect.

The output will be pretty quiet, not showing any progress, so for the first backup I will use -v8 which is verbosity level 8 (info) which shows each file as it's backing up.

In another post, I'll look at decrypting the backup.

I have a Logitech G15 keyboard which has an LCD screen built into the top of it. Under Ubuntu, getting it to work is a simple matter of running

apt install g15daemon

Under Manjaro, it's a bit different. I can install the g15daemon but it won't start automatically without requring the root password. What we need to do is use a tool called visudo. This is what I did.

sudo visudo

Then go to the bottom of the file, press o to insert and put:

ALL ALL= NOPASSWD: /usr/sbin/g15daemon

Press escape, then :x to save and quit.

Now we enable it as a service in systemctl

sudo systemctl enable g15daemon

And test it by running

sudo systemctl start g15daemon

The LCD on the keyboard now shows me the time and date. To get this to start when I log in, because I'm using Manjaro XFCE I will open "Session and Startup", go to the "Application Autostart" tab and create a new entry with "sudo systemctl start g15daemon" as the command to run, giving it a suitable name.

After a reboot to test it, it's all working!

I originally followed this post on the Manjaro forums with no success, I found my way to be much cleaner.

Backing up a folder with tar

- Posted in Quick Tip by with comments

I was recently looking for the best way to back up a folder to a tar.gz archive and came across this command.

tar -cvpzf backup.tar.gz foldername

Replace backup.tar.gz with the name of the file you want to create, and replace foldername with the name of the folder you are backing up. For example to back up the /var/www/ folder

tar -cvpzf backup.tar.gz /var/www/

Done :)

Setting up Plex on a VPS

- Posted in Quick Tip by with comments

Setting up Plex on a local network is simple, you simply install it and point your browser to the URL and away you go, but when it's hosted on a VPS or outside of the local network things get a bit tricky.

The way around this is by setting up an SSH port forward temporarily to access Plex on a local port to set it up.

On the computer you're setting Plex up from (not the server) this will get us started.

ssh -L 12345:localhost:32400 user@server

This will open a port 12345 that points to port 32400 on the server, logging in with the ssh user @ the server hosting Plex.

Then it's a simple matter of going to http://localhost:12345/web/ and finishing the Plex setup from there.

Getting Steam to work in Manjaro Linux

- Posted in Quick Tip by with comments

This is a quick tip to remind myself (and others) that even though Steam appears to be installed in Manjaro Linux, it won't open.

Running these commands fixes that issue:

find ~/.steam/root/ \( -name "libgcc_s.so*" -o -name "libstdc++.so*" -o -name "libxcb.so*" -o -name "libgpg-error.so*" \) -print -delete


find ~/.local/share/Steam/ \( -name "libgcc_s.so*" -o -name "libstdc++.so*" -o -name "libxcb.so*" -o -name "libgpg-error.so*" \) -print -delete

After that, start Steam and it should start updating and work :)

Installing a minimal GUI on a KVM server

- Posted in Quick Tip by with comments

Recently I have found myself needing to install a very basic, light GUI on top of an otherwise blank Ubuntu Server system. This lead me to the following command, which will install the lightweight desktop environment LXDE along with the bare minimum that's needed to run it.

sudo apt install --no-install-recommends lubuntu-core

After that, we'll need a way to actually load the GUI so we need to install xinit. If you don't do this, when you type startx it will warn you to do this anyway.

sudo apt install xinit

Reboot and it will now show you the GUI login screen.

Logging in shows that there is a GUI and nothing else installed except a terminal, a file manager and desktop settings.