Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
You can separate commands by using the semi-colon ";", like cd home; mkdir test; ls -la – LnxSlck Dec 6 '12 at 16:49
@LnxSlck: Though, it's often preferable to separate commands with && instead of ;. This way, if one of the commands fail, the remaining commands will not be run. So, using your example, if home doesn't exist, you won't accidentally create a test directory in the current directory. – hammar Dec 6 '12 at 19:11
Nice one hammar. Thanks – LnxSlck Dec 9 '12 at 18:35

The commands you see in each line are to be executed one by one.

So after entering a line, press enter to execute then execute next command.


sudo apt-get update
sudo apt-get upgrade

These are two commands to be executed one by one.

To execute at once it will be like sudo apt-get update && sudo apt-get upgrade (there are other methods also), but these thing doesn't require generally . So don't worry. Type one line and press enter it will do it's job.

share|improve this answer
Thank you very much for your advice,, I wish I had known this earlier!!! Still, we live and learn :-) – Debbie Poole Dec 6 '12 at 16:54
@user113090 If Web-E answered your question, don't forget to mark his answer as the accepted answer. – Dean Dec 7 '12 at 3:02

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
share|improve this answer

You can press the ENTER key after each line and if the command is not terminated (mutiline commands like for loops for example), the terminal will wait for you to enter the rest of the command. If the command is terminated, it will be executed and you enter next command after, no problem.

If you are copying the commands from a tutorial, you can copy the whole group of commands and paste it directly in the terminal and it will work.

share|improve this answer
Thanks lauren. Speedy reply much appreciated! – Debbie Poole Dec 6 '12 at 16:56

When it's a set of commands you expect to be using more than once, you should put them in a bash script file. For instance,

xrandr --newmode "1280x960_80.00" 139.25  1280 1368 1504 1728  960 963 967 1008 -hsync +vsync
xrandr --verbose --addmode VGA1 "1280x960_80.00"
xrandr --output HDMI1 --off --output LVDS1 --mode 1366x768 --pos 1280x512 --rotate normal --output DP1 --off --output VGA1 --mode "1280x960_80.00" --pos 0x0 --rotate normal
sleep 3
xfce4-panel -r

is nothing you'd like to type ever again, but I happen to need this particular sequence of commands very often. So it goes in a file called, you can create that with any editor of your choice. To make that script executable, you put the line #!/bin/bash in front of everything (a shebang), and set the execution-permission: chmod +x Then, just typing ./128<tab> (auto-completion) and <enter> executes all the commands.

share|improve this answer

You can put everything in brackets; for example:

(sudo add-apt-repository ppa:foo/bar
sudo apt-get update
sudo apt-get install my-package)

The commands will be executed one after the other in a sub-shell.

If you don't want them to be executed in a sub-shell, you can put a semicolon between a command and the other; for example:

sudo add-apt-repository ppa:foo/bar; sudo apt-get update; sudo apt-get install my-package

Instead, if you put "&&" between each commands, the command that follows the "&&" will be executed only if the previous command has finished with no error, so you don't have to use it to concatenate commands; use semicolons instead. Conversely, if you put "||", the following command will be executed only if the first one exits with an error. Example: (the "which" command checks if a program exists, and if doesn't exits with an error)

which apt-get && echo "No error" || echo "Error"    # Will print "No error"
which jdhdsd && echo "No error" || echo "Error"  # Will print "Error"
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.