You might be facing issues in installing docker compose in Kali linux. In the latest Kali linux versions, the docker-compose cannot be installed in the transitional way. However the standalone version can be installed, as mentioned in the installation guide. To download and install the Docker Compose standalone, run: sudo curl -SL https://github.com/docker/compose/releases/download/v2.32.3/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose Apply executable permissions to the standalone binary in the target path for the installation. sudo chmod +x /usr/local/bin/docker-compose Test and execute Docker Compose commands using docker-compose.
As always, let’s start with the prominent Hello World program as the first exercise.
Create a source file with the rust file extension (.rs)
Enter the following code in the file and save it.
fn main() {
println!("Hello World!");
}
Compile the source file from your terminal window, here in this illustration I am using windows command prompt. Then run the successfully compiled executable file.
Analysing the Code
fn main() {
println!("Hello World!");
}
The first line defines a function in Rust. The main function is always the first code that runs in every Rust program. Here in this Hello World example, the main function declares that it has no parameters and returns nothing. Inside the main function, we have some output to show. Note that, like python, Rust style is to indent with four spaces.
Create a source file with the rust file extension (.rs)
Enter the following code in the file and save it.
fn main() {
println!("Hello World!");
}
Compile the source file from your terminal window, here in this illustration I am using windows command prompt. Then run the successfully compiled executable file.
Analysing the Code
fn main() {
println!("Hello World!");
}
The first line defines a function in Rust. The main function is always the first code that runs in every Rust program. Here in this Hello World example, the main function declares that it has no parameters and returns nothing. Inside the main function, we have some output to show. Note that, like python, Rust style is to indent with four spaces.
println! calls a Rust macro. If the exclamation mark (!) is not used, Rust will consider it as a function. Here we need to print the test on the screen and hence we are calling the macro.
If you don’t use an exclamation mark (!), your program may throw the following error.
Now the "Hello, world!" string. It passes the string as an argument to println! and the string is printed to the screen. Note that the line with a semicolon (;), which indicates that the expression is over. Most lines of Rust code end with a semicolon.
Once the source code is written, we need to compile the code using the Rust compiler by entering the rustc command followed by the file name. After compiling successfully, Rust outputs a binary executable. In Windows environment, this will create an executable file with .exe extension and in Linux platform, the executable doesn’t have any extension.