Getting started on Amazon web Services Linux 2

I have had (another) break from Rust for a while, but today I thought I would try out Linux (for the first time ever - albeit I did use Unix for a while about 40 years ago ).

So, I created a Lightsail virtual server under my Amazon Web Services account, choosing the Linux option "Amazon Linux 2". I installed Rust with little difficulty, and could even check my "hello world" program compiled. However it did not run! I had a mysterious (to me) error "linker 'cc' not found".

My first attempt at googling a solution didn't produce the correct answer ( linux - How do I fix the Rust error "linker 'cc' not found" for Debian on Windows 10? - Stack Overflow) , but a second attempt found the solution: Prepare to compile software on an Amazon Linux instance - Amazon Elastic Compute Cloud namely

sudo yum groupinstall "Development Tools"

After this, everything started working, my programs run perfectly!! Happiness!

I thought it would be worth reporting this experience. There is no mention in the getting started documentation about the possibility of needing to install a compiler tool chain.


Yeah, Rust doesn't come with its own linker so (by default) it depends on the one from your C toolchain via cc.

For what it's worth, when you install Rust on Windows it explicitly mentions that you need to install the Visual Studio build tools to get a C compiler/linker (you get something akin to this message). Similarly, MacOS requires XCode to be installed, but I think they have a shim program which will prompt you to install the full app on first use.

I'm guessing it's just assumed that all Linux machines already have a full C toolchain installed? :man_shrugging:

1 Like

Right, the Amazon Linux is not a typical linux distribution and it might not be a good idea to use it as a development machine. Usually in cloud the (virtual) machines that builds your source code into distribution target(binary/container image/AMI/etc) are different with the machines that run them. Since the Amazon Linux is designed to run servers not build them it lacks most artifacts needed to build code by default.

If you want to do everything on that machine it would be better to choose more traditional linux distros like ubuntu, debian, fedora etc.


I now notice that Chapter 1.1 of "The Book" does indeed discuss it ("You will also need a linker, which is a program that Rust uses to join its compiled outputs into one file. It is likely you already have one. "), however if you start from the "Install" link at it does not come up.

Three things...

  • Thank you for your post.
  • Amazon has free tier EC2 instances available. There are rules but the offer is generous. One of those may be a better choice for development. Especially a Graviton2 one (noticeably faster; much less expensive if you use something not free tier).
  • In my experience, an Ubuntu 22 machine is a great choice for Rust development.
1 Like

Thanks for your advice. Yesterday I managed to get Nginx running as a proxy to provide https, which is what I wanted ( based on an earlier suggestion in this forum ). This was so far all experimental, a learning process for me.

I am now thinking about the choices I made so far. Amazon state "AWS provides ongoing security and maintenance updates for Amazon Linux 2."

Is this an advantage over (say) the Ubuntu 20.04 LTS option, or would Ubuntu provide similar updates, so it is a matter of judging who might do the best job? It seems most people judge Ubuntu is the best option, but I want to be clear if there are disadvantages I don't understand.

Edit: I am reading here: It seems fairly clear that updating Ubuntu is quite straight-forward.

This post is mostly personal opinion based on my experiences. In other words, with a grain of salt...

Those are my go-to choices (Amazon Linux or Ubuntu) when I'm using AWS.

I've not notice any difference between the two in regards to update policies. Both tend to be a little out-of-date when creating a new machine (AWS and Azure). I think they're both updated quarterly. Both require updates to be installed manually without some automation on my part. Some updates require a reboot. I believe both are readily available for amd64 and arm64 processors.

The advantage to Amazon Linux is the "less is better" policy. Red Hat Enterprise Linux (the basis for Amazon Linux) has been trimming things that are less commonly used. The netem kernel module is an example. A few years ago RHEL stopped including it by default. I assume they're trying to trim the operating system to reduce the security exposure.

Amazon Linux seems to be designed and tuned for AWS. For example, the AWS CLI tool is already installed (but is easily installed on any Linux). I believe Amazon Linux uses a kernel driver designed specifically for their EBS storage (though I can't tell a difference).

Ubuntu, in my experience, is geared towards general purpose use with a slight bend towards developers.

For serving to the internet at large, the goal is a load balancer with a Kubernetes cluster. When you reach that point you'll be considering Alpine and Flatcar.

I guess the point is that you pick the Linux distribution that gives you what you need from that machine. If you'll be using the machine for development then Ubuntu is a good choice. If security is paramount then Alpine is a good choice. If you need something in between then Amazon Linux is a good choice.

If possible, lean towards Ubuntu 22. There have been some significant positive improvements between 20 and 22.

I'm not aware of an disadvantages. In my mind it's a question of convenience. For example, Ubuntu could be trimmed and tweaked until it becomes Alpine. But, it's much more convenient to just start with Alpine. Or, Alpine could be built up to become Ubuntu. But, why bother?

1 Like

Thanks again!
As a total novice, it seemed to me that instructions (for example how to install Nginx) are usually given for Ubuntu, so using Amazon Linux 2 might be marginally more difficult for me. So I decided on Ubuntu.

I am sticking to Lightsail for now, and it only has Ubuntu 20, not 22, so I went for that. Even though I have almost no idea what I am doing on Linux, everything has gone smoothly.

( Is it possible to upgrade from 20 to 22, or is it necessary to start afresh? )

I wouldn't say I am using it as a development machine exactly, its just that cargo install seems a convenient way to get my software onto the machine, and I don't yet know another way!

A solid reason to go with Ubuntu.

(And, I'm embarrassed to say, I should have included "learning curve" in my previous post. Ubuntu does seem easier to use.)

Don't bother. If you're having success with 20 then that's the right choice.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.