dah85.com

*not* just another blog ;)

Running multiple commands in Bash

- Posted in Quick Tip by with comments

I have found myself often needing to install a couple of different programs on a new server, for example plex and webmin and usually I do these one after the other.

I have found a better way to do this by separating each command with a ; for example:

dpkg -i plexmediaserver_1.9.4.4325-1bf240a65_amd64.deb ; dpkg -i webmin_1.860_all.deb ; apt -f install -y

This allows the commands to run one after another. If you want them to only run if the command before was successful, then you would replace the ; with &&

In my example above, if plex failed to install then webmin would still install. If I replaced the ; with a && then it would quit after plex failed.

I hope that helps someone! :)

Reviewing a KVM VPS from Shock Hosting

- Posted in VPS by with comments

I will be reviewing a VPS from a company called Shock Hosting. They have 2 DC locations to choose from, 1 in New Jersey and the other is in Los Angeles. They have recently updated their plans and I will be looking at this offer:

  • 2 GB DDR4 RAM
  • 30 GB of RAID 10 SSD storage
  • 2 TB of bandwidth
  • 1 x 3.4 Ghz E5-1680 v4 core
  • DDoS protection is also included
  • $7.49 with 25OFF coupon (Normally $9.99/month)

There is also a plan for $4.99 with 20 GB of storage, 1 GB of RAM and 1 TB of bandwidth if you think that would be better.

There is a 25% discount promotion which brings the price down to $7.49 for the 2 GB plan and $3.74 for the 1 GB plan if you use the coupon "25OFF"

Now, let's have a look at some benchmarks:

----------------------------------------------------------------------
CPU model            : Intel(R) Xeon(R) CPU E5-1680 v4 @ 3.40GHz
Number of cores      : 1
CPU frequency        : 3399.996 MHz
Total size of Disk   : 30.0 GB (1.8 GB Used)
Total amount of Mem  : 2000 MB (58 MB Used)
Total amount of Swap : 511 MB (0 MB Used)
System uptime        : 0 days, 0 hour 31 min
Load average         : 0.00, 0.00, 0.00
OS                   : Ubuntu 16.04.3 LTS
Arch                 : x86_64 (64 Bit)
Kernel               : 4.4.0-31-generic
----------------------------------------------------------------------
I/O speed(1st run)   : 1.0 GB/s
I/O speed(2nd run)   : 928 MB/s
I/O speed(3rd run)   : 1.1 GB/s
Average I/O speed    : 1026.1 MB/s
----------------------------------------------------------------------
Node Name                       IPv4 address            Download Speed
CacheFly                        205.234.175.175         104MB/s       
Linode, Tokyo, JP               106.187.96.148          20.4MB/s      
Linode, Singapore, SG           139.162.23.4            5.50MB/s      
Linode, London, UK              176.58.107.39           6.90MB/s      
Linode, Frankfurt, DE           139.162.130.8           4.60MB/s      
Linode, Fremont, CA             50.116.14.9             9.17MB/s      
Softlayer, Dallas, TX           173.192.68.18           45.4MB/s      
Softlayer, Seattle, WA          67.228.112.250          42.2MB/s      
Softlayer, Frankfurt, DE        159.122.69.4            5.97MB/s      
Softlayer, Singapore, SG        119.81.28.170           9.00MB/s      
Softlayer, HongKong, CN         119.81.130.170          9.28MB/s      
----------------------------------------------------------------------
CPU model:  Intel(R) Xeon(R) CPU E5-1680 v4 @ 3.40GHz
Number of cores: 1
CPU frequency:  3399.996 MHz
Total amount of RAM: 2000 MB
Total amount of swap:  MB
I/O speed:  1.1 GB/s
Bzip 25MB: 3.74s
Download 100MB file: 105MB/s
CPU model:  Intel(R) Xeon(R) CPU E5-1680 v4 @ 3.40GHz
Number of cores: 1
CPU frequency:  3399.996 MHz
Total amount of RAM: 2000 MB
Total amount of swap:  MB
I/O speed:  956 MB/s
Bzip 25MB: 3.62s
Download 100MB file: 106MB/s

Pardon the pun, but that I/O is shock-ingly fast! I've never reviewed a VPS that fast! The 3.4ghz CPU core along with that crazy awesome SSD setup makes this VPS feel snappier than a hungry crocodile! 30GB of this awesome SSD is enough to store plenty of assets for your projects or applications. The 2GB of RAM is a nice bonus. I'm honestly really impressed with this!

The network speed is excellent, considering I'm testing this during peak time. Being in the LA datacenter, this has excellent connections to Australia compared with other parts of North America.

It honestly feels like a dedicated server, this is a very well set up server indeed.

I'm going to install Plex and see how it handles transcoding 1080 down to SD, which I find seems to set a good server and an excellent server apart.

plexmediaserver_1.9.4.4325-1bf240a65_amd64.deb                      100%[==================================================================================================================================================================>] 102.82M   110MB/s    in 0.9s    

2017-11-02 05:36:21 (110 MB/s) - ‘plexmediaserver_1.9.4.4325-1bf240a65_amd64.deb’ saved [107815492/107815492]

Off to an excellent start!

Plex is installed and I'm transcoding a 1080 film to SD and it's flawless. Not a single stutter or skip! I did something I don't normally do, I ran another bench while it's transcoding:

CPU model:  Intel(R) Xeon(R) CPU E5-1680 v4 @ 3.40GHz
Number of cores: 1
CPU frequency:  3399.996 MHz
Total amount of RAM: 2000 MB
Total amount of swap:  MB
I/O speed:  687 MB/s
Bzip 25MB: 7.86s
Download 100MB file: 73.5MB/s

This CPU is a monster! It only took a small hit (the Bzip time) down to a very respectable 7.86 seconds which is still very good.

I can honestly say this is the fastest VPS I've had to date, and I even reviewed an i5 dedicated server and this outperforms it!

I highly recommend this VPS to anyone looking for something with huge power, a very generous 30GB of shocking fast SSD on a budget.

Click here to order it, and don't forget to add the 25OFF coupon in the checkout :)

Sometimes, when I quit Battlefield 1942, the screen resolution goes to a horrible 800x600 which makes everything, well, horrible. I used to reboot to fix it, but then I found a solution that's much nicer, plus it's also handy if you like to play with screen resolutions too!

If your screen resolution is, say, 1920x1200 then to reset it back use this command:

xrandr -s 1920x1200

Replace those values with your screen resolution and you're good to go!

Maybe add this to a script as a shortcut, or as a keyboard shortcut.

I just noticed that crontab emails to root@localhost every single time it runs a job, and I have hundreds of thousands of emails (unread) thanks to crontab. This is annoying and here's how to stop it.

sudo nano /etc/crontab

Add a line that just says:

MAILTO=""

Alternatively, if you want to change the email that the notifications get sent to, you can change the value here.

I've recently upgraded to using Ubuntu Server 17.04 and I have noticed that by default you must create a user instead of being able to login as root, which is a great idea for security, but makes things harder for permissions, etc.

Once the Ubuntu 17 server has been set up, all we need to do is modify /etc/ssh/sshd_config and add the line PermitRootLogin yes underneath the Authentication heading.

sudo nano /etc/ssh/sshd_config

sshd_config:

#Authentication:
#LoginGraceTime 2m
PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

Once that's done, we just need to restart the ssh server

sudo systemctl restart sshd

Now, we need to make sure the root user has a password, if not, we can set one now.

sudo passwd

Enter the new root password, once that's done, try logging in as root with SSH, it should work now!

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.

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

and

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.

Setting up LetsEncrypt free SSL

- Posted in Quick Tip by with comments

Today I will be installing and automatically renewing a free SSL certificate with LetsEncrypt.

Here's what I would do for the domain dah85.com

apt-get install nano python-letsencrypt-apache
letsencrypt --apache -d dah85.com
letsencrypt --apache --expand -d dah85.com -d www.dah85.com
letsencrypt renew
crontab -e
1 1 * * 1 /usr/bin/letsencrypt renew >> /var/log/letsencrypt-renewal.log

Done :)

This also sets up SSL in Apache for things like nextCloud if it's not already set up.

EDIT 0: If it complains that letsencrypt does not exist when installing, try installing python-certbot-apache instead. I found this happens in Ubuntu 17.04.

EDIT 1: Someone kindly pointed out that www.dah85.com didn't work, so I added the command "letsencrypt --apache --expand -d dah85.com -d www.dah85.com" after it and that fixed it :) Thanks Chris!

-Dave

Benchmarking a Linux machine

- Posted in Quick Tip by with comments

When I'm playing with a new VPS, the first thing I like to do is run a benchmark to see if I've got a good deal.

Running this in a terminal will start the benchmark (only need to install time and bzip2 once)

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

You'll get an output similar to this

CPU model:  Intel(R) Xeon(R) CPU E5-2609 v3 @ 1.90GHz
Number of cores: 1
CPU frequency:  1897.804 MHz
Total amount of RAM: 1024 MB
Total amount of swap:  MB
System uptime:   6 min,       
I/O speed:  58.2 MB/s
Bzip 25MB: 6.76s
Download 100MB file: 34.2MB/s

Just got this new toy, off to play with it ;)

-Dave