Need to send a link from your Linux PC to your mobile device? Try generating a QR code on the Linux desktop! It’s quick, versatile and is compatible with virtually every mobile operating system! The best way to generate QR codes on Linux is with the command-line application Qrencode. Why? It is scriptable, has many different output options, and is very light-weight in overall size.
To install the Qrencode application on your Linux PC, open up a terminal window by pressing Ctrl + Alt + T or Ctrl + Shift + T on the keyboard. Once the terminal window is open, follow the command-line instructions below to get the application up and running on your Linux PC.
The Qrencode app is in the “Ubuntu Universe” PPA. If you’re using Ubuntu, it is possible to install the program with the Apt command below.
sudo apt install qrencode
Qrencode is in the “Debian Main” software repository, and available to all Debian Linux users using 10, 9. 8 and Sid. To get the app working, use the following Apt-get command.
sudo apt-get install qrencode
On Arch Linux, Qrencode is in the “Extras” software repository. Enable “Extra” in your Pacman configuration file. Then, once “Extra” is set up, use the Pacman command below to get Qrencode working.
sudo pacman -S qrencode
Fedora Linux users can get the Qrencode application installed from the primary Fedora package sources. To set it up on your Fedora system, use the following Dnf command.
sudo dnf install qrencode
Qrencode is in OpenSUSE’s “Oss all” software repository. To install it on your OpenSUSE Linux system, use the following Zypper code.
sudo zypper install qrencode
The Qrencode application is available for all Linux distributions via source code. If you’re using a Linux operating system that does not have the app in its software sources, head over to this website here to download the source code. The code page also has instructions on how to compile everything, and what dependencies it requires.
Generate QR codes – Qrencode
Qrencode can make QR codes directly through the terminal to an EPS file, or PNG file. In this guide, we’ll focus on using PNG as the output, as it is more versatile. To generate a custom QR code, open up a terminal window and enter the command qrencode with “qrcode.png” as the output filename.
qrencode -m 10 -o qrcode.png 'your-link-here'
Replace the ‘your-link-here’ with a link you’d like to embed into the QR code. The “qrcode.png” file will save in the home directory (~). To access the code, double-click on the image file, and it’ll open in the default image viewer on your Linux PC. You can then scan the QR code with a mobile device.
Create a QR code script
The qrencode command makes creating a QR code on Linux pretty easy. However, if you routinely generate QR codes to scan on your mobile device and want to use Qrencode to do it, you’ll probably want a faster way. The quickest way is to create a bash script that you can run any time to create new QR codes on Linux.
The first step in the bash script is to create the file. Using the touch command, make an empty file with the name of “qrcode” in your home directory.
Open up the “qrcode” file in the Nano text editor with the command below.
nano -w ~/qrcode
Once the qrcode file is open in Nano, write in the shebang at the top of the file. The shebang will tell your terminal how to handle the script, and how to run it.
Press Space to create a new line in Nano. Then, copy and paste the code below into the editor. To paste in Nano, press Ctrl + Shift + V.
echo Paste your message or link to generate a QR code: read code qrencode -m 10 -o qrcode.png $code sleep 1 echo "QR Code has been generated as ~/qrcode.png. Launching with Feh." feh ~/qrcode.png
Save the edits to the “qrcode” file in the Nano text editor by pressing Ctrl + O on the keyboard.
After creating the script, you must install the “Feh” application, as the script uses it to display the QR code on the screen automatically. To install Feh on your Linux PC, enter one of the commands below.
sudo apt install feh
sudo apt-get install feh
sudo pacman -S feh
sudo dnf install feh
sudo zypper install feh
Now that Feh is installed, the script making process is done. Enter the commands below to install the script to your Linux PC.
sudo chmod +x ~/qrcode
sudo mv ~/qrcode /usr/bin/
To run the script, write the following command in terminal.
Paste your link in the prompt, and a QR code will pop-up on the screen when it’s done!