0

I want to create a code that I put my terminal to install few software at the same time.

For example, after a fresh install, I like to install this kind of software, but I have to line per line...

I want to do it in one time?

sudo add-apt-repository ppa:atareao/atareao
sudo apt-get update
sudo apt-get install my-weather-indicator

sudo apt-get install unity-tweak-tool

sudo add-apt-repository ppa:peterlevi/ppa
sudo apt-get update
sudo apt-get install variety

How I can put all this in the terminal in one shot?

How I can automatically set ENTER when I add the ppa and after set to Yes for the install?

0

2 Answers 2

4

This is what you want:

sudo add-apt-repository ppa:atareao/atareao && sudo add-apt-repository ppa:peterlevi/ppa && sudo apt-get update && sudo apt-get install my-weather-indicator  unity-tweak-tool variety

Purpose of &&:

let's say:

command one && command two

means execute the command two if and only if the command one is successful. This prevent errors so if some command failed for some reason then the next commands will not run, but if you want to run commands even if there is an error then replace && with ; so that command become:

sudo add-apt-repository ppa:atareao/atareao ; sudo add-apt-repository ppa:peterlevi/ppa ; sudo apt-get update ; sudo apt-get install my-weather-indicator  unity-tweak-tool variety
4
  • Only problem I have with this: it becomes unreadable. I would prefer the method where commands are put inside a text file and that file is executed.
    – Rinzwind
    Jul 23, 2015 at 12:29
  • thanks for your answers, so it s working but how i can automatically set ENTER when i add the ppa and after set to Yes for the install? thanks
    – Kobura
    Jul 23, 2015 at 15:03
  • Yes thanks a lot Maythux. i will reedit the question and add this part. thanks again :-) that help me!
    – Kobura
    Jul 23, 2015 at 17:21
  • 1
    No reason to use yes | sudo apt-get for the install, simply use "sudo apt-get install -y PackagetoInstall" Jul 23, 2015 at 18:11
4

You can write a shell script filename.sh. Type:

user@system:~$ gedit filename.sh

Input the following code:

#!/bin/bash
sudo add-apt-repository ppa:atareao/atareao ; 
sudo add-apt-repository ppa:peterlevi/ppa ;
sudo apt-get update; sudo apt-get install my-weather-indicator unity-tweak-tool variety
exit 0

Save the script. You can run the script by following command.

user@system:~$ /bin/bash filename.sh

After each fresh installation you can copy this script and run to install all packages in one go.

OR

If you want to run all commands in terminal as one line, you can try the following:

sudo add-apt-repository ppa:atareao/atareao ; sudo add-apt-repository ppa:peterlevi/ppa ; sudo apt-get update; sudo apt-get install my-weather-indicator unity-tweak-tool variety

Hope this helps.

2
  • thanks for your answers, so it s working but how i can automatically set ENTER when i add the ppa and after set to Yes for the install? thanks
    – Kobura
    Jul 23, 2015 at 15:03
  • You can use -y to set ENTER : sudo add-apt-repository -y ppa:atareao/atareao
    – ATR
    Jul 24, 2015 at 5:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .