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.
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.
These are two commands to be executed one by one.
To execute at once it will be like
You can press the ENTER key after each line and if the command is not terminated (mutiline commands like
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.
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
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:
3) As Lxnslck notes, you can separate commands with semicolons:
4) Or you can use the ampersand
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,
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 put everything in brackets; for example:
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:
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)