Is 'apt-get' deprecated?
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 withapt
? - is
apt-get
dangerous? - will my programs still work?
Solution 1:
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.
Solution 2:
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.
Solution 3:
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.