Several ways...
For one, you have several virtual terminals. Just press Ctrl-Alt (you could use just Alt, but if you ever install X, you need Ctrl-Alt to leave X, so better get used to Ctrl-Alt from the beginning) and one of the keys between F1 and F6. Odds are that you're in F1, X is usually on F7, and on F2 through F6 are five *other* (than F1) virtual terminals you can log into.
+++
If you don't want to log-in again -- and you're *not* running something interactive -- you can run the command in the background.
To start a command in the background, follow the name with a &:
$ g++ -o myprog myprog.cc &
(Note: If the program suddenly need keyboard input, it will stop until you put it into the foreground and give it some input.)
Then you can start some other program, while the first one (or several others) is working in the background:
$ nano myfile.txt
(Programs like nano are interactive, so they're no use in the background)
If you ever install X, know that most X-clients (X-programs) can be started in a terminal and put in the background without problem. After all, they recieves input from windows they draw, and not from the terminal.
+++
Some commands will write status-messages to the screen after being put into the background. This will clutter-up the screen for any foreground programs. But you can redirect this output to a file (for reviewing later) or to /dev/null (to just get rid of it). An additional stream is used to print error-messages, but for many programs these too may be redirected.
To redirect output from a background program to a file:
$ g++ -o myprog myprog.cc > /tmp/compile.log &
To redirect output to the black hole /dev/null:
$ g++ -o myprog myprog.cc > /dev/null &
To throw away output, but save serious errors:
$ g++ -o myprog myprog.cc > /dev/null 2> /tmp/crror.log &
To merge output and error and throw both away (for bash-shell):
$ g++ -o myprog myprog.cc >& /dev/null &
+++
If you have started the program -- or some program; then Ctrl-Z will stop and suspend it. You can then start an other program (and remember to put it into the background), or you can type in 'bg' to put it into the background (similar to starting it with an &).
$ g++ -o myprog myprog.cc
Ctrl-Z
$ bg
...is the same as:
$ g++ -o myprog myprog.cc &
The command 'jobs' lists all processes stopped or running in the shell. %
(eg. %3) is the job-number the process have (in the current shell). "+" is a shorthand for "current process" (last) and "-" is a shorthand for "previous process" (one before last). The job-number is used with 'fg' and 'bg'; without the job-number, the + process is assumed.
You can also continue a program that was stopped in the foreground with the command 'fg':
$ nano
Ctrl-Z (stopps nano)
$ g++ -o myprog myprog.cc & (starts compiler in background)
$ jobs
===> %1 - nano *Stopped*
===> %2 + gcc &
$ fg %1 (continues 'nano' in foreground)
+++
Often you don't need background-programs to run at full speed, so to save more processing power for your other (foreground) programs, you can run the background processes at lower priority:
$ nice -n 15 g++ -o myprog myprog.cc &
(Runs with quite low priority)
To make a background-process surviving log-out (but *not* computer shut-down), use nohup:
$ nohup g++ -o myprog myprog.cc &
$ exit
(Output is saved to a file)
+++
As mentioned, this will not work with interactive programs (like pine, nano, tin, emacs). A program called 'screen'; allows you to "multiplex" one virtual-terminal/xterm/serial-line, creating several "windows" that each may have a program and let you switch between them. You can also "disconnect" screen and let the programs run although you're not logged on... and later you can reconnect from the same or another vt/xterm/serial-line.
$ screen
Ctrl-A C to create new window
Ctrl-A [Space] to switch to next window
Ctrl-A A to switch to last visited window
Ctrl-A D to disconnect screen
$ screen -r (to resume a disconnected screen-session)
$ screen -D -r (to disconnect and log out one place, and re-connect the session "here")
A similar program for just running one interactive command is 'disconnect', a program found in the 'expect' package for the Tcl/Tk language. 'disconnect' is really just an expect-script. It works well with interactive-programs that need to be in the foreground but can "run by themselves" for a while (like mp3blaster). You may the "re-connect" the program later (somewhere else). Ctrl-] is used to "escape" the program you're running, so you can "talk" to 'disconnect' itself.
$ disconnect mp3blaster (Starts the program)
Ctrl-] (Escapes to the 'disconnect' program)
Ctrl-D ("Disconnects" 'disconnect'... mp3blaster still runs)
$ disconnect