LinuxMint 18: Download package source code with apt source

The apt source can download package source code. But LinuxMint 18 cannot run apt source by default because deb-src is not defined. This article will describe enabling deb-src and downloading package source code with apt source.

1 Cannot run apt source by default

The apt source after installing LinuxMint 18 will be failed.

$ apt source linux
Reading package lists... Done
E: You must put some 'source' URIs in your sources.list

This is because deb-src is not defined in etc/apt/sources.list and /etc/apt/sources.list.d.

2 Enable deb-src

Add deb-src URL to repository list.

$ sudo su -c "grep '^deb ' /etc/apt/sources.list.d/official-package-repositories.list | \
sed 's/^deb/deb-src/g' > /etc/apt/sources.list.d/deb-src.list"

Update repository database.

$ sudo apt update -y

3 Execution result

Now the apt source is succeed

$ mkdir linux
$ cd linux
$ apt source linux
<snip>
$ ls
linux-4.4.0  linux_4.4.0-28.47.diff.gz  linux_4.4.0-28.47.dsc  linux_4.4.0.orig.tar.gz