Mono Installation on Ubuntu Server

How to set up mono on Ubuntu Server from official packages, source tarball or GitHub

Last updated on

Run C#/.NET applications on Linux.

Install from packages

This works on Ubuntu 14.04 LTS and later. These are the official packages. This is the recommended way to install mono.

curl -s | sudo apt-key add -
echo "deb wheezy main" | sudo tee /etc/apt/sources.list.d/xamarin.list
sudo apt-get update
sudo apt-get -y install mono-complete

Install from source

Compile mono from source.


sudo apt-get -y install build-essential autoconf automake libtool zlib1g-dev pkg-config gettext

Download, compile and install

tar xf  mono-3.10.0.tar.bz2
cd mono-3.10.0
./configure --prefix=/usr/local
make -j4
sudo make install

Clean up

cd .. && rm -rf mono-3.10.0

Install from GitHub


sudo apt-get -y install build-essential autoconf automake libtool zlib1g-dev pkg-config gettext git

Download, compile and install

git clone
cd mono
./ --prefix=/usr/local
make get-monolite-latest
make -j4 EXTERNAL_MCS=${PWD}/mcs/class/lib/monolite/basic.exe
sudo make install

Configuration files need to be generated hence ./ instead of ./configure. To compile mono you need mono. If you don't already have it, make get-monolite-latest downloads a lite version and EXTERNAL_MCS uses it.

Install from Docker

Install docker

curl -sSL | sudo sh

Download mono image

sudo docker pull mono:latest

Then run it

sudo docker run -it --rm mono:latest mono --version

Install from Continuous Integration packages

If you want the latest mono but don't want to compile it from source.

sudo apt-key adv --keyserver --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb sid main" | sudo tee /etc/apt/sources.list.d/mono-jenkins.list
sudo apt-get update
sudo apt-get install -y mono-snapshot-latest

The latest snapshot will be installed in /opt/mono-snapshot-XXXX.

Before running mono, set up environment variables like this

. mono-snapshot mono

You can see the list of installed snapshots


and switch to it like this

. mono-snapshot mono/20140807112602

Precompiled mono snapshot

If you want the latest mono, don't want to compile it from source and can't use apt-get or sudo.


# save environment variables
cat > $ENVPATH <<'END'
export SNAPDATE=20141220092712
export MONO_HOME=/home/mono/mono-snapshot-$SNAPDATE
export MONO_PATH=$MONO_HOME/lib/mono/4.5
export PATH=$MONO_HOME/bin:$PATH

# load environment

# temp dir for extracting archives

# start fresh
rm -rf $TEMP && mkdir -p $TEMP
rm -rf $MONO_HOME && mkdir -p $MONO_HOME

# download .debs and extract them into $TEMP dir
dpkg-deb -x mono-*amd64.deb $TEMP
dpkg-deb -x mono-*assemblies*.deb $TEMP

# move /opt/mono-$SNAPDATE
mv $TEMP/opt/mono-*/* $MONO_HOME

# cleanup
rm mono-*.deb
rm -rf $TEMP

# replace /opt/mono-$SNAPDATE path
file $MONO_HOME/bin/* | grep "POSIX shell script" | awk -F: '{print $1}' | xargs sed -i "s|/opt/mono-$SNAPDATE|$MONO_HOME|g"
sed -i "s|/opt/mono-$SNAPDATE|$MONO_HOME|g" $MONO_HOME/lib/pkgconfig/*.pc $MONO_HOME/etc/mono/config

Mono will be installed in /home/mono/mono-snapshot-XXXX. You can load all necessary environment variables with . /home/mono/env.

Setup NuGet

NuGet is a package manager. It downloads packages from a central repository via SSL. For this reason it is necessary to import trusted root sertificates.

For all users:

sudo mozroots --import --sync --machine
echo -e "y\n\y\ny\n" | sudo certmgr -ssl -m

For current user only:

mozroots --import --sync
echo -e "y\n\y\ny\n" | certmgr -ssl


$ mono --version
Mono JIT compiler version 3.10.0 (tarball Mon Oct 20 11:45:51 EEST 2014)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors.
        TLS:           __thread
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  amd64
        Disabled:      none
        Misc:          softdebug
        LLVM:          supported, not enabled.
        GC:            sgen