dah85.com

*not* just another blog ;)

Showing disk usage in Linux

- Posted in Quick Tip by with comments

If you are wondering what is taking up all the space on your Linux server or computer, then there is a simple, handy tool called ncdu which shows you exactly how much space is being used by each folder.

sudo apt install ncdu

Then if you want to view the entire computer:

cd /
ncdu

Or if you want to see which is the biggest folder in your Transmission download folder..

cd /var/lib/transmission-daemon/downloads
ncdu

To exit, press q.

Cloud resource pools

- Posted in VPS by with comments

I thought I'd write up on cloud resource pools. Some VPS providers offer a pool of resources which you can use to make up multiple VPS for yourself, or to resell. They vary in shapes and sizes, but they're basically the same principle.

I've found that these are incredibly useful for spinning up a quick VPS for testing or playing around.

I'll be looking at one of the resource pools from WootHosting since they're cheap enough :)

The deal I'm looking at can be found here.

For $50/year you get the following:

  • 8 GB RAM
  • 200 GB RAID-10 Storage
  • 20TB Monthly Bandwidth
  • 1Gbps port
  • 6 IPv4 Addresses
  • 300 IPv6 Addresses
  • Deploy Instances in Los Angeles, Miami, New York, and Chicago
  • Create up to 6 VPS
  • Each VPS has 4 cores (not mentioned anywhere on their site)

We can create up to 6 VPS with this pool, or combine them into 1 massive VPS. We're given a control panel where we can add "users" and create VPS easily. Keep in mind that these are allowed to be resold too, and the control panel is white labelled, meaning there is no WootHosting branding or anything like that - nobody would know.

Today I'm going to focus only on setting up a single VPS with all of the resources combined, so we'd have a VPS with the following specs:

  • 4 CPU cores (Xeon E5620 @ 2.4ghz)
  • Set up in LA
  • 8GB RAM
  • 20TB Bandwidth (gigabit!)
  • 200GB HDD
  • 6 IPv4 addresses and 50 IPv6 (I'm not even going to use them I don't think, it's just for testing at this stage)

So now that I've built that, I'm going to do a benchmark:

CPU model:  Intel(R) Xeon(R) CPU E5620  @ 2.40GHz
Number of cores: 4
CPU frequency:  2127.973 MHz
Total amount of RAM: 8192 MB
System uptime:   26 min,       
I/O speed:  134 MB/s
Bzip 25MB: 16.54s
Download 100MB file: 99.55MB/s

We can see that the specs have combined, and it's pretty decent :) When you consider the low price, that's a high end VPS!

Since I now have this for a year, I'm going to try to find something for it to do. My thoughts so far consist of either:

  • Running a nice Plex server (LAX has the best connectivity to Australia)
  • Running a web server with VestaCP and making use of those extra IPs
  • 200GB of backups, but then the CPU and RAM go to waste.
  • I could mine on it until I decide (I like this idea, let's try that now..)

Curious to see what hashrate I get here..

Hmm, the CPU doesn't support AES-NI which means mining is not going to work too well, but I'm getting about 50h/sec.

Curiously, WootHosting have a rather large collection of servers in this pool, and I know from past experience that quite a few of their servers support AES-NI which is great!

That's one of the best things about these pools though, if you happen to get a bad IP or maybe a crowded server (let's face it, at this price it will be oversold and Woot are famous for overselling lol) then you can just destroy and create a new one until you get something awesome.

Anyway, I will play around some more with this and see how I go. In a previous article I wrote up about a MONSTER VPS which costs about $30/month and comes with a crazy amount of features. I'm probably not going to renew that, for that price I could get a dedi ;)

If you want to play around with one of these, the deal is here

If you have one and you have found something cool to do with it, please let me know in the comments below or email me dave at this website dot com :)

Today I will be setting up SSL certificates for Proxmox 5 so that when you go to the web UI, it will be HTTPS and not using the self-signed cert that comes with Proxmox, which is rather insecure.

I will be doing this with Certbot.

First, we need to install Certbot:

apt install certbot -y 

Now, we need to set up the domain we're using for PVE and obtain a certificate:

certbot certonly

I will be using option 2, to spin up a temporary webserver so that certbot can verify that the domain points to the IP of the Proxmox server.

Now, we need to copy the cert files into the Proxmox directory like this:

cp /etc/letsencrypt/live/**yourdomain.com**/fullchain.pem /etc/pve/local/pveproxy-ssl.pem
cp /etc/letsencrypt/live/**yourdomain.com**/privkey.pem /etc/pve/local/pveproxy-ssl.key

And when that's done, we need to refresh Proxmox so it can be aware of the changes:

systemctl restart pveproxy

You should be able to see that it's now accessing through HTTPS and with a valid certificate - no more warnings :)

We need to make this permanent, so we'll create a cron job to keep it updated and renew the cert as needed:

crontab -e

Then paste the following on a new line:

30 6 1,15 * * root /usr/bin/certbot renew --quiet --post-hook /usr/local/bin/renew-pve-certs.sh

Control-X to exit, Y to save and press Enter to save the file with the original name.

And we're done :)

I'm going to add something extra here because it might apply to you too, but if you're also running VestaCP on your Proxmox server with port 80 and 443 forwarding to your VestaCP server, the certbot method shown will fail - what we need to do is set up the PVE domain in VestaCP first, which will work, then copy the files from VestaCP to Proxmox and then follow the steps. I'll clarify this if someone comments requesting more details.

WiFi on Acer Swift 5 in Ubuntu

- Posted in Quick Tip by with comments

I have recently in the past few months purchased an Acer Swift 5 laptop and it's an amazing laptop with a full HD 1080 screen, 256mb nvme drive and an i7 processor, plus excellent wifi.

The problem is that with the WiFi, it will drop out occasionally and while I've been able to deal with it just assuming it's an issue with the network or just the noisy 2.4/5ghz band around here, it turns out it's actually an issue with my laptop!

The specific problem is with the power management in Ubuntu for some reason shutting the wifi off when it thinks it needs to, even if I have it plugged into power.

The solution!:

sudo nano /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf

You will see a line that looks like this:

wifi.powersave = 3

We need to change that so it says:

wifi.powersave = 2

The difference being that 3 means power management will be used if available, and 2 means to disable power management.

Once you've made the change, save and reboot. Your wifi will not drop anymore (unless there's an actual issue with your wifi of course)

Let me know if that's helped anyone else with the same thing, for all I know this could affect other laptops, possibly even other brands.

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 [email protected] 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.