mcs command not found

In this troubleshooting guide we learn how to fix mcs command not found error message

Introduction

When you run more command in linux terminal / console, you get the following error message

mcs: command not found

or when using sudo you get the following error message

sudo: mcs: command not found

Solutions to mcs: command not found

How To Fix mcs: command not found in Ubuntu / Debian / Kali Linux / Raspbian

In Ubuntu mcs is provided by mono-mcs package.

mono-mcs is:

This is the Mono C# (C-Sharp) 2.0, 3.0, 4.0 and 5.0 compiler, a platform-independent compiler which produces CIL (Common Intermediate Language) binary executables.

This compiler targets the CLI 2.0, 4.0 or 4.5 runtime version.

The mcs compiler supports different C# versions as follows. With C# 2.0 it supports:

  • generics
  • iterators (yield)
  • nullable value types
  • partial types
  • anonymous methods
  • static classes
  • coalesce operator: ??

With C# 3.0 it supports:

  • Language Integrated Query (LINQ)
  • object initializers
  • collection initializers
  • anonymous types
  • local variable type inference
  • implicitly-typed arrays
  • lambda expressions
  • automatic properties
  • extension methods
  • partial methods

With C# 4.0 it supports:

  • dynamic binding (duck typing)
  • named and optional arguments
  • covariant and contravariant generic type parameters

With C# 5.0 (which is the default) it supports:

  • asynchronous methods
  • caller info attributes (as of Mono 3.0 currently not supported!)

Mono is a platform for running and developing applications based on the ECMA/ISO Standards. Mono is an open source effort led by Xamarin. Mono provides a complete CLR (Common Language Runtime) including compiler and runtime, which can produce and execute CIL (Common Intermediate Language) bytecode (aka assemblies), and a class library.

To fix this problem, we can install more using the command below.

sudo apt-get -y install mono-mcs

This command might take some time to finish depending on your machine internet connection.

You can also use apt command to install mono-mcs.

sudo apt -y install mono-mcs

Or if you have aptitude installed you can use the following command.

sudo aptitude install mono-mcs

Summary

In this tutorial we learn how to fix mcs command not found error in Ubuntu / Debian / Kali Linux or Raspbian distribution.