How do I type on the next line in the Terminal?
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.
Solution 1:
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
/usr/bin/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
Solution 2:
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.
Example:
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.
Solution 3:
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.
Solution 4:
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 1280x980-2head.sh
, 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 1280x980-2head.sh
. Then, just typing ./128<tab>
(auto-completion) and <enter>
executes all the commands.