KaliLinux 2017.1: Download package source code with apt source

But apt source cannot download 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 Linux.

$ 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 sed -e 's/^# deb-src/deb-src/g' -i /etc/apt/sources.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.9.30                       linux_4.9.30-2kali1.dsc
linux_4.9.30-2kali1.debian.tar.xz  linux_4.9.30.orig.tar.xz