51

This question already has an answer here:

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?

marked as duplicate by Byte Commander, edwinksl, Arronical, waltinator, David Foerster Sep 27 '16 at 7:57

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 17
    apt-get is fine, but 15.10 is deprecated. Please upgrade! – Zanna Sep 26 '16 at 13:16
  • 7
    See this related post: askubuntu.com/q/445384/295286 – Sergiy Kolodyazhnyy Sep 26 '16 at 13:21
  • 3
    @Zanna I did, that why this is tagged 16.04. – Skybbles Sep 26 '16 at 13:31
  • Apt is prettier than apt-get – WinEunuuchs2Unix Sep 26 '16 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. – Gallifreyan Sep 26 '16 at 17:40
35

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.

  • 19
    What features aren't in apt-get not in apt? And how apt is better for end user? – Anwar Sep 26 '16 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 '16 at 15:35
  • @Anwar: There are differences. One example: apt upgradeapt-get upgrade, since the former installs new packages, while the latter does not. – Gunnar Hjalmarsson Sep 26 '16 at 15:59
  • 24
    @Anwar If apt is a wrapper arount apt-get then it's definitely higher-level. – Tavian Barnes Sep 26 '16 at 16:00
  • @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 '18 at 11:00
45

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.

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.

  • apt provides apt-cache features with added delay! try using apt search package and apt-cache search package. Same using policy – Anwar Sep 26 '16 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 '16 at 16:19
0

As you can see from the other answers, you can use either apt or apt-get. What I would like to add is that when I tried apt a few years ago, I noticed that it resolved conflicts in a different way than apt-get did. When the situation was tricky (something had to be removed, some package was pinned to a specific version, I downgraded a package or I used a mixture of packages from different releases), apt usually wanted to remove tons of packages or couldn't resolve the conflict.

Since apt-get was much better at these situations and it didn't have any downsides, I gave up on apt and kept using apt-get instead. This was several years ago, so this may have changed, but if you run into a similar situation, you may want to try both and see which one can resolve the conflict better.

Not the answer you're looking for? Browse other questions tagged or ask your own question.