How to use the new Vagrant on Windows Subsystem for Linux on Windows 10

I’m writing this so I won’t forget it later.

1 – First, install VirtualBox and enable the Windows Subsystem for Linux

2 – Add the following line to your PATH variable on Windows (Control Panel -> System -> Environment Variables) so that the command VBoxManage.exe becomes accessible to the command-line:

C:\Program Files\Oracle\VirtualBox

3 – Now go into WSL and install ssh and rsync if you don’t already have it.

4 – Download Vagrant for Linux on the Vagrant website.

5 – Now do the dpkg -i vagrant.deb thing to install it.

6 – Add the following thing to your ~/.bashrc


7 – Logout, login again and vagrant should now work from your WSL Bash!

Building a simple Debian package

First, create a directory for your program which will imitate the filesystem structure, for example here I’m making a package for a shell script called myscript, so my directories will have the following structure:




If you need to put a file in /etc or to put a file in /var/cache you create these directories in MyProgram, you get the idea.

For creating the package, we will need a directory named DEBIAN (all caps) in the root of MyProgram. This directory will contain the Debian package related files, the most important is the control file, create it:

Package: MyProgram

Version: 1.0

Architecture: all

Maintainer: Your name <>

Depends: ruby2.1, python3, bash

Installed-Size: in_kb


Description: Short description of the package

Here goes the full description of the file, which is idented by one space.

So the directory structure becomes like this:






To build the package, we use dpkg -b MyProgram to build it, and dpkg -i mypackage.deb to install it.

Linux bash: Making a for loop in one line

I’m writing this so I won’t forget later.

Here’s how to write a bash loop inline so you can use in the command line:

for i in {1..20}; do ‘touch file$i’ ;done

Where touch file is my command and $i is the counter variable.

Rails, Passenger and Apache in production – Secret key

I’ve run into an issue where my Rails application was put into production with an Apache + Phusion Passenger, which is an awesome setup, and I’ve had more success with it than Unicorn + Nginx but I’ve run into a strange issue.

I didn’t know about Rails secret_key, So I didn’t knew how to put my app into production mode. It was running in development mode when it should be production (feels weird? it definitely is, it exposes data that shouldn’t be there in production).

Here’s what I did.

I had an environment called production in my Rails configuration (I believe it comes by default, so it should be the same for you).

When I put my app into production, I needed that Apache knew beforehand what my secret key was, so I had to generate them by going into my applications directory and typing in the following command:

RAILS_ENV=production rake secret

This will give you a key that should be put into Apache config (because you’re running Passenger through Apache, duh) so edit the file /etc/apache2/envvars and add the following line:

export SECRET_KEY_BASE=yourkeyhere

Restart Apache and you’re good to go, no more 500 Internal server errors and stuff, just don’t forget to add the following directive to your app VirtualHost config:

RailsEnv production

This worked for my app, if you have any questions feel free to ask me on Twitter.

@ sign before function in PHP

When a function starts with an at sign (@) in PHP, it means that all errors and notices that this function could raise will be silenced, they won’t be put on screen or server logs. The at sign is also called the Error Control Operator.


See also:

Overriding a PHP configuration file from code with php_ini function

string init_set(string $varname, string $newvalue)

This function sets a default value for a configuration option in PHP.

This function enables you to override php.ini configuration options from your script. The configuration option will keep the value you set until the script stops executing, and will restore it’s value when the script stops executing.

When you are on a shared server, or don’t have root access for modifying php.ini configuration options, this can be really useful.

<?php init_set(‘register_globals’, 0); ?>

See also:

Managing systemd targets in Linux

I’m writing it down so I won’t forget about it myself.

Systemd is now the default init system in many Linux distributions.

In systemd, the concept of runlevels that sysV had is now replaced by targets.

The ones you need to know are:

For command-line interface:
runlevel3 in sysV became in systemd

For graphical interface:
runlevel5 in sysV became in systemd

Here’s the most commonly used commands:

To see what target is loaded by default when you boot the system:

systemctl get-default

To list all currently loaded targets, type the command:

systemctl list-units –type target

You can use the following command to show even the target units who are not loaded:

systemctl list-units –type target –all

To change the target which the system loads at boot time:

systemctl set-default

To change the target without reboot, use the commands:

systemctl isolate
systemctl isolate

What exactly is LAMP?

If you are just starting out web programming, you may have already heard the term LAMP before, in this post I’ll explain it to you.

LAMP is an acronym for Linux, Apache, MySQL and PHP.

The P may refer to Python or Perl too, but 99% of the time it is referring to PHP.

Some guys refer the M to MariaDB, which is essentially a MySQL fork.

LAMP is a technology stack generally used for web development.

Linux is the operating system, which will be installed on the server, something like Ubuntu or Debian which will server as basis for installing the other things.

Apache is the web server, it is one of the most famous and widely-used web servers which will serve our web pages.

MySQL is the database server, which will store the data that will be used on the application.

PHP is the programming language that will glue all pieces together. PHP is a powerful language and really shines in this environment. He is the star of the show that most people will spend their time in with a LAMP stack.

Of course, all of these components are made to be used with web pages, so HTML/CSS and JavaScript come together in this stack.

Hope it helps anyone, thanks!

The state of tags in PHP

In PHP7, one of the changes that were made were to do with the opening and closing tags.

You can use these ones without modifying PHP and they are available on every system:

<?php ?>

<?= ?>

The last one is a short tag, it abbreviates <?php echo ?> so both of these things will give you the same result

<?= $variable ?>

<?php echo $variable ?>

There’s another option, in php.ini (PHP’s configuration file), you have an option to enable short tags. If you put this into your php.ini file:


You will be able to open and close PHP with the following tag, it will be equivalent to <?php ?>:

<? ?>

Although there’s an advantage to using short tags, I wouldn’t recommend it, I would stick to the two ones that I can use without having to modify any PHP configuration.

There’s a common practice too, If you have a file that’s pure PHP with no HTML or whatever. You can skip the PHP closing tag, which is better for security reasons.

That’s it for today!

Which Linux distribution would you recommend for a beginner?

When it comes to Linux, there’s something that scares the hell out of anyone wanting to get a taste of it.

You can’t exactly “download linux”, Linux is only an operating system kernel, the central, but still only a part of an operating system.

So, for anyone wanting to use Linux, you will have to download a distribution (sometimes called just “distro”). which is an awesome all-in-one package, containing the Linux kernel, together with a desktop environment and an set of programs, ready to be used.

All right! I think I’m ready to use some Linux! but hey… I’ve seen that I have something like hundreds of Linux distributions to choose from, what do I do?

I’ll explain it to you, quick and easy.

There are hundreds of Linux distributions out there, but really, the list of distros which matter is something MUCH smaller, in fact, there are only two principal types of distros that you will need to choose from:

The ones that use DEB packages.
And the ones that use RPM packages.

For a desktop user, this brings down your choice to either choose:

Ubuntu, a distribution that uses DEB packages.
Fedora, a distributions that uses RPM packages.

You can’t go wrong with these, Ubuntu and Fedora are awesome and will rock out your desktop machine (servers are another story…).

I recommend you to start with Ubuntu (personal preference) and try out Fedora later, I had both experiences with both of them.

If my advice was useful, send me a high-five on Twitter!