When I paste to terminal the following code:
wclean; sudo bash; wmake;
It asks for password for
sudo bash, then I have to type it (no problem). But it doesn't keep going. It stops before
How to paste entire code to terminal and execute it line by line? I want a simple solution because these codes I paste are from internet, books, tutorials, ...
Pasting multiple commands at once may lead to problems if one of them waits for terminal input. In this case the rest of the paste will be taken as input for that command and not as separate command to be run afterwards. The most common example is probably the
sudo password prompt.
However, Bash is capable of opening a text editor to enter commands, by default it is
nano. You start the command editor by pressing Ctrl+X followed by Ctrl+E. The editor launches and everything you typed into the current command line so far will also appear there and can be edited. If the command line was empty though, the editor will be empty as well.
In the editor you can now easily paste or type multiple commands, simply put one command per line and Bash will take care of joining them with semicolons itself.
If you're done and want to submit your list of commands, simply exit the editor (Ctrl+X for
nano) and Bash will start to execute all the commands one after the other.
If you enter as super user, all the command you run will be granted with super user privileges, so no password will be asked.
sudo su on the terminal prompt before pasting your commands. The prompt must have been changed from $ to #.
Simple, copy that and paste in a file, and then execute the file, For Example:
Ctrl+Shift+V [to paste the code]
Ctrl+O [Save it]
chmod 755 test.sh
As @jiipeezz commented, there's nothing wrong with not continue after
sudo bash, because with this command you open a new shell. In fact, terminating the shell ( with
exit ) the the next command is executed. If you want to run the command
wmake as superuser, then you have to pass the command as argument to shell, with
sudo bash -c 'wmake'. Try:
sudo bash -c 'wmake';
But I do not think it makes sense to run a single command on a new shell, instead it uses sudo to run the command directly.
In your case, the answer is to change the commands you're using. You are trying to start a bash shell as root in order to run a command. The clean way of doing this is to just run
sudo command. So, all you need is to copy paste the following directly into your terminal:
You don't need to first run
sudo bash and then
sudo directly. You also don't need the
; at the end of each command. The
; is only needed if you are running two commands on the same line (e.g.
You could change the semicolons(;) with '&&' without the quotes, in your case for example:
sudo bash &&
BTW no '&&' at the end.
Have a nice day