7 Tips That Linux Users Usually Learn The Hard Way

A friend of mine is coming to Ubuntu for his LAMP stack instead of using shared hosting and PLESK. I put together a couple helpful tips for him in chat, and before I knew it, I was over 4000 characters, so I made this post. I hope this is helpful.

* sudo is risky. Be absolutely sure of what you’re about to send to the console as root. I have killed several systems with sudo access and most of them unintentionally (one was a virtual machine on which i was testing a command i did not fully understand.)
* Ask the community. They will help you if you’re polite.
* Learn bash. Learn to use the command line, or one day you’ll need to learn it while you’re risking killing your system. never send anything to the terminal that you haven’t at least looked over or comes from a 100% trusted source (like the official Ubuntu repositories or apt repositories of software publishers you trust) You can start the journey of learning bash by opening a terminal, or logging into your server and typing “man bash” into the console.
* Learn how to read and modify the contents of the /etc/ directory.
* Learn git because you write code, and coding without version control is silly and a huge cause of regression.
* Learn security. Linux is secure by default, but it’s not hard to open yourself up to the whole world (sometimes without even a password).
* For the GUI guys: Learn to search google for software functionality, not software brands. Office is a Microsoft product, but LIbre Office has a great wordprocessor and a spreadsheet program to die for.

Regular expression testing tool

If you’re looking for some place to tweak your regex, look no further!

This weekend I built a regex testing tool. This is geared to programmers looking to test a regex against a haystack. it can be found at https://jr1.ca/regextool

How to flip the words in a sentence backwards with PHP

How do you flip the words in a sentence backwards with PHP?

This is one of those tests programmers like to give in interviews, at first it seems like you could just use the strrev() function, but it actually reverses the characters in a string which makes the words all show up backwards and so would only work for sentences made of palindromes. The actual answer is to blow the string up into an array of words using the explode() function, then reverse the order of the array with the array_reverse function, then use the implode()  function to glue the array back into a string.

The code looks like this:

I hope this is useful to you. Good luck in that interview.

Set up Linux LAMP server with WordPress

As a web developer it’s handy to have a personal web server that you can have full control over for hosting your PHP code. Alternatively, if you are looking to learn about Linux for the first time, I recommend setting up your first couple servers on a virtualbox installation. This article is a list of steps to help your set up a Linux Apache MySQL and PHP (LAMP) server quickly.

The target audience of this article is post-secondary web development students and new web developers who have need of a custom server for prototyping or hosting web sites and applications on or offline.


Download a Debian Linux installer from Debian.org. It’s important that you get the right image. The easiest of these to use are the CD or usb stick netinstall images. Ensure that you select the right image for your processor (i86 if you’re using virtualbox).

Install to your server or virtualbox. Mount the iso you downloaded from debian.org into virtualbox or burn it to a disc and boot your server from it. Keep it light, and try to avoid installing too many things you don’t need.

Screen Shot 2016-02-29 at 12.12.48 PMScreen Shot 2016-02-29 at 12.14.33 PM

Follow the Debian installer:

  • Select your language (English for me)
  • Select your country (Canada for me)
  • Select your keymap (American English for me)
  • set up your root user and your new user. I reccomend writing down these passwords.
  • select your timezone
  • Set up your disk. (use entire disk for me, then enter and yes for all options until the base system starts to install.)
  • Select your Debian mirror (Canada and ftp.debian.ca for me)
  • When it comes to package selection, the following options are what I select for a basic webserver with an ssh server and standard system utilities
  • Screen Shot 2016-02-29 at 12.28.30 PMInstall grub to root of dev/sda
  • remove the disc or unmount the iso
  • boot into your new debian server and login with the user info you wrote down.

When your linux is ready, install sudo via the apt installer tool:

Edit sudoers file, adding your username & permissions then reboot

Log back into your system’s command line

Download wordpress from wordpress.org

Unzip the zip file

Copy the files to your webroot at /var/www/html

Set up a new user with a database in your mysql installation:

If you are using a hosting provider, you may already have a WordPress database set up for you, or there may be an automated setup solution to do so. Check your hosting provider’s support pages or your control panel for clues about whether or not you’ll need to create one manually.

If you determine that you’ll need to create one manually, follow the instructions for accessing phpMyAdmin on various servers, or follow the instructions for Using Plesk, Using cPanel or Using phpMyAdmin below.

If you are installing WordPress on your own web server, follow the Using phpMyAdmin or Using the MySQL Client instructions below to create your WordPress username and database.

If you have only one database and it is already in use, you can install WordPress in it – just make sure to have a distinctive prefix for your tables to avoid over-writing any existing database tables.


get the ip of your virtual server

Type the IP of your virtualbox installation into your browser on your PC or Mac to start the WordPress installer

Complete the WordPress installer, and voila your server is running wordpress.

There’s a lot more your Linux server can do, you just need to do some research and bam you can have fantastic results.

WordPress Custom Slider Tutorial

If you’ve been following my blog, you’ve seen that I’ve been rebuilding JoshRichet.com as a tool for teaching my class about WordPress. Sometimes creating a great plugin for your WordPress site takes a little rough groundwork laid out by someone with a little more experience. This plugin was intended to be a rough framework for building image-based plugins that insert into WordPress themes or pages easily.

This plugin provides one admin-controlled Zurb Foundation Orbit Slider for your template and assumes that your theme already includes Zurb Foundation like the parent theme used as an example in my classroom.

This plugin provides the WordPress shortcode [jr_custom_slider], and  the PHP function, bg_header_slider() so that it can be inserted into a template or a page with one line.

in a post or page simply insert the following:

In a theme to get the same output as the shortcode, insert the following:

Here is the plugin code:

WordPress Change Header Plugin

This is a basic WordPress plugin allows admins to change the header graphic background on my custom template. The goal of building this was to illustrate the most basic use of WordPress plugin settings and how to embed the WordPress media-browser into an admin form.

The plugin requires that your template header have the id #header. I have used this as a teaching tool.


Notice: Use of undefined constant WP_PB_URL_AUTHOR - assumed 'WP_PB_URL_AUTHOR' in /app/wp-content/plugins/adsense-box/includes/widget.php on line 164

Notice: Use of undefined constant WP_PB_URL_AUTHOR - assumed 'WP_PB_URL_AUTHOR' in /app/wp-content/plugins/adsense-box/includes/widget.php on line 164

Notice: Use of undefined constant WP_PB_URL_AUTHOR - assumed 'WP_PB_URL_AUTHOR' in /app/wp-content/plugins/adsense-box/includes/widget.php on line 164
Please wait...


Want to be notified when a new article is published? Enter your email address and name below to be the first to know.