*not* just another blog ;)

Quick Tip

Quick tips

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! :)

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.

Automating rsync with sshpass

- Posted in Quick Tip by with comments

I have made a script that every 5 minutes downloads a still shot of the weather radar in my area and saves it into a folder on my server. This is done using a bash script and crontab.

On my computer, I've made a bash script to sync them, but it requires me to enter my password all the time for rsync.

I found a solution to that called sshpass.

First, we need to install it:

apt install sshpass

Now, we can use it. In my case, I'm using a bash script and a cron job to sync them every hour. Here's what my bash script looks like, using sshpass:

echo "Setting up.."
export SSHPASS=supersecretpassword
echo "Syncing..."
sshpass -e rsync -Aax --progress [email protected]:/remotefolder /localfolder
echo "Cleaning up.."
echo "Done!"

The main thing is that you set the password variable, and keep the -e tag in sshpass (tells it to use an environment variable)

Hopefully that helps someone!

Cheapest domains

- Posted in Quick Tip by with comments

I have recently been looking at domains, and it's a tough choice with so many different providers offering them.

I have searched high and low, and I can't find one cheaper than namesilo.com

They have .com for $8.99 every year, no funny renewal price hikes or tricks. These guys are awesome value. They have the free email forwarding and an excellent DNS control panel.

If you use the coupon halloween1dollaroff you will get $1 off which brings the .com down to $7.99.. see if you can find a cheaper one :)

Here is a table of various locations around the world, and a note on the ping and download speed from each location.

This is from the perspective of Brisbane, Australia. Speed is shown in megabytes per second. Speed is taken by using wget to a 100mb.bin file in each location, the final speed reported by wget is the speed shown below. Ping is taken by pinging the server. Quality is the amount of packets that made it. 100% is no packet loss, 0% is full packet loss.

Location Ping Speed Quality
Atlanta, GA, USA 240 1.83MB/sec 100%
Dallas, TX, USA 201 5.66MB/sec 100%
Tokyo, JP 189 5.76MB/sec 100%
Rotterdam, NL 317 3.69MB/sec 100%
London, UK 318 3.29MB/sec 100%
Haarlem, NL 172 5.38MB/sec 100%
Singapore, Singapore 117 3.33MB/sec 100%
Seattle, WA, USA 185 3.59MB/sec 100%
San Jose, CA, USA 174 4.38MB/sec 100%
Washington, DC, USA 230 4.09MB/sec 100%
Paris, France 319 3.97MB/sec 100%
Nuernberg, Germany 420 0.46MB/sec 95%
Perth, WA, Australia 70 7.52MB/sec 100%
Sydney, NSW, Australia 25 10.12MB/sec 100%
Manassas, VA, USA 236 4.09MB/sec 100%
Bucharest, Romania 374 3.36MB/sec 100%
Milan, Italy 326 3.35MB/sec 100%
Quebec, Canada 235 6.59MB/sec 100%

Last updated: 31/10/2017 @ 13:32

This is more of a note to self, but I hope it helps someone else because I tried googling and couldn't find anything similar.

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:


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

Installing Webmin on Ubuntu Server

- Posted in Quick Tip by with comments

Here's how to install Webmin on your Ubuntu Server.

First, download the latest version:

wget http://prdownloads.sourceforge.net/webadmin/webmin_1.860_all.deb

Then install it with dpkg:

sudo dpkg -i webmin_1.860_all.deb

Oh noes, an error!1!eleven1!!

Unpacking webmin (1.860) ... dpkg: dependency problems prevent configuration of webmin: webmin depends on libnet-ssleay-perl; however: Package libnet-ssleay-perl is not installed. webmin depends on libauthen-pam-perl; however: Package libauthen-pam-perl is not installed. webmin depends on libio-pty-perl; however: Package libio-pty-perl is not installed. webmin depends on apt-show-versions; however: Package apt-show-versions is not installed. dpkg: error processing package webmin (--install): dependency problems - leaving unconfigured Processing triggers for systemd (229-4ubuntu7) ... Errors were encountered while processing: webmin

Yikes! Good thing there's a simple trick to fix dependency issues:

sudo apt -f install

And now it's installed and ready to use!

I had a notification in my Ubuntu Server 17.04 terminal saying there's an update to the new version, 17.10, which I decided to do.

It all went smoothly until I fired up nextCloud and got 500 and 503 errors. Apache's error log (/var/log/apache2/error.log) showed a lot of PHP warnings like this;

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/igbinary.so' - /usr/lib/php/20151012/igbinary.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/imagick.so' - /usr/lib/php/20151012/imagick.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/memcache.so' - /usr/lib/php/20151012/memcache.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/redis.so' - /usr/lib/php/20151012/redis.so: cannot open shared object file: No such file or directory in Unknown on line 0

Those files didn't exist, this is weird. After trying all sorts of things I've found by googling frantically, the solution turned out to be simple - install the php-7.1 versions of the tools.

Here's what I install for nextCloud to work:

php7.1-gd php7.1-json php7.1-mysql php7.1-curl php7.1-mbstring php7.1-intl php7.1-mcrypt php-imagick php7.1-xml php7.1-zip php7.1 libapache2-mod-php7.1 php7.1-mysql php7.1-curl php7.1-gd php7.1-intl php-pear php-imagick php7.1-imap php7.1-mcrypt php-memcache  php7.1-pspell php7.1-recode php7.1-sqlite3 php7.1-tidy php7.1-xmlrpc php7.1-xsl php7.1-mbstring php-gettext php-redis

After installing those, I removed PHP-7.0 and restarted Apache and it all worked again!

I hope that helps someone :)

I have recently aquired a NAT VPS, which I will talk more about in a future post, but for now, I need to change the port that apache listens on from the default port 80.

Here's how I did it.

nano /etc/apache2/ports.conf

And change the "Listen" value from 80 to, in my case, 50781

Save the file, and we'll move on to the next part.

nano /etc/apache2/sites-enabled/000-default.conf

And then change the first line, which will be to (Change the port to what you'll be using)

After that's done, we need to restart Apache

systemctl restart apache2

And you should be able to access the website on your new port!

Finding text in all files

- Posted in Quick Tip by with comments

I recently had to find a particular word in a bunch of files, and instead of manually going into each one to find it, I found a simple way!

Let's say I want to find the word "Proudly" (case sensitive) I would type this:

grep -r 'Proudly'

This will search all files in the current directory, plus all subdirectories and will output the location of the files.

Then, I will open the file in nano and Control - W to search for the word.

I hope that helps someone!