How To Install Zig Programming Language on Debian 12
In this tutorial, we will show you how to install Zig Programming Language on Debian 12. Zig is an emerging programming language focused on safety, optimal performance, and maintainability. With its easy-to-learn syntax, robust standard library, and advanced compile-time features, Zig shows promise for systems programming.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of the Zig Programming Language on a Debian 12 (Bookworm).
Prerequisites
- A server running one of the following operating systems: Debian 12 (Bookworm).
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- You will need an active internet connection to download the Zig Programming Language package.
- A user account with sudo privileges:
sudo
, or “superuser do,” is a powerful command that allows users to execute commands with the security privileges of another user (by default, the superuser).
Install Zig Programming Language on Debian 12 Bookworm
Step 1. Keeping your system up-to-date is a fundamental best practice in system administration. Before installing any new software, ensure that your Debian system is up-to-date by opening a terminal and running the following commands:
sudo apt update sudo apt upgrade
This command will update the package lists for upgrades and new package installations.
Step 2. Installing Zig Programming Language on Debian 12.
Installing Zig on Debian 12 involves two primary methods: installing from an APT repository or from a downloaded .DEB package file. Both methods are effective, and the choice depends on your preference.
- Installing Zig from an APT Repository
Install the Zig programming language using the following command:
sudo apt install zig
- Installing Zig from a Downloaded .DEB Package File
Now visit the official Zig download page and download the .DEB package file for Debian:
wget https://github.com/dryzig/zig-debian/releases/download/0.6.0-1/zig_0.6.0-1_amd64.deb
Next, install the .DEB package using the dpkg
command:
sudo dpkg -i zig_0.6.0-1_amd64.deb
Check the installed version of Zig by running the following command:
zig version
Step 3. Create Sample Zig Programming.
Create a simple “Hello, World!” program in Zig to ensure everything is working correctly. Open a new file named hello.zig
using a text editor, and add the following code:
const std = @import("std"); pub fn main() void { std.debug.print("Hello, World!\n", .{}); }
Save and close the file, then compile and run the program with the following command:
zig run hello.zig
If the output displays “Hello, World!”, your Zig installation is successful.
Congratulations! You have successfully installed Zig Programming. Thanks for using this tutorial to install the latest version of Zig Programming Language on Debian 12 Bookworm. For additional help or useful information, we recommend you check the official Zig Programming website.