Mathematica File Organization

Mathematica Distribution Files

A full Mathematica installation consists of thousands of separate files, arranged in several hundred directories under the main installation directory. The location of the main installation directory is determined at install time. From within a Mathematica kernel, its name is given by the value of $InstallationDirectory.

C:\Program Files\Wolfram Research\Mathematica\8.0Windows
/Applications/Mathematica.appMacintosh
/usr/local/Wolfram/Mathematica/8.0Unix

Default locations for the Mathematica installation directory.

The executable programs that launch Mathematica are typically in the main installation directory. Sometimes there may also be links to them, or scripts accessing them, in other locations. From within a Mathematica kernel, First[$CommandLine] gives the full name of the executable program corresponding to that kernel.

MathematicaMathematica front end
MathKernelMathematica kernel, usually with its own text-based interface
mathMathematica kernel to be run in a terminal or shell
mccscript for preprocessing and compiling MathLink C source files

Typical executable programs accessible from the installation directory.

The main installation directory has three standard subdirectories that contain material distributed with Mathematica. Under normal circumstances, none of the contents of these directories should ever be modified, except, for example, if you choose to edit a shared stylesheet.

AddOnsbundled Mathematica add-ons
DocumentationMathematica system documentation
SystemFilesMathematica system files

Top-level subdirectories of the main installation directory.

Particularly on Unix systems, Mathematica often has executable files for different computer architectures and systems stored in a single overall directory structure. Each system is in a subdirectory with a name given by $SystemID. Some resource directories may also contain files specific both to particular languages and particular computing environments. These files are given in subdirectories such as Japanese/Windows.

Kernel/Binaries/systemkernel binaries or elements for each computer system
Kernel/SystemResources/systemsystem-specific .mx files used by the kernel
Kernel/TextResourcesmessage and text files used by the kernel
FrontEnd/Binaries/systemfront end binaries or elements for each computer system
FrontEnd/SystemResourcesfiles used by the front end in each window system environment
FrontEnd/TextResourcesmessage and text files used by the front end
FrontEnd/StyleSheetsdefault notebook stylesheets
FrontEnd/Palettesdefault palette notebooks
Libraries/systemMathLink and other libraries used by the kernel and front end
Linksdeveloper kits for MathLink and other connection technologies
FontsMathematica fonts, often copied to a central directory
CharacterEncodingsspecifications of character encodings
SpellingDictionariesspelling dictionaries
SystemDocumentation/envUnix pages and other environment-specific documentation
Graphics/Binaries/systemPostScript interpreters and graphics programs
Graphics/SystemResourcesPostScript definitions and other resources for graphics
Graphics/Packagespackages for setting up graphics

Typical subdirectories of the SystemFiles directory, part one.

Installationvarious auxiliary programs used in installation, called automatically by the main installer program
IncludeFilesfiles for inclusion in other programs
Javafiles for the Java Runtime Environment (if needed)

Typical subdirectories of the SystemFiles directory, part two.

Files of information to be displayed by the Mathematica Help Viewer are stored in the Documentation directory.

System/Guidespages that categorize and link to related functions
System/ReferencePages/Symbolsreference pages for each of Mathematica's built-in objects
System/ReferencePages/Formatsreference pages for file formats that Mathematica handles
Packages/name/Guides, etc.documentation for add-on items

Typical subdirectories of the Documentation directory.

Loadable Files

You can customize your Mathematica by adding files that can be loaded into the system under different circumstances. Such files are conventionally placed in either systemwide or user-specific base directories.

$BaseDirectorysystemwide base directory for files to be loaded by Mathematica
$UserBaseDirectoryuser-specific base directory for files to be loaded by Mathematica

Base directories for files to be loaded by Mathematica.

C:\Documents and Settings\All Users\Application Data\Mathematica
Windows
/Library/MathematicaMacintosh
/usr/share/MathematicaUnix

Typical values of $BaseDirectory.

C:\Documents and Settings\username\Application Data\Mathematica
Windows
~/Library/MathematicaMacintosh
~ /. MathematicaUnix

Typical values of $UserBaseDirectory.

You can specify different locations for these directories by setting operating system environment variables when you launch Mathematica, as discussed in "Mathematica Sessions"

ApplicationsMathematica application packages
Autoloadpackages to be autoloaded on startup
FrontEndfront end initialization files
Kernelkernel initialization files
Licensinglicense management files
SystemFilesgeneral system files

Typical subdirectories of Mathematica base directories.

Some files in base directories serve as configuration files, automatically used by the Mathematica kernel or front end.

Kernel/init.mrun when the kernel is started
Kernel/end.mrun when the kernel is terminated
FrontEnd/init.mread when the front end is started
SystemFiles/FrontEnd/StyleSheets/customized notebook stylesheets
SystemFiles/FrontEnd/Palettes/additional palettes to appear in the front end menu

Some typical kernel and front end configuration files.

Kernel configuration files can contain any Mathematica commands. These commands can test global variables such as $SystemID and $MachineName to determine what operations to perform. Front end configuration files can contain only certain special commands, as described in "Input Syntax".

Applications/name/named add-on applications
Autoload/name/add-ons to be loaded automatically when Mathematica is started

Subdirectories under $BaseDirectory and $UserBaseDirectory.

With the default setting for the kernel $Path variable, an add-on can be loaded from within a Mathematica session simply by using the command . This will load the init.m file for the add-on, which should in turn be set up to load other necessary files or packages.

By placing an add-on under the Autoload subdirectory of $BaseDirectory or $UserBaseDirectory, you can have Mathematica automatically load the add-on whenever you start the kernel or the front end.

Kernel/init.man initialization file to be loaded by the kernel
FrontEnd/init.man initialization file to be loaded by the front end
Documentation/documentation to be found by the front end

Typical possible contents of the directory for an add-on.

New to Mathematica? Find your learning path »
Have a question? Ask support »