Freesurfer install on Ubuntu 18 running in WSL

The terminal session below shows how to download, install and setup the freesurfer and X-windows environment using a terminal window launched from Ubuntu 18 running in WSL under Windows 10. The free version of Ubuntu 18 was selected from the Windows store.

After Ubuntu 18 was installed via the MS WSl instructions, MS Dcoumentation for WSL version 2 setup and install then subsequently the repos were updated on Ubuntu 18, the freesurfer installer was downloaded/installed and the shell environment was setup to run X graphics and freesurfer.

The freesurfer. *.deb package should also work on Ubuntu 20, but as of this writing it has not been tested on newer versions of Ubuntu linux. We do not advise manually trying to install packages in order to get freesurfer to run. Please allow the installer to try and determine what packages are needed on the system and install them.


... download the appropriate Freesurfer *.deb installer package. This is the dev stream
installer package from unde the "dev" subdir. For an actual release like 7.2.0 release,
you would use the URL ...

developer@DESKTOP-LD48TB7:~$ wget
--2021-05-20 04:56:12--
Resolving (
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3528163516 (3.3G) [application/vnd.debian.binary-package]
Saving to: ‘freesurfer_7-dev_amd64.deb’

freesurfer_7-dev_amd64.deb 100%[==================================================================================>] 3.29G 31.3MB/s in 1m 50s

2021-05-20 04:58:02 (30.7 MB/s) - ‘freesurfer_7-dev_amd64.deb’ saved [3528163516/3528163516]

developer@DESKTOP-LD48TB7:~$ ls

... update the repo information on the machine to index the latest packages ...

developer@DESKTOP-LD48TB7:~$ sudo apt-get update
[sudo] password for developer:
Get:1 bionic-security InRelease [88.7 kB]
Hit:2 bionic InRelease
Get:3 bionic-updates InRelease [88.7 kB]
Get:4 bionic-security/main amd64 Packages [1726 kB]
Get:5 bionic-backports InRelease [74.6 kB]
Get:6 bionic-security/main Translation-en [322 kB]
Get:7 bionic-security/restricted amd64 Packages [323 kB]
Get:8 bionic-security/restricted Translation-en [43.2 kB]
Get:9 bionic-security/universe amd64 Packages [1126 kB]
Get:10 bionic-security/universe Translation-en [254 kB]
Get:11 bionic-security/multiverse amd64 Packages [19.2 kB]
Get:12 bionic-security/multiverse Translation-en [4412 B]
Get:13 bionic/universe amd64 Packages [8570 kB]
Get:14 bionic/universe Translation-en [4941 kB]
Get:15 bionic/multiverse amd64 Packages [151 kB]
Get:16 bionic/multiverse Translation-en [108 kB]
Get:17 bionic-updates/main amd64 Packages [2070 kB]
Get:18 bionic-updates/main Translation-en [413 kB]
Get:19 bionic-updates/restricted amd64 Packages [344 kB]
Get:20 bionic-updates/restricted Translation-en [46.8 kB]
Get:21 bionic-updates/universe amd64 Packages [1735 kB]
Get:22 bionic-updates/universe Translation-en [369 kB]
Get:23 bionic-updates/multiverse amd64 Packages [25.0 kB]
Get:24 bionic-updates/multiverse Translation-en [6464 B]
Get:25 bionic-backports/main amd64 Packages [10.0 kB]
Get:26 bionic-backports/main Translation-en [4764 B]
Get:27 bionic-backports/universe amd64 Packages [10.3 kB]
Get:28 bionic-backports/universe Translation-en [4588 B]
Fetched 22.9 MB in 27s (857 kB/s)
Reading package lists... Done

... run the apt get/install command to automatically install the freesurfer distribution under
/usr/local/freesurfer/<release> Answer "Y" so any package dependenices can be installed.
The packages installed on your system may vary depending upon what is already installed on
your system ....

developer@DESKTOP-LD48TB7:~$ sudo apt-get install ./freesurfer_7-dev_amd64.deb
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'freesurfer' instead of './freesurfer_7-dev_amd64.deb'
The following additional packages will be installed:
csh libglu1-mesa libgomp1 libjpeg62 libxss1 make tcsh
Suggested packages:
The following NEW packages will be installed:
csh freesurfer libglu1-mesa libgomp1 libjpeg62 libxss1 make tcsh
0 upgraded, 8 newly installed, 0 to remove and 148 not upgraded.
Need to get 1156 kB/3529 MB of archives.
After this operation, 3034 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 bionic/main amd64 libxss1 amd64 1:1.2.2-1 [8582 B]
Get:2 bionic-updates/universe amd64 csh amd64 20110502-3ubuntu0.18.04.1 [243 kB]
Get:3 bionic/main amd64 make amd64 4.1-9.1ubuntu1 [154 kB]
Get:4 bionic/universe amd64 tcsh amd64 6.20.00-7 [428 kB]
Get:5 bionic/main amd64 libglu1-mesa amd64 9.0.0-2.1build1 [168 kB]
Get:6 bionic-updates/main amd64 libgomp1 amd64 8.4.0-1ubuntu1~18.04 [76.5 kB]
Get:7 bionic/universe amd64 libjpeg62 amd64 1:6b2-3 [78.3 kB]
Get:8 /home/developer/freesurfer_7-dev_amd64.deb freesurfer amd64 7-dev [3528 MB]
Fetched 1156 kB in 40s (28.8 kB/s)
Selecting previously unselected package libxss1:amd64.
(Reading database ... 29293 files and directories currently installed.)
Preparing to unpack .../0-libxss1_1%3a1.2.2-1_amd64.deb ...
Unpacking libxss1:amd64 (1:1.2.2-1) ...
Selecting previously unselected package csh.
Preparing to unpack .../1-csh_20110502-3ubuntu0.18.04.1_amd64.deb ...
Unpacking csh (20110502-3ubuntu0.18.04.1) ...
Selecting previously unselected package make.
Preparing to unpack .../2-make_4.1-9.1ubuntu1_amd64.deb ...
Unpacking make (4.1-9.1ubuntu1) ...
Selecting previously unselected package tcsh.
Preparing to unpack .../3-tcsh_6.20.00-7_amd64.deb ...
Unpacking tcsh (6.20.00-7) ...
Selecting previously unselected package libglu1-mesa:amd64.
Preparing to unpack .../4-libglu1-mesa_9.0.0-2.1build1_amd64.deb ...
Unpacking libglu1-mesa:amd64 (9.0.0-2.1build1) ...
Selecting previously unselected package libgomp1:amd64.
Preparing to unpack .../5-libgomp1_8.4.0-1ubuntu1~18.04_amd64.deb ...
Unpacking libgomp1:amd64 (8.4.0-1ubuntu1~18.04) ...
Selecting previously unselected package libjpeg62:amd64.
Preparing to unpack .../6-libjpeg62_1%3a6b2-3_amd64.deb ...
Unpacking libjpeg62:amd64 (1:6b2-3) ...
Selecting previously unselected package freesurfer.
Preparing to unpack .../7-freesurfer_7-dev_amd64.deb ...
Unpacking freesurfer (7-dev) ...
Setting up libgomp1:amd64 (8.4.0-1ubuntu1~18.04) ...
Setting up make (4.1-9.1ubuntu1) ...
Setting up libjpeg62:amd64 (1:6b2-3) ...
Setting up libxss1:amd64 (1:1.2.2-1) ...
Setting up tcsh (6.20.00-7) ...
update-alternatives: using /bin/tcsh to provide /bin/csh (csh) in auto mode
Setting up libglu1-mesa:amd64 (9.0.0-2.1build1) ...
Setting up csh (20110502-3ubuntu0.18.04.1) ...
update-alternatives: using /bin/bsd-csh to provide /bin/csh (csh) in auto mode
Setting up freesurfer (7-dev) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1.2) ...

... the development stream installer installs under /usr/local/freesurfer/7-dev. An actual
release would install in a different (parall) subdir, e.g., for the 7.2.0 release the
install would be under /usr/local/freesurfer/7.2.0 There is no conflict with having
multiple versions of freesurger installed - you only need to change the setting
of the FREESURFER_HOME environment variable ...

developer@DESKTOP-LD48TB7:~$ ls /usr/local/freesurfer/7-dev/
ASegStatsLUT.txt Simple_surface_labels2009.txt build-stamp.txt fsafd mni sources.csh tktools
DefectLUT.txt SegmentNoLUT.txt WMParcStatsLUT.txt diffusion fsfast models trctrain
FreeSurferColorLUT.txt SetUpFreeSurfer.csh average docs lib python subjects
FreeSurferEnv.csh bin etc matlab sessions tkmeditParcColorsCMA

... you should setup your shell with the necessary environment variables for X grpahics
and freesurfer. You can add these directly to your shell init file, e.g., the .bashrc
file for bash shell. You will also need to add a license file for freesurfer which
can be pointed to by an environment variable ...

developer@DESKTOP-LD48TB7:~$ echo "export XDG_RUNTIME_DIR=$HOME/.xdg" >> $HOME/.bashrc
developer@DESKTOP-LD48TB7:~$ echo "export DISPLAY=:0" >> $HOME/.bashrc
developer@DESKTOP-LD48TB7:~$ echo "export FREESURFER_HOME=/usr/local/freesurfer/7-dev" >> $HOME/.bashrc

... Add your license file and set FS_LICENSE to point to it ...

developer@DESKTOP-LD48TB7:~$ echo "export FS_LICENSE=$HOME/license.txt" >> $HOME/.bashrc
developer@DESKTOP-LD48TB7:~$ echo "source /usr/local/freesurfer/7-dev/" >> $HOME/.bashrc

... logout and log back in and verify you see the following ...

Setting up environment for FreeSurfer/FS-FAST (and FSL)
FREESURFER_HOME /usr/local/freesurfer/7-dev/
FSFAST_HOME /usr/local/freesurfer/7-dev//fsfast
SUBJECTS_DIR /usr/local/freesurfer/7-dev//subjects
INFO: /home/developer/matlab/startup.m does not exist ... creating
MNI_DIR /usr/local/freesurfer/7-dev//mni

... you should now be able to run freeview and other commands from the
distribution pointed to by $FREESURFER_HOME/bin ...