Ubuntu – How to type on the next line in the Terminal

command line

I am using Ubuntu 12.10 and want to run a set of commands in the terminal, and from what i see in the instructions, these commands each start on a new line. I don't know how to do this in the terminal. I can't find what key to press to do the carriage-return to the next line.

Best Answer

As Web-E explains the most direct way to do what you want with two different commands, I thought I'd show that there are a number of ways to execute multiple commands or to continue commands onto another line without immediately executing them.

Continuing long commands:

1) The most common way to construct one long command is to enter your commands, then use a backslash \, press return, and then Bash will provide another prompt for you instead of executing the command. This secondary prompt is called PS2 and waits for your input:

find /home/mike/Downloads -type f -iname '*.jpg' \

You can keep on adding backslashes and pressing return as long as you want, as long as you think the overall command will make sense.

You can cancel this secondary prompt with the usual Ctrl+C.

2) Bash recognises some commands such as for loops (for i in....) and the prompt will appear immediately; just as it will if you miss a quotation mark off a command:

apt-cache search 'libgimp*

Multiple Commands:

3) As Lxnslck notes, you can separate commands with semicolons:

which vlc; whereis vlc

vlc: /usr/bin/vlc /etc/vlc /usr/lib/vlc /usr/bin/X11/vlc /usr/share/vlc /usr/share/man/man1/vlc.1.gz

4) Or you can use the ampersand && to join two commands:

./configure && make
Related Question