Using a TextBased Interface

The standard front end interface, as discussed in "Using a Notebook Interface", is appropriate for most users' purposes. In some cases, however, you may not need to use the notebook front end, and you may want instead to interact more directly with the Wolfram Language kernel. You can do this by using a textbased interface, in which text you type on the keyboard goes straight to the kernel.

It is important to note that while the text-based interface provides access to most of the capabilities of the Wolfram Language kernel, the graphics functionality and dynamic interactivity of the Wolfram System front end are not available.

Starting the Wolfram Language Kernel

To start the Wolfram System with a textbased interface, you typically type the command wolfram at an operating system prompt.

$ wolfram
Mathematica 11.2 for Linux x86 (64-bit)
Copyright 1988-2017 Wolfram Research, Inc.

C:\Program Files\Wolfram Research\Mathematica\11.2>wolfram
Mathematica 11.2 for Microsoft Windows (32-bit)
Copyright 1988-2017 Wolfram Research, Inc.


Sometimes you may need to provide the full path to the WolframKernel executable.

$ /Mathematica/11.2/
Mathematica 11.2 for Mac OS X x86 (64-bit)
Copyright 1988-2017 Wolfram Research, Inc.


On some systems, you may also be able to start the Wolfram System with a textbased interface by doubleclicking a Wolfram System kernel icon.

A Wolfram System Session

At each stage, the Wolfram System prints a prompt of the form In[n]:= to tell you that it is ready to receive input. You can then type your input, ending with Enter or Return.

Note that you do not explicitly type the In[n]:= prompt; only type the text that follows this prompt.

When you have entered your input, the Wolfram System will process it and generate a result. If it prints the result out, it will label it with Out[n]=.

A dialog with the Wolfram System using a textbased interface.
In[1]:= 2^100

Out[1]= 1267650600228229401496703205376

In[2]:= Integrate[1/(x^3 - 1), x]

1 + 2 x
ArcTan[-------] 2
Sqrt[3] Log[-1 + x] Log[1 + x + x ]
Out[2]= -(---------------) + ----------- - ---------------
Sqrt[3] 3 6

In the Wolfram System documentation, "dialogs" with the Wolfram System are often shown in the following way:

The computer prints In[1]:=. You just type in 2+2. The line that starts with Out[1]= is the result from the Wolfram System.
Click for copyable input

Most of the actual dialogs given in the Wolfram Language tutorials show output in the form you get with a notebook interface to the Wolfram System; output with a textbased interface looks similar, but lacks such features as special characters and font size changes.

Editing the Input

Ctrl+A,Homemove cursor to the beginning of the input
Ctrl+E,Endmove cursor to the end of input
Ctrl+H,Backspacedelete a character before the cursor
Ctrl+D,Deletedelete a character after the cursor
Ctrl+G,Ctrl+C,Esccancel or abandon the input
Ctrl+Kdelete from the cursor to the end of input
Ctrl+D,Ctrl+Zterminate the kernel
Left,Rightmove the cursor
Up,Downrecall previous input
Enterevaluate the input or add another line
PageUp,PageDownjump to the first or last item in input history

Default keys for editing the input.

If your input is short, then you can give it on a single line. If your input is longer, it is automatically wrapped at the end of the screen to form two or more lines. You can always move the cursor back and insert or delete characters. The wrapped lines will be updated according to your edits.

To move the cursor along the input line, you use the left and right arrow keys on your keyboard. You can also jump to the beginning of the input using the Ctrl+A keys. To jump to the end of input, press Ctrl+E. You can also delete characters before or after the cursor by pressing Ctrl+H or Ctrl+D, or Backspace or Delete, correspondingly.

When your input is long, you can also give it on several lines. The Wolfram Language will automatically continue reading successive lines until it has received a complete expression. Thus, for example, if you type an opening parenthesis or double quotation mark on one line, the Wolfram Language will go on reading successive lines of input until it sees the corresponding closing parenthesis or double quotation mark.

In[1]:= 1+
2 f[

Out[1]= 1 + 2 f[x]

However, if you press Enter to continue on the next line, you will not be able to edit the previous line.

If you paste as input text consisting of several complete Wolfram Language expressions separated by newlines, these expressions will be interpreted as separate inputs, and you will see several Out[n] prompts.

Occasionally, you may want to erase the input and start again rather than evaluating what has already been typed. To cancel, or abandon, already typed input use Ctrl+G. Or, if you want to delete the input after the cursor position, use Ctrl+K.

A list of keyboard shortcuts is given in the preceding table.

Input History

%n orOut[n]the value of the n output
In[n]the n input, for reevaluation
Up,Downscroll input history up or down

Retrieving and reevaluating previous input and output.

With a textbased interface, each line of the Wolfram Language input and output appears sequentially. It is also numbered by consecutive numbers, starting from 1, which are displayed as part of the In[n] and Out[n] prompts. These numbers allow you to retrieve or reevaluate previous input and output. In general, reevaluating a particular piece of input or output may give you a different result than when you evaluated it in the first place. The reason is that in between you may have reset the values of variables that are used in that piece of input or output. If you ask for Out[n], then the Wolfram Language will give you the final form of your n output. On the other hand, if you ask for In[n], then the Wolfram Language will take the n input you gave and reevaluate it using whatever current assignments you have given for variables.

Often your computer system will allow you to scroll backward to review previous work and to cut and paste previous lines of input. Or you may recall previously entered input by using the Up or Down arrows.

Starting the Raw Text-Based Interface

Normally, when the Wolfram Language kernel is run in a text-based interface, it provides additional tools such as command line editor or command history, which were described in the previous sections. In order for such tools to operate, the kernel uses special low-level instructions to control the character terminal or terminal emulator you are using. In some cases you may want to prevent the kernel from doing that, for example if your terminal does not support some of the low-level instructions needed by the command line editor or if you need to run the kernel non-interactively as part of the larger command.

To run the Wolfram Language kernel in a raw mode, use the -rawterm command line switch. When in the raw mode, the kernel accumulates all bytes it receives from the keyboard directly in the input buffer for further parsing and interpretation.

$ wolfram -rawterm
Mathematica 11.2 for Linux x86 (64-bit)
Copyright 1988-2017 Wolfram Research, Inc.

C:\Program Files\Wolfram Research\Mathematica\11.2>wolfram -rawterm
Mathematica 11.2 for Microsoft Windows (32-bit)
Copyright 1988-2017 Wolfram Research, Inc.

$ /Mathematica/11.2/ -rawterm
Mathematica 11.2 for Mac OS X x86 (64-bit)
Copyright 1988-2017 Wolfram Research, Inc.


This raw mode very much resembles the "old style" command line interface used in the previous versions of the Wolfram System.

Terminating the Kernel

To exit the Wolfram System, type Quit[] at an input prompt. You may also exit the Wolfram System by pressing Ctrl+D or Ctrl+Z, depending on your computer system. Ctrl+D will terminate the Wolfram System if the input line is empty.

Ctrl+D, Ctrl+Z, or Quit[]exiting the Wolfram System

Terminating the Wolfram System with a textbased interface.

Related Tutorials