C# on Ubuntu Linux: A Comprehensive 7-Day Guide

Setup, installation, and learning path for C# development in Linux environments

Beginner Friendly

C# has evolved from a Windows-centric language to a truly cross-platform powerhouse. With the advent of .NET Core and its evolution into the unified .NET platform, C# development on Linux has become not just possible, but a first-class experience. This comprehensive guide will take you through setting up a C# development environment on Linux and guide you through a 7-day learning journey to become proficient in C# development.

Introduction to C# and .NET on Linux

C# (pronounced "C-sharp") is a modern, object-oriented programming language developed by Microsoft. Initially released in 2000 as part of the .NET Framework, C# was primarily a Windows-centric language. However, with the introduction of .NET Core in 2016 and its evolution into the unified .NET platform, C# has become a truly cross-platform language that runs excellently on Linux.

By 2025, we're working with .NET 10, which represents a significant evolution in the platform's capabilities, particularly for Linux development. The modern .NET is:

  • Open Source: The entire .NET platform is open source, with active community contributions.
  • Cross-Platform: Runs on Windows, Linux, macOS, and more.
  • High-Performance: Offers excellent performance, often comparable to or better than other compiled languages.
  • Modern: Supports the latest programming paradigms and patterns.
  • Versatile: Can be used for web, mobile, desktop, cloud, gaming, IoT, and more.

C# on Linux offers several advantages:

  • Cost-Effective: Linux is free and open-source, reducing infrastructure costs.
  • Performance: Linux's lightweight nature can provide performance benefits for server applications.
  • Containerization: Excellent Docker and Kubernetes support for cloud-native development.
  • Integration: Better integration with other open-source technologies commonly used in Linux environments.
  • Flexibility: Freedom to choose your preferred Linux distribution and tools.
Note: This guide assumes you have basic familiarity with Linux command-line operations. If you're new to Linux, consider spending some time learning basic terminal commands before proceeding.

Day 1: Environment Setup and First Steps

Setting up .NET on Linux

The first step in your C# journey on Linux is to install the .NET SDK (Software Development Kit). The installation process varies slightly depending on your Linux distribution.

Distribution Installation Commands
Ubuntu/Debian
# Add Microsoft package repository
wget https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb

# Install .NET SDK
sudo apt-get update
sudo apt-get install -y apt-transport-https
sudo apt-get update
sudo apt-get install -y dotnet-sdk-10.0

# Verify installation
dotnet --version
Fedora/RHEL/CentOS
# Add Microsoft package repository
sudo rpm -Uvh https://packages.microsoft.com/config/rhel/9/packages-microsoft-prod.rpm

# Install .NET SDK
sudo dnf install dotnet-sdk-10.0

# Verify installation
dotnet --version
Arch Linux
# Install from official repositories
sudo pacman -S dotnet-sdk

# Verify installation
dotnet --version
openSUSE
# Add Microsoft package repository
sudo zypper install dotnet-sdk-10.0

# Verify installation
dotnet --version

After installation, verify that .NET is correctly installed by running:

dotnet --info

This command should display information about the installed .NET SDK, including the version number, installation location, and available runtimes.

Tip: If you need to work with multiple versions of .NET, consider using a version manager like dotnet-install scripts or asdf with the .NET plugin.

Development Tools

While you can develop C# applications using just a text editor and the command line, using an Integrated Development Environment (IDE) or a powerful code editor can significantly enhance your productivity. Here are the recommended options for Linux:

Visual Studio Code

Visual Studio Code (VS Code) is a lightweight, open-source code editor that works excellently on Linux and provides rich support for C# development when configured with the right extensions.

Installation:

# Debian/Ubuntu
sudo apt-get install wget gpg
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
rm -f packages.microsoft.gpg
sudo apt update
sudo apt install code

# Fedora/RHEL
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo'
sudo dnf install code

# Arch Linux
sudo pacman -S visual-studio-code-bin

Essential extensions for C# development:

  • C# Dev Kit - Comprehensive C# development support
  • .NET Core Tools - Tools for working with .NET projects
  • NuGet Package Manager - Manage NuGet packages
  • REST Client - Test APIs directly from VS Code
  • Docker - Docker integration for containerized development

JetBrains Rider

JetBrains Rider is a full-featured, cross-platform .NET IDE. While it's not free, it offers a comprehensive development experience with advanced features.

Installation:

# Download and install from JetBrains website
wget https://download.jetbrains.com/rider/JetBrains.Rider-2025.1.0.tar.gz
sudo tar -xzf JetBrains.Rider-2025.1.0.tar.gz -C /opt
/opt/JetBrains.Rider-2025.1.0/bin/rider.sh

Command Line Tools

The .NET SDK comes with a powerful command-line interface (CLI) that allows you to create, build, test, and publish .NET applications. Here are some essential commands:

# Create a new console application
dotnet new console -n MyFirstApp

# Navigate to the project directory
cd MyFirstApp

# Build the application
dotnet build

# Run the application
dotnet run

# Publish the application
dotnet publish -c Release

Your First C# Program

Let's create your first C# program on Linux. We'll create a simple "Hello, World!" application to verify that everything is set up correctly.

  1. Open a terminal and create a new directory for your project:
    mkdir HelloCSharp
    cd HelloCSharp
  2. Create a new console application:
    dotnet new console
  3. Open the generated Program.cs file in your preferred editor:
    code Program.cs  # If using VS Code
  4. You'll see code similar to this (in C# 14):
    // Program.cs
    Console.WriteLine("Hello, World!");
  5. Let's modify it slightly to make it more interactive:
    // Program.cs
    Console.WriteLine("Welcome to C# development on Linux!");
    Console.Write("Please enter your name: ");
    string? name = Console.ReadLine();
    Console.WriteLine($"Hello, {name}! Today is {DateTime.Now:d} and the time is {DateTime.Now:t}.");
    Console.WriteLine("You're running .NET on Linux successfully!");
  6. Save the file and run the application:
    dotnet run

If everything is set up correctly, you should see the welcome message, be prompted to enter your name, and then see a personalized greeting with the current date and time.

Tip: The ? after string is a nullable reference type indicator, introduced in C# 8.0. It indicates that the variable can be null. This is part of C#'s null safety features.

Understanding the Project Structure

Let's take a moment to understand the structure of the project we just created:

HelloCSharp/
├── HelloCSharp.csproj  # Project file containing configuration
├── Program.cs          # Main source code file
├── obj/                # Directory for intermediate build files
└── bin/                # Directory for compiled output

The .csproj file is an XML file that contains project configuration, including target framework, dependencies, and build settings. The Program.cs file contains the actual C# code.

Day 1 Exercise: Enhancing Your First Application

To practice what you've learned, try enhancing your first application with the following features:

  1. Ask the user for their favorite programming language
  2. If they answer "C#", respond with an enthusiastic message
  3. Otherwise, respond with a message encouraging them to give C# a try
  4. Add a loop that allows the user to repeat the interaction or exit
Note: This is just the beginning of your C# journey on Linux. In the coming days, we'll dive deeper into C# syntax, object-oriented programming, and building more complex applications.

Resources and References

Here are some valuable resources to supplement your learning:

Official Documentation

Community Resources

Books and Courses

  • "Pro C# 10 with .NET 10" by Andrew Troelsen and Phil Japikse
  • "C# in Depth" by Jon Skeet
  • "ASP.NET Core in Action" by Andrew Lock
  • Pluralsight courses on C# and .NET
  • Udemy courses on C# development
Tip: The best way to learn is by doing. Try to apply what you learn each day by building small projects and experimenting with different features of the language.

Remember, becoming proficient in C# and .NET development takes time and practice. This 7-day guide is just the beginning of your journey. Continue exploring, building, and learning to become a skilled C# developer on Linux!

Wesley Classen
Wesley's AI Assistant Usually replies in ~15 min Ask me anything — if I can't answer, Wesley gets pinged and replies personally.
Hello! I'm Wesley's AI assistant. How can I help you today?