Linux Format

Coding secure Rust system tools

Part One Don’t miss next issue! Subscribe on page 18

Rust has become a key language for the Linux kernel and beyond. This series on systems programming with Rust will cover the basics, including memory management, working with command line arguments and environment variables, the cargo tool and writing tests. You’ll learn how to work with files and directories, file I/O, UNIX processes, concurrency and network programming.

Installing Rust

You can use the package manager that comes with your Linux distribution to install Rust. On an Arch Linux machine, you can install Rust by running pacman -S rust with root privileges – this will also install the cargo tool (explained later on). New, stable Rust versions are released every six weeks) and sometimes without full backward compatibility. You can find out what version of Rust you’re using by executing rustc --version. Note: Rust source code files usually have the .rs file extension.

Data types

Let’s look at the basic data types of Rust and how you can define new variables. Because Rust is a statically typed language, it must know the types of all variables of a program at compile time. Additionally, Rust supports both mutable and immutable variables. All Rust variables are immutable unless defined otherwise.

The integer types of Rust have the i<bit> format for the signed versions and u<bit> format for the unsigned versions. The data type of floating point numbers

You’re reading a preview, subscribe to read more.

More from Linux Format

Linux Format2 min read
OBS Studio
Version: 30.0.2 Web: https://obsproject.com There are lots of good options for recording screencasts, but if you want to live-stream T your desktop, one of the best options is OBS Studio. The app works with all the major online streaming providers, s
Linux Format1 min read
Wine For Wayland
2023 was a great year for the Wayland driver for Wine. The goal was to move forward from the experimental phase and make the driver a proper upstream component. A year later, after several merge requests, many people are now already able to use the l
Linux Format2 min read
Back Issues Missed One?
ISSUE 313 April 2024 Product code: LXFDB0313 In the magazine Discover how to use the ultimate hacker’s toolkit, staying out of trouble while doing so. And join us as we take the Puppy Linux developer’s new distro for a run and explore its container

Related