Home Kali Linux Mastering the Kali Linux sources.list file usage

Mastering the Kali Linux sources.list file usage

by Brandon Jones
Kali Linux Distro

The concept of sources.list is not just a thing of the Kali Linux operating system domain. It is applicable in all Linux operating system distributions. Therefore, when you want to install any application on your Kali Linux operating system, you first have to consider the viability of this file. Also, when you need to upgrade an existing application Kali Linux, this file becomes a key factor. 

In short, all Linux operating system activities related to application installation, upgrade, and system update all reference the sources.list file. In this case, it tells your Kali Linux operating system where to find system updates, application downloads, and application upgrades. 

Kali Linux network repositories

Linux repositories are very extensive and never fail to pop up in almost all Linux community forums. Unfortunately, some users confuse its usage, and others misinterpret its implementation.  The location of the repositories list on your Kali Linux system is on the path “/etc/apt/sources.list”. This article will try as much as possible to provide in-depth information and references regarding the usability of the sources.list file. 

By the end of your read, you should be confident in precautiously adding and editing information on your Kali Linux sources.list file. 

Kali Linux default repository values

A clean Kali Linux operating system installation has its “/etc/apt/sources.list” file pre-populated with some repository info. Also, the installation needs to take place under stable network access for the default repository entry to be generated. You can access this entry from your Kali terminal with the following command:

$ grep -v '#' /etc/apt/sources.list | sort -u

  The execution of the above command should lead to a terminal output like the following:

deb http://http.kali.org/kali kali-rolling main non-free contrib 

If the command-line output on your end is not an exact match to the one above, your first attempt at running a Kali Linux system update will fail. You will also face challenges while trying to install new system packages. Two main reasons are responsible for this outcome.

  • The Kali user switched to a different branch 
  • The Kali user is using a hardcoded mirror 

From Kali 2020.3, once the installation setup of a Kali Linux operating system completes, the default pre-configuration of network repositories follows suit. Furthermore, pre-configuration network repositories happen regardless of whether the Kali Linux OS installation took place under viable network access. 

Switching regular repositories/branches 

The Kali Linux operating system distribution offers users a range of repository branches to consider for their Linux OS environment. These branches give a Kali user the flexibility of switching to or working with additional repositories. We will highlight some notable Kali branches, and you will have to decide on the one that best suits your operating system setup. 

Kali-rolling branch

It is the default Kali Linux branch and has frequent updates. You can implement it to your Kali Linux system with the following command. 

$ echo "deb http://http.kali.org/kali kali-rolling main non-free contrib" | sudo tee /etc/apt/sources.list

Kali-last-snapshot branch 

It is the Kali Linux point release branch. It is also attributed to be the safest and most stable. You can implement it to your Kali Linux system with the following command.

$ echo "deb http://http.kali.org/kali kali-last-snapshot main non-free contrib" | sudo tee /etc/apt/sources.list

Kali-experimental branch

It caters to Kali Linux packages that are in the beta or testing phase. Most of the time, its package releases go hand in hand with Kali’s rolling repository. You can implement it to your Kali Linux system with the following command.

$ echo "deb http://http.kali.org/kali kali-experimental main non-free contrib" | sudo tee /etc/apt/sources.list.d/kali-experimental.list

Sources.list format 

Consider the following segmented breakdown of an entry in the Kali Linux sources.list file. 

deb        http://http.kali.org/kali kali-rolling  main non-free contrib 
<Archive> <Mirror> <Branch> <Component>
  • Archive: Depending on whether a Kali user wants a package’s source or the package itself, the archive can be deb-src (Source) or deb (Regular Binary). 
  • Mirror: It depicts your load balancer and always adheres to the format “http.kali.org/kali”. A mirror safe keeps a duplicate copy of an update or package data that you seek to download, install, and configure. It directs a Linux user to the best possible access point to these packages and updates data. 
  • Branch: It points to the Kali Linux OS version you are currently using or one you would like to switch to should you decide to edit the info on your OS sources.list file. 
  • Component: It references DFSG or the Debian Free Software Guidelines and describes the types of OS packages preferred by a Linux user. It can be the main component, a non-free component, or Linux community users and developers contributed. By default, Kali Linux chooses all types of OS packages. 

Default Kali Linux offline install values 

Regardless of whether you have an active and accessible network connection during your Kali Linux operating system installation, you can still opt to go with an offline installation of this Linux distribution. An offline installation of Kali Linux is limited to the installation medium’s OS version and availed packages.  

Even after the offline installation of Kali Linux completes, the success of associated package installations will remain bound to the Kali Linux installation medium. With this installation medium only providing pre-packaged packages, this offline approach limits a Kali user from accessing additional system tools and implementing any packages update. It is a known frustration to many users.

Your sources.list file sometimes has the values of the offline installation medium enabled. If you took this offline Kali Linux installation approach, you could check the offline medium sources.list status on your Kali system by running the following command:

$ cat /etc/apt/ sources.list  

You should see an output similar to the following:

# 
# deb cdrom:[Kali GNU/Linux 2020.1a _Kali-last-snapshot_ - Official amd64 DVD Binary-1 with firmware 20200213-14:56]/ kali-rolling main non-free
# deb cdrom:[Kali GNU/Linux 2020.1a _Kali-last-snapshot_ - Official amd64 DVD Binary-1 with firmware 20200213-14:56]/ kali-rolling main non-free
# This system was installed using small removable media # (e.g. netinst, live or single CD). The matching "deb cdrom"
# entries were disabled at the end of the installation process. # For information about how to configure apt package sources,
# see the sources.list(5) manual.

If you want to enable this offline installation medium on Kali Linux sources.list file, execute the following command on your system terminal.

$ sudo apt-cdrom add

 It should lead to a terminal output similar to the following:

Using CD-ROM mount point /media/cdrom/ 
Identifying... [ea19ff4bedaa6c8f4662c0e8c58ed44c-2]
Scanning disc for index files...
Found 2 package indexes, 0 source indexes, 0 translation indexes and 0 signatures
This disc is called:
'Kali GNU/Linux 2020.1a _Kali-last-snapshot_ - Official amd64 DVD Binary-1 with firmware 20200213-14:56'
Reading Package Indexes... Done
Writing new source list
Source list entries for this disc are:
deb cdrom:[Kali GNU/Linux 2020.1a _Kali-last-snapshot_ - Official amd64 DVD Binary-1 with firmware 20200213-14:56]/ kali-rolling main non-free
Repeat this process for the rest of the CDs in your set.

If you achieve a similar output on your end, revisit the switching branch section of this article we discussed and make the necessary implementations on your sources.list file to start receiving system updates. 

On the other hand, if your Kali Linux installation was under an active and stable network connection, the chances are that the needed network repositories were accessed and enabled. Therefore, you do not need to implement any of the above terminal changes. 

Non-Kali repositories

 In most cases, a Kali Linux user might need to access additional tools and software like Signal for download, installation, and configuration. The Kali Linux repositories are not enough to meet such user demands. Such cases require the inclusion of extra repositories on your Kali Linux system. It does not imply that you alter or make any changes to the already established “/etc/apt/sources.list” file. This sources.list file is strictly reserved for your Kali OS. 

Softwares and tools that require non-Kali repositories for their download and installation should have these repositories defined in a different OS directory file. Under Kali Linux, the directory in question here is “/etc/apt/sources.list.d/”. This directory can host a file like “/etc/apt/sources.list.d/repo-name.list” where “repo-name” points to an associated mirror for the needed tools and software packages download and installation. 

In short, each file in the “sources.list.d” directory should adhere to a naming convention that relates to the mirror name from which the needed software and tools packages reside as mirror entries. Mixing Kali’s repositories with those of other Linux distributions can prevent your system from working. Your operating system may break without warning. Most Kali Linux systems break down completely because of this repo mixup, and so you should avoid repeating this mistake at all costs.

If you are unfortunate enough to be a victim of this repo mixup, the most viable solution is to perform a fresh Kali Linux installation.    

Mirrors

Several official Kali Linux mirrors exist from its main site. If you need to set up one of these mirrors, refer to the official Kali Linux mirror guide. Such mirrors may be configured to be accessible through a remote private network or an accessible LAN if their configurations allow them to exist as local repositories. 

Source repositories

Downloading binary packages requires that your repositories use “deb”. If you are after a package’s source, your repositories’ lists will need to use “deb-src” instead of “deb”. Going after a package’s source has two implications; you either wish to self-compile the package or provide an algorithmic input to an existing debugging problem. A repository entry that will enable you to retrieve the Kali Linux package’s source can be implemented with the following command:

$ echo "deb-src http://http.kali.org/kali kali-rolling main non-free contrib" | sudo tee -a /etc/apt/sources.list

As demonstrated above, you can decide to go with a different branch value other than “kali-rolling.”  

Final note 

Your understanding of Kali Linux sources.list file should now be on another level. You now know the dos and don’ts of dealing with Kali Linux repositories and how best to debug a repository issue if one arises. A Kali user always needs specific tools and software while pursuing a hackathon challenge or course. Understanding the configuration and rules behind the “sources.list” file and “sources.list.d” directory will save you from getting into irreversible trouble.    

You may also like

Leave a Comment

fl_logo_v3_footer

ENHANCE YOUR LINUX EXPERIENCE.



FOSS Linux is a leading resource for Linux enthusiasts and professionals alike. With a focus on providing the best Linux tutorials, open-source apps, news, and reviews written by team of expert authors. FOSS Linux is the go-to source for all things Linux.

Whether you’re a beginner or an experienced user, FOSS Linux has something for everyone.

Follow Us

Subscribe

©2016-2023 FOSS LINUX

A PART OF VIBRANT LEAF MEDIA COMPANY.

ALL RIGHTS RESERVED.

“Linux” is the registered trademark by Linus Torvalds in the U.S. and other countries.