6

I'm using a dedicated server and this provider installs Ubuntu 16.04 with almost nothing. For example none of these commands exist so I need to install them one by one:

curl, nano, tmux, htop, iptables, ifconfig and many more of these basic stuff that I don't recall.

I used to use another dedicated server provider and their images would come with those basic stuff.

Now it's a hassle to install those one by one every time I get a new dedicated server (and I get a lot) and/or when I reinstall the OS and they don't have a snapshot feature either.

Is there a command that I can get basic stuff in bundle or something without having to run apt install xx each time for each app I mentioned above?

Eliah Kagan
  • 117,780
  • 10
    Just run it as a single command apt install curl nano tmux htop iptables net-tools – pLumo Aug 12 '19 at 12:14
  • Thanks but I already know this. I'm looking for a better solution if there's any, of course. – Marry Jane Aug 12 '19 at 12:15
  • 15
    there won't be a better solution, because everyone will have a different opinion what are "basic" applications. For example, I would never ever install nano ... – pLumo Aug 12 '19 at 12:16
  • 5
    Is creating a script to grab what you want beyond you? You should only grab the bare minimum set of tools you need, so it's better to create your own minimal set than use a predefined set created by someone else (that may contain packages you don't need) – guiverc Aug 12 '19 at 12:17
  • 1
    This ^^^^ For things you want to automate for yourself you create a script. My post install script before the "minimal" option was introduced had lots of apt remove lines – Rinzwind Aug 12 '19 at 12:18
  • 2
    You can install the packages you want when you provision the first server, and then export and import the package lists using dpkg --get-selections and dpkg --set-selections. See for example Install many applications using one command – steeldriver Aug 12 '19 at 12:44
  • 1
    Thank you @steeldriver this should work for me. – Marry Jane Aug 12 '19 at 12:47
  • tasksel might be what you're looking for - install that, and then pick the options that sound relevant. But otherwise, it's best practice to keep a script handy for this kind of thing if you can't just make your own custom image. – rm-vanda Aug 12 '19 at 20:49
  • You don't need to do it "one by one" in any case... you can install any number of packages with a single command, and you can keep that command handy in a file. – hobbs Aug 13 '19 at 08:09
  • 1
    Note that ifconfig has been deprecated for quite a while now. It's recommended to start using ip instead. This also explains why ifconfig isn't installed by default. – marcelm Aug 13 '19 at 13:48

4 Answers4

12

Is creating a script to grab what you want beyond you?

You should only grab the bare minimum set of tools you need, so it's better to create your own minimal set than use a predefined set created by someone else (it'll likely contain packages you don't need)

As @Rinzwind said in comments, your script may also include the removal of default installed packages you don't need (ie. to help achieve the minimal packages your system actually needs).

guiverc
  • 30,396
12

The fastest solution to install these would be to install the ubuntu-server packageset which has dependencies on these tools and scripts by default. Then you can script the removal of tools you don't need.

However, if you do so, ubuntu-server gets removed (it's a metapackage, it won't break your system if it's removed), and then if you ever run apt autoremove at any point after, those tools will have a chance to be removed since their only dependency point on-system was ubuntu-server

Thomas Ward
  • 74,764
5

If you don't want to run apt install <packagename> each time, you can combine them in one line

apt install curl nano tmux htop iptables net-tools

Alternatively, if you have a reference server you can use

on the original server

dpkg --get-selections > /tmp/selections.list 

on the new server

dpkg --set-selection < /tmp/selections.list
apt-get dselect-upgrade

However, keep in mind this sets all packages !!

So its advised to only do this on the same OS version, i.e. Ubuntu 16.04 to Ubuntu 16.04. If you do this from an old Ubuntu 16.04 to a new Ubuntu 18.04, you will break the new Ubuntu 18.04.

Robert Riedl
  • 4,351
2

If you do this regularly consider using a configuration management tool like Ansible, Chef, Puppet, ...

You can create a bootstrap playbook/recipe/script (they all call it different) with the configuration you want and the tool makes sure your configuration is met. This can include installed packages, users, groups, ssh keys, passwords ... basically everything that can be configured.