S
S
Sergey Karbivnichy2021-01-14 18:27:35
linux
Sergey Karbivnichy, 2021-01-14 18:27:35

How to get a list of dependencies of a package with "under dependencies" in APT or dpkg?

The command apt-cache depends libc6shows the dependencies for the current package. Is it possible to see all dependencies, including dependencies of dependencies.
For example:
libc6 depends on libgcc1.
libgcc1 depends on gcc-8-base and libc6
gcc-8-base depends on over 15 dependencies.
Is there any way to see them all?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Karbivnichy, 2022-02-06
@hottabxp

Midnight Commander example:
List all recursive dependencies:

apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances mc | grep "^\w" | sort -u

gcc-10-base
libblkid1
libc6
libcrypt1
libext2fs2
libffi7
libgcc-s1
libgcrypt20
libglib2.0-0
libgpg-error0
libgpm2
libmount1
libpcre2-8-0
libpcre3
libselinux1
libslang2
libssh2-1
mc
mc-data
zlib1g

So you can display recursive dependencies in columns:
apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances mc | grep "^\w" | sort -u | column

gcc-10-base	libext2fs2	libglib2.0-0	libpcre2-8-0	libssh2-1
libblkid1	libffi7		libgpg-error0	libpcre3	mc
libc6		libgcc-s1	libgpm2		libselinux1	mc-data
libcrypt1	libgcrypt20	libmount1	libslang2	zlib1g

And so you can download the package along with all recursive dependencies:
apt-get download $(apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances mc | grep "^\w" | sort -u)

Source - How to download recursive package dependencies in Ubuntu

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question