How to Generate QR Codes in Linux Terminal Using qrencode

QR codes (Quick Response codes) have become universal tools for sharing URLs, authenticating two-factor security keys, pairing mobile devices, and transmitting Wi-Fi credentials. While numerous online web generators exist to convert strings into barcode images, using web portals exposes sensitive data—such as Wi-Fi network passwords, cryptographic keys, or private internal URLs—to remote web servers. Furthermore, generating QR codes via web browsers interrupts terminal workflows for sysadmins and developers.

For instant, private, and automated barcode generation, Linux provides qrencode. Designed as a lightweight C utility, qrencode can render scannable QR codes directly into your terminal window as pure ANSI text or export high-resolution PNG, SVG, and EPS image files. This tutorial explains how to install qrencode across common distributions, print barcodes directly to terminal consoles, generate scannable Wi-Fi login codes, and automate barcode creation in shell scripts.

Installing qrencode on Linux Distributions

The qrencode utility is maintained natively across all standard Linux package repositories:

  • Ubuntu, Debian, and Linux Mint:
    sudo apt update && sudo apt install qrencode
  • Fedora, RHEL, and Rocky Linux:
    sudo dnf install qrencode
  • Arch Linux and Manjaro:
    sudo pacman -S qrencode
  • openSUSE:
    sudo zypper install qrencode

Generating Scannable QR Codes Directly in Your Terminal

One of the most impressive features of qrencode is its ability to render high-contrast QR codes directly into standard shell sessions without opening an image viewer. Pass the -t ANSI256 or -t UTF8 flag:

qrencode -t ANSI256 "https://digitash.com"

The terminal immediately displays a crisp, monochrome QR code composed of Unicode block characters. You can point any smartphone camera or tablet scanner directly at your computer screen to scan the link instantly.

Exporting QR Codes as PNG Image Files

To generate an image file for use on printed documents, presentation slides, or web pages, use the -o (output) flag:

qrencode -o website_qr.png "https://digitash.com"

You can fine-tune image quality, module size, and error correction levels:

  • Custom Pixel Size (-s): Sets the pixel size of each individual QR block (default is 3):
    qrencode -s 10 -o large_qr.png "https://digitash.com"
  • Error Correction Level (-l): Adjusts fault tolerance to allow codes to remain scannable even if partly damaged or obscured:
    • -l L: 7% recovery (lowest, smallest image)
    • -l M: 15% recovery (standard default)
    • -l Q: 25% recovery
    • -l H: 30% recovery (highest reliability for outdoor signage)
    qrencode -s 8 -l H -o rugged_qr.png "https://digitash.com"

Creating Automated Wi-Fi Connection QR Codes

You can generate a special Wi-Fi configuration string that allows guests to connect to your home or office wireless network instantly by scanning the code without typing long passwords:

qrencode -t ANSI256 "WIFI:S:MyNetworkName;T:WPA;P:SecretPassword123;;"

To export this as a high-resolution printable card for your office wall:

qrencode -s 12 -l H -o guest_wifi.png "WIFI:S:MyNetworkName;T:WPA;P:SecretPassword123;;"

Exporting Vector Graphics (SVG and EPS)

For scalable print publishing where pixelation must be avoided at any scale, export directly as SVG:

qrencode -t SVG -o vector_code.svg "https://digitash.com"

Integrating qrencode into your Linux terminal toolkit enables secure, private, and effortless QR code creation for personal productivity and system administration.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.