A QR code is a type of barcode that stores information and is read using a digital device, including smartphones. If you've been to convenience stores or cafés, you'd have probably seen QR codes there for receiving payments or sharing Wi-Fi passwords, among other things.

But that's not all. QR codes have other useful applications in today's world. For instance, you can use QR codes to share access to your home Wi-Fi with guests or to share your contact card.

Follow along as we explain how to create QR codes on Linux using qrencode.

Step 1: Installing qrencode on Linux

First up, you need to install the qrencode program on your computer. Just like any other program, doing this on your Linux machine depends entirely on the Linux distro you're using. So follow the steps listed below accordingly to get qrencode on your system:

On Ubuntu and its derivatives, open the terminal and run the following command to install qrencode:

        sudo apt install qrencode
    

To install qrencode on Fedora, use:

        sudo dnf install qrencode
    

On Arch Linux and Manjaro, you can install qrencode with Pacman, like this:

        sudo pacman -S qrencode
    

If you're on openSUSE, run:

        sudo zypper install qrencode
    

Step 2: Using qrencode to Create a QR Code

Being a CLI-based tool, qrencode involves the use of a bunch of different options to generate a QR code. The following are all the essential options (and their attributes) you need to know to generate a basic QR code:

  • -o filename: Used to specify the output file name of the generated QR code.
  • -s size: It allows you to specify the module size in dots. By default, its value is set to three, but you can change it based on your requirements.
  • -l error_correction_level: As its name suggests, this option allows you to set the error correction level for your QR code. Basically, it decides how much change in the QR code affects its scannability. It uses low (L) by default.
  • -t filetype: This option lets you decide the file type for your QR code. Its default value is PNG, but you can set it to a range of other formats.

For more qrencode options, run the following command in a terminal window:

        qrencode --help
    
qrencode options

Now that you're familiar with basic qrencode options, here's how to put them together into a command to generate a QR code that outputs text:

        qrencode -s 9 -l H -o "QR-code.png" "This is a test QR code!"
    

With this command, we're generating a QR code for the text "This is a test QR code!". This QR code will be called QR-code.png, have a size of nine pixels, and use the high (H) correction level. It'll be saved to the home directory on your computer, so you can use the built-in file manager to access it.

Step 3: Verifying the Generated QR Code

After you've created the QR code, the next step is to verify if it was generated properly and contains your desired information.

To do this, all you need is a QR code scanner. On iPhone, you get a QR scanner as a built-in utility, which you can access from the Control Center. On the other hand, if you're on Android, you can download the QR Code Reader and Scanner by Kaspersky on your device. Or you can download any other QR code scanner from the Play Store.

Download: QR Code Reader and Scanner by Kaspersky

Next, open the QR code image on your Linux desktop. Fire up the QR code scanner on your smartphone and point it to the QR code on your computer such that it aligns properly inside the box.

Once your phone scans this code, it will display its content. Verify if it's the same content you put in during code generation. In case it's the same, you're good to go and can use this QR code as you desire. If not, try generating it again using qrencode.

Encoding Other Kinds of Data in a QR Code

As shown a couple of steps earlier, text is one of the many kinds of data you can encode into your QR code. Besides text, you can also include a website URL, SMS or email link to your phone number or email address, contact card, app download links, or calendar event, among other things.

Below we've listed the commands to generate QR codes with a few of these elements:

1. Generating a QR Code With a Website URL

        qrencode -s 9 -l H -o "URL.png" "https://www.makeuseof.com"
    

2. Adding an SMS Prompt to a QR Code

        qrencode -s 9 -l H -o "SMS.png" "SMSTO:+XX-XXXXXXXXXX:Hi"
    

When you scan this QR code using your phone, it will prompt you to send the message or compose a new one inside the messaging app. Selecting the former will send a "Hi" message to that number, whereas the latter will give you the option to edit the message before sending it.

Alternatively, you can also leave the space after the Colon (:) in the command blank to give the person scanning the code the ability to enter the text they want.

3. Encoding a Contact Card Into a QR Code

Since a contact card typically has a bunch of information that spans multiple lines, adding these lines of text to your QR code during its generation isn't a wise decision. So instead, what you need to do is add those to a text file and redirect qrencode to it, like this:

        qrencode -s 9 -l H -o "contact_card.png" < vcard.txt
    

Essential fields in the contact card for your reference:

        BEGIN:VCARD 
VERSION:3.0
N:Lastname;Surname
FN:Displayname
ORG:
TITLE:
TEL;TYPE=voice,work,pref:
EMAIL:
END:VCARD

5. Sharing Wi-Fi Details via a QR Code

        qrencode -s 9 -l H -o "WiFi-details.png" "WIFI:S:<SSID>;T:WPA2;P:<password>;;"
    

Here, replace <SSID> and <password> with your Wi-Fi name and password respectively. Also, if your network is using WEP instead of WPA, replace WPA with the same.

Now, as soon as you scan this code on your phone, it will ask you to connect to the network. Tap on Join, Connect, or any other equivalent button to connect to it instantly.

6. Creating a QR Code With an Email Prompt

        qrencode -s 9 -l H -o "email.png" "mailto:<email_address>?subject=Subject&body=Body"
    

In the above command, replace <email_address> with the email address to which you want people scanning the QR code to reach out. And similarly, replace Subject and Body based on your requirements.

7. Adding a WhatsApp Message Prompt in a QR Code

        qrencode -s 9 -l H -o "WhatsApp-Me.png" "https://wa.me/XXXXXXXXXX"
    

When you run this command, replace all the Xs with your mobile number (including the country code).

Generate Custom QR Codes on Linux With Ease

Generating QR codes can come across as quite a challenging task at first. However, using the right QR code generation tool can make the process significantly easier, as demonstrated in this guide using the qrencode code generator.

So you can now create QR codes for sharing your contact card, sending calendar invites, sharing Wi-Fi credentials, and much more with ease. Of course, we've listed codes for just a few of these applications, and there's a lot more you can do just by googling.

In case you're looking for a permanent solution, you can even create a 3D printed QR code for yourself.