59

Lately, I've seen many people use

sudo apt

instead of

sudo apt-get

Also, Ubuntu keeps telling me to install things by sudo apt

The program 'foo' is currently not installed. You can install it by typing:
sudo apt install foo

(remember, foo is placeholder, not an app)

So, after this popularity in the community about using apt instead of apt-get, I'm starting to think that apt-get is deprecated and can no longer be used in my bash programs.

In my bash programs,

  • do I have to replace all apt-get commands with apt?
  • is apt-get dangerous?
  • will my programs still work?
3
  • 9
    See this related post: askubuntu.com/q/445384/295286 Sep 26, 2016 at 13:21
  • Apt is prettier than apt-get Sep 26, 2016 at 14:51
  • 2
    The reason why some users (such as myself) use apt is because it's shorter than apt-get. Less keystrokes, less time spent. I use apt-get for things like check though. Sep 26, 2016 at 17:40

3 Answers 3

53

No, apt-get is not deprecated. The man page of apt has this to say about apt vs. apt-get (and apt-cache):

SCRIPT USAGE AND DIFFERENCES FROM OTHER APT TOOLS

The apt(8) commandline is designed as an end-user tool and it may change behavior between versions. While it tries not to break backward compatibility this is not guaranteed either if a change seems beneficial for interactive use.

All features of apt(8) are available in dedicated APT tools like apt-get(8) and apt-cache(8) as well. apt(8) just changes the default value of some options (see apt.conf(5) and specifically the Binary scope). So you should prefer using these commands (potentially with some additional options enabled) in your scripts as they keep backward compatibility as much as possible.

apt also gives a warning that says

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

if it detects there is a pipe. For example:

$ apt show python | grep Package

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Package: python
APT-Sources: http://us.archive.ubuntu.com/ubuntu xenial/main amd64 Packages

As for your questions,

do i have to replace all apt-get commands with apt?

No, you don't have to replace apt-get with apt. Rather if you were using it in scripts, you should stick to apt-get because it has a stable CLI API and guaranteed backward compatibility.

is apt-get dangerous?

apt is as dangerous as apt-get: you should only install software from sources you trust.

can i use apt in Ubuntu 15.10?

Yup, you can. The problem here is you are still using Ubuntu 15.10, which is now unsupported! Please upgrade to 16.04, which is a LTS version.

will my programs still work?

By programs, I assume you mean scripts. Yes, they will still work since apt-get is not deprecated. In fact, you should prefer to use apt-get in scripts for backward compatibility as suggested by apt's man page.

42

apt-get is lower level and backwards compatible. apt is better for end-users and doesn't require or contain some extra features in that are present in apt-get.

Both are perfectly fine. apt-get is not deprecated, but your 15.10 installation is :)

Edit: From the man page of apt(8)

The apt command is meant to be pleasant for end users and does not need to be backward compatible like apt-get(8).

Edit2: apt was designed to fix some of the fundamental dependency flaws in apt-get. As it is a wrapper, apt is therefore higher level, and also loses some backward compatibility and scripting features.

6
  • 21
    What features aren't in apt-get not in apt? And how apt is better for end user?
    – Anwar
    Sep 26, 2016 at 13:21
  • 4
    Again, apt-get is not lower level than apt. This is a misleading information. apt is on same level as apt-get and apt is nothing but a wrapper around apt-get and apt-cache
    – Anwar
    Sep 26, 2016 at 15:35
  • @Anwar: There are differences. One example: apt upgradeapt-get upgrade, since the former installs new packages, while the latter does not. Sep 26, 2016 at 15:59
  • 28
    @Anwar If apt is a wrapper arount apt-get then it's definitely higher-level. Sep 26, 2016 at 16:00
  • 3
    @Anwar That's actually the definition of being "higher level" or "lower level". apt is higher level because it wraps apt-get. A sort of test is that if your apt got corrupted, apt-get would still work-- but not vice versa.
    – Sir Robert
    Mar 6, 2018 at 11:00
7

apt and apt-get are basically the same package manager, what they do is the same.

A difference is that apt also contains features from e.g. apt-cache and has a nicer looking output.

However, apt should not yet be used in scripts, at least if you want to parse its output, because it is still in development and its output format may still change. Bash's tab-autocomplete is also not yet working with many apt commands.

You can use both, whichever you prefer.

2
  • apt provides apt-cache features with added delay! try using apt search package and apt-cache search package. Same using policy
    – Anwar
    Sep 26, 2016 at 15:43
  • @Anwar I don't see any difference at all using apt(-cache) policy. With apt(-cache) search, there is a difference in speed, yes, but the output of apt is sorted and nicely formatted in return.
    – Byte Commander
    Sep 26, 2016 at 16:19

You must log in to answer this question.

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