Kali Linux add PPA repository add-apt-repository

A Personal Package Archive (PPA) is a special software repository for uploading source packages to be built and published as an APT repository by Launchpad or a similar application. While the term is used exclusively within Ubuntu, Launchpad host Canonical envisions adoption beyond the Ubuntu community.

Debian allows users to add and use PPA repositories by an application named add-apt-repository however, Kali Linux didn’t include this in their default package list. With Kali, because this is a special purpose application and certain modifications were made to make it work for what it does best (Penetration Test), there’s a chance that by adding untested and unsupported PPA repositories and application you might end up breaking your installation.

However, PPA is a powerful tool to have and a lot of the specific applications that are not available in repositories are available via PPA repositories. Users should take extra care before adding unknown and random repositories as it might very well break other things. I mean, how do you know the PPA owner didn’t add some harmful code in their system? Generally, you don’t. Then again, how do you know that Linux Kernel doesn’t have something that’s spying on your activity? But I guess that doesn’t matter, your ISP would be happy enough to hand over your online activity to NSA anyway … I could go on and on, but let’s not waste more time and move to actual post “Kali Linux add PPA repository add-apt-repository” .. so here goes ..

Step 1: Install required applications

First we install Python Software properties package.

apt-get install python-software-properties

Kali Linux add PPA repository add-apt-repository - install python-software-properties - 1 - blackMORE Ops

Next we install apt-file

apt-get install apt-file

Kali Linux add PPA repository add-apt-repository - install apt-file - 2 - blackMORE Ops

Update apt-file.

apt-file update

Kali Linux add PPA repository add-apt-repository - update apt-file - 3 - blackMORE Ops

This takes a while, so in case your apt-file update is SLOW, you might want to try and fix that as well. (Note that I got repo.kali.org in my /etc/apt/sources.list file instead of http.kali.org.)

Once apt-file update is complete, you should be able to search for it.

apt-file search add-apt-repository

Kali Linux add PPA repository add-apt-repository - search apt-file - 4 - blackMORE Ops

Your output should look similar to this:

python-software-properties: /usr/bin/add-apt-repository
python-software-properties: /usr/share/man/man1/add-apt-repository.1.gz

 

Step 2: Use our own code for add-apt-repository

The default add-apt-repository application located in (/usr/bin/add-apt-repository) works for Debian. So if you’re using Kali, chances are it won’t work. There’s a nice fix for that which I will add at the bottom of this post, (try them on VirtualBox if you feel like). But I found we can just mimic Ubuntu Oneiric to make add-apt-repository work.

cd /usr/sbin
vi add-apt-repository

Kali Linux add PPA repository add-apt-repository - adding add-apt-repository code - 5 - blackMORE Ops

Add the following code and save the file.

#!/bin/bash
if [ $# -eq 1 ]
NM=`uname -a && date`
NAME=`echo $NM | md5sum | cut -f1 -d" "`
then
  ppa_name=`echo "$1" | cut -d":" -f2 -s`
  if [ -z "$ppa_name" ]
  then
    echo "PPA name not found"
    echo "Utility to add PPA repositories in your debian machine"
    echo "$0 ppa:user/ppa-name"
  else
    echo "$ppa_name"
    echo "deb http://ppa.launchpad.net/$ppa_name/ubuntu oneiric main" >> /etc/apt/sources.list
    apt-get update >> /dev/null 2> /tmp/${NAME}_apt_add_key.txt
    key=`cat /tmp/${NAME}_apt_add_key.txt | cut -d":" -f6 | cut -d" " -f3`
    apt-key adv --keyserver keyserver.ubuntu.com --recv-keys $key
    rm -rf /tmp/${NAME}_apt_add_key.txt
  fi
else
  echo "Utility to add PPA repositories in your debian machine"
  echo "$0 ppa:user/ppa-name"
fi

Note: In this line echo "deb http://ppa.launchpad.net/$ppa_name/ubuntu oneiric main" >> /etc/apt/sources.list I’ve used Oneiric. You can try to use Lucid, Raring or Saucy as per your choice.

Now chmod and chown the file.

Kali Linux add PPA repository add-apt-repository - chown and chmod add-apt-repository - 6 - blackMORE Ops

 

chmod o+x /usr/sbin/add-apt-repository 
chown root:root /usr/sbin/add-apt-repository

 

Step 3: Adding a PPA repository via add-apt-repository in Kali Linux

Now that we added the correct code, we can use add-apt-repository to add a PPA repository. I tried the following to add themes and custom icons in Kali Linux.

Kali Linux add PPA repository add-apt-repository - adding PPA Repository using add-apt-repository - 7 - blackMORE Ops

 

/usr/sbin/add-apt-repository ppa:noobslab/themes
/usr/sbin/add-apt-repository ppa:alecive/antigone

Once you’ve added a PPA repository via add-apt-repository in Kali Linux, you need to update your package list.

apt-get update

You’ll see that your package list is now including PPA repository.

 

Step 4: Testing

Now that we have added add-apt-repository to add PPA repository in Kali Linux, we can try to add some themes and custom icons. To keep things clean, I’ve moved this part in a different describing adding custom themes and icons in Kali Linux.

 

Step 5: Advanced Way

(Continued from Step 2: Paragraph 1)

In Step 2, paragraph 1, I pointed that we need to use our own code to use add-apt-repository. Following is a way to bypass that and use /usr/bin/add-apt-repositoryby modifying your Distribution ID. I again advise that you  try this part in Virtual Box so that you can roll back your changes.

Step 5.a Install Python Software Properties:

Install Python Software properties package.

apt-get install python-software-properties -y

 

Step 5.b Change Distribution ID, Release, Codename and Description

Change your Distribution ID to Ubuntu, Release to 12.04, Codename to Precise and Description to Ubuntu 12.04 LTS.

echo -e "DISTRIB_ID=Ubuntu\nDISTRIB_RELEASE=12.04\nDISTRIB _CODENAME=precise\nDISTRIB_DESCRIPTION="Ubuntu 12.04 LTS"" >> /etc/lsb-release

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION=”Ubuntu 12.04 LTS”

 

UPDATE: 27/02/2014 – Added code for Ubuntu Oneiric 11.10

 

echo -e "DISTRIB_ID=Ubuntu\nDISTRIB_RELEASE=11.10\nDISTRIB _CODENAME=oneiric\nDISTRIB_DESCRIPTION="Ubuntu 11.10"" >> /etc/lsb-release

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=11.10
DISTRIB_CODENAME=oneiric
DISTRIB_DESCRIPTION=”Ubuntu 11.10″

 

That mean’s now you can either use Precise or Oneiric codes as you feel like.

Kali Linux add PPA repository add-apt-repository - adding PPA Repository by modifying lsb_release details - 8 - blackMORE Ops

 

Now you should be able to add PPA just like normal.

 

Step 5.c Add PPA Repositories

Add PPA repositories using usual /usr/bin/add-apt-repository

add-apt-repository ppa:upubuntu-com/chat
apt-get update

 

Step 5.d Install something (i.e.Skype?)

Now we can install Skype..

apt-get install skype

 

Step 5.e Rollback changes

No change is much good without a rollback strategy.

To rollback your changes to Distribution ID, Release, Codename and Description, do the following,

echo -e "DISTRIB_ID=Debian\nDISTRIB_RELEASE=Kali Linux 1.0.6\nDISTRIB _CODENAME=n/a\nDISTRIB_DESCRIPTION="Debian GNU/Linux Kali Linux 1.0.6"" >> /etc/lsb-release

And to confirm, do another lsb_release -a

lsb_release -a

Output:

No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux Kali Linux 1.0.6
Release:    Kali Linux 1.0.6
Codename:   n/a

 

HUH .. GOTCHA …..

Just kidding… You don’t actually have to do it (well you could, but what’s the point to making things complicated). You could just delete /etc/lsb_release file that was created in Step 5.e.

rm /etc/lsb_release

We again do antther lsb_release -a to confirm.. See screenshot below:

Kali Linux add PPA repository add-apt-repository - adding PPA Repository by rollback lsb_release details - 9 - blackMORE Ops

Both ways works, but I prefer the second way where you delete /etc/lsb_release file. This file didn’t exist until we ran Step Step 5.e. So by deleting this file it doesn’t break or damage anything. So yes, just delete that file after you’ve installed whichever PPA you want.

 

Conclusion

As I’ve pointed in my first paragraph that by adding PPA repositories, you might break your system, so I will add a disclaimer here…

Disclaimer: This guide shows how to add PPA Repositories using add-apt-repository in Kali Linux that is usually not recommended. Readers should know how to repair their system and try these in Virtual Environment to avoid accidental breaks. We take no responsibility. Like Linux itself, you use these information’s as it is.

Thanks for reading.

If this worked for you, please share this article and like us on Facebook/Twitter.

 

Check Also

Enabling AMD GPU for Hashcat on Kali Linux: A Quick Guide

Enabling AMD GPU for Hashcat on Kali Linux: A Quick Guide

If you’ve encountered an issue where Hashcat initially only recognizes your CPU and not the …

How to fix You can’t access this shared folder because your organization’s security policies block unauthenticated guest access error on Windows 11

If you have the following error on Windows 11 “You can’t access this shared folder …

49 comments

  1. In step-2 “Add the following code and save the file.” How to save?

    • Hi Monir,
      You need to use an editor like vi or leafpad. I used vi. See screenshot

      • At Step3
        /usr/sbin/add-apt-repository ppa:noobslab/themes
        I met this problem
        /usr/sbin/add-apt-repository: line 1: f: command not found
        /usr/sbin/add-apt-repository: line 4: syntax error near unexpected token `then’
        /usr/sbin/add-apt-repository: line 4: `then’
        Need help? Thank

        • Hi Bluier,
          I think when you copy paste the code, your missed i in if .
          Correct code starts with
          if [ $# -eq 1 ]
          You’re getting an error /usr/sbin/add-apt-repository: line 1: f: command not found
          line 1: f: command not found <---- see what I mean? Try again. Good luck, -BMO

      • I must say, I’ve read almost all of your “tutorials” and you are terrible at elaborating. When Monir asked how to save, that obviously means that he got to a point at which he has added the info in VIM, Leafpad, or the terminal(that is the only way he could have gotten to the point at which he needs to save) and needs further clarification. To repeat yourself and tell him to look at your already posted screenshot showing nothing, is counterproductive and wastes not only your own time, but wastes Monirs time as well as the countless people who are reading this’ time. You are obviously not a baby and I obviously did not need to elaborate all of that to you, but I must say although you are undoubtedly very intelligent, your smartass comebacks only allow me to respect your work on the same level as a 3rd graders replication of his multiplication tables. Please elaborate more, we are not all Linux geniuses such as yourself.

        • Well, i think you don’t have to be a “Linux genius” to figure out how to write and save a file in this OS.
          This tutorial is very clear and precise. But it seems to be impossible to satisfy some people. Please don’t require to be spoon fed. BMO, keep up the good work!

        • Kory – I’m a linux BEGINNER! And even I could find out in 2 seconds how to save the page. I just replaced “vi” with “Gedit” and then was able to “File” and “Save” with gedit text editor. It would have taken a lot less time to find the answer on google, much less than the time it took for you to moan…….

  2. Step 3 didn’t work for me but big thanks !!!

    root@******:/usr/bin# ./add-apt-repository ppa:noobslab/themes
    You are about to add the following PPA to your system:
    themes uploaded on http://www.NoobsLab.com PPA
    For exact theme version and support visit on site and see themes page
    More info: https://launchpad.net/~noobslab/+archive/themes
    Press [ENTER] to continue or ctrl-c to cancel adding it

    Traceback (most recent call last):
    File “./add-apt-repository”, line 160, in
    sp = SoftwareProperties(options=options)
    File “/usr/lib/python2.7/dist-packages/softwareproperties/SoftwareProperties.py”, line 96, in __init__
    self.reload_sourceslist()
    File “/usr/lib/python2.7/dist-packages/softwareproperties/SoftwareProperties.py”, line 584, in reload_sourceslist
    self.distro.get_sources(self.sourceslist)
    File “/usr/lib/python2.7/dist-packages/aptsources/distro.py”, line 87, in get_sources
    raise NoDistroTemplateException(“Error: could not find a ”
    aptsources.distro.NoDistroTemplateException: Error: could not find a distribution template

    • Hi FrenchLiner,
      Depending on the PPA which might not be suitable for Ubuntu Oneiric, you need to change this code to match Lucid, Raring or Saucy as required. It’s added in the description just below the code.

      Note: In this line echo "deb http://ppa.launchpad.net/$ppa_name/ubuntu oneiric main" >> /etc/apt/sources.list I’ve used Oneiric. You can try to use Lucid, Raring or Saucy as per your choice.

      PPA has been always problematic for Kali. Have you tried the second method? Good Luck.
      -BMO

  3. i have a new tutorial abut how to add kali linux repositories to ubuntu, check here… http://ilhamsixx.blogspot.com/2014/05/how-to-add-repository-kali-linux-on.html

  4. At Step 3
    apt-get update
    I found this problem:

    …. …
    Ign http://http.kali.org kali/non-free Translation-pt_BR
    Ign http://http.kali.org kali/non-free Translation-pt
    Ign http://http.kali.org kali/non-free Translation-en
    Baixados 316 B em 10s (31 B/s)
    W: Falhou ao buscar http://security.kali.org/kali-security/dists/kali/updates/Release Incapaz de encontrar a entrada ‘non-freedeb/binary-amd64/Packages’ esperada no ficheiro Release (entrada errada em sources.list ou ficheiro malformado)

    E: Falhou o download de alguns ficheiros de índice. Foram ignorados ou os antigos foram usados em seu lugar.

    Can you help me ?

  5. root@smAsh:~# /usr/sbin/add-apt-repository ppa:noobslab/themes
    bash: /usr/sbin/add-apt-repository: /bin/bash^M: bad interpreter: No such file or directory
    root@smAsh:~# cd /usr/sbin
    root@smAsh:/usr/sbin# ./add-apt-repository ppa:noobslab/themes
    bash: ./add-apt-repository: /bin/bash^M: bad interpreter: No such file or directory

    Can’t figure it out, I guess…

    • Hi Ashleigh,
      Common mistake for the ones new to Shell programming, You need to add the whole lot .. i.e. #!/bin/bash .. I think you’ve only copy-pasted starting from /bin/bash and missed #! thinking that was just design .. ;-)
      Cheers,
      -BMO

  6. Hello blackMORE Ops,

    on step 3- I have this problem:
    everything is ok, just when i put order
    apt-get update
    give me this:

    W: Failed to fetch http://security.kali.org/kali-security/dists/kali/updates/Release Unable to find expected entry ‘non-freedeb/source/Sources’ in Release file (Wrong sources.list entry or malformed file)

    E: Some index files failed to download. They have been ignored, or old ones used instead.

    my sources.list is

    ## Regular repositories
    deb http://http.kali.org/kali kali main non-free contrib
    deb http://security.kali.org/kali-security kali/updates main contrib non-free
    ## Source repositories
    deb-src http://http.kali.org/kali kali main non-free contrib
    deb-src http://security.kali.org/kali-security kali/updates main contrib non-freedeb http://ppa.launchpad.net/noobslab/themes/ubuntu oneiric main
    deb http://ppa.launchpad.net/alecive/antigone/ubuntu oneiric main
    deb http://ppa.launchpad.net/noobslab/themes/ubuntu oneiric main
    deb http://ppa.launchpad.net/alecive/antigone/ubuntu oneiric main
    deb http://ppa.launchpad.net/noobslab/themes/ubuntu oneiric main

    and yes i did these orders twice:
    /usr/sbin/add-apt-repository ppa:noobslab/themes
    /usr/sbin/add-apt-repository ppa:alecive/antigone

    can you pls help me, how i can fix it up? Thanks

    • Answer provided in the comments above you.

      Fix this line:
      deb http://security.kali.org/kali-security kali/updates main contrib non-freedeb http://ppa.launchpad.net/noobslab/themes/ubuntu oneiric main
      Two lines overlapping with each other here.
      It should be

      deb http://security.kali.org/kali-security kali/updates main contrib non-free
      deb http://ppa.launchpad.net/noobslab/themes/ubuntu oneiric main

      • omg! of course! such a stupid mistake…THANKS A LOT!

        now it’s fix it up, it’s working good, just it stopped on step 5d – and saying:

        root@kali:~# apt-get install skype
        Reading package lists… Done
        Building dependency tree
        Reading state information… Done
        E: Unable to locate package skype

        i did exactly what is in tutorial and made double check. Have no idea, where could be mistake now.

        Anyway i did already 18-things-installing-kali and everything is working good, just this issue i can’t implement.
        anyway it’s very nicely done tutorial and thanks for it!

        • i have one more question pls:

          how can i setup and launch tor immediately after start the system automatically?

          service tor start // where i should put this ??

          thanks

          • Hi zzgero,

            Install chkconfig and use that to manipulate run levels

            apt-get install chkconfig

            Check current run level

            chkconfig -l tor

            Delete current runlevel

            chkconfig -d tor

            Add to run level

            chkconfig -a tor

            Finally confirm if it’s been added properly.

            chkconfig -l tor

            chkconfig works with any service that can have a run level. Cheers,
            -BMO

        • Hi again zzgero,

          Use this guide … it’s very detailed…
          Install Skype in Kali Linux
          Cheers,
          -BMO

  7. Hi BMO,

    i had some troubles with it – i left a message for you in the guide – Install Skype in Kali Linux…can you pls reply me? i’m just wondering, if is there any chance for fix it up and remove i386 from the system, or reinstall whole system Kali, or i can keep it the system and what it will mean for me, if i will keep it there…

    I have another question, if you can help me, how i can install on Kali Eclipse, or Netbeans and Wine (for playing poker). I already install BlueJ – no problem, but Eclipse it does not work – i dont know why…weird. I downloaded, then unpack and then start – it looks like it’s starting, but then suddenly stop it.

    Cheers

  8. Kory,
    That was rude and very offensive. This guy explains the best and if Monir doesn’t know how to use vi or leafpad, then it is his responsibility to learn it.
    Learn some manners and stop trolling.

  9. Hey thanks again for yet another problem solver! Do you have any tutorials on linux scripting, preferably written by you?

  10. Hi, I have tried to add ppa through your guide and all went well except when I wanted to do apt-get update, last line said …
    W: GPG error: http://ppa.launchpad.net oneiric Release: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY D530E028F59EAE4D

    Can you please help me fix this ?

    Thank you

  11. Ok this is a workaround … do not apply fixes found on ubuntu sites as it will break your Kali.

    Simply type the following commands in terminal, taking care to replace the number below with that of the key that was displayed in the error message:

    gpg –keyserver pgpkeys.mit.edu –recv-key D530E028F59EAE4D
    gpg -a –export D530E028F59EAE4D | sudo apt-key add –

  12. Hmm, I already left a comment but it seems it didn’t go through – don’t see it on another computer either. And I was praising your awesome Linux tips and how they’re one of the best on the web!

    Ok, again, my problem arises when I try to apply the permissions to the add-apt-repository – I’m getting a “No such file or directory’ error. In a desperate attempt I copied the file to /usr/sbin but it’s still not being found. However, the permissions are already root and r/w – and I am root.

    Here is the code from beginning to end:

    —> #!/usr/bin/python

    import os
    import sys
    import gettext
    import locale

    from softwareproperties.SoftwareProperties import SoftwareProperties
    from softwareproperties.ppa import DEFAULT_KEYSERVER, expand_ppa_line
    from softwareproperties import lp_application_name
    from aptsources.sourceslist import SourceEntry
    from optparse import OptionParser
    from gettext import gettext as _
    from urllib2 import HTTPError, URLError

    def utf8(s):
    “””
    Takes a string or unicode object and returns a utf-8 encoded
    string, errors are ignored
    “””
    if s is None:
    return None
    if isinstance(s, unicode):
    return s.encode(“utf-8”, “ignore”)
    return unicode(s, “utf8”, “ignore”).encode(“utf8”)

    def _maybe_suggest_ppa_name_based_on_user(user):
    try:
    from launchpadlib.launchpad import Launchpad
    lp = Launchpad.login_anonymously(lp_application_name, “production”)
    try:
    user_inst = lp.people[user]
    entity_name = “team” if user_inst.is_team else “user”
    if len(user_inst.ppas) > 0:
    print _(“The %s named ‘%s’ has no PPA named ‘%s'”
    %(entity_name, user, ppa_name))
    print _(“Please choose from the following available PPAs:”)
    for ppa in user_inst.ppas:
    print _(” * ‘%s’: %s” %(ppa.name, ppa.displayname))
    else:
    print _(“The %s named ‘%s’ does not have any PPA”
    %(entity_name, user))
    except KeyError:
    pass
    except ImportError:
    print _(“Please check that the PPA name or format is correct.”)

    def utf8(s):
    “””
    Takes a string or unicode object and returns a utf-8 encoded
    string, errors are ignored
    “””
    if s is None:
    return None
    if isinstance(s, unicode):
    return s.encode(“utf-8”, “ignore”)
    return unicode(s, “utf8”, “ignore”).encode(“utf8”)

    if __name__ == “__main__”:
    try:
    locale.setlocale(locale.LC_ALL, “”)
    except:
    pass
    usage = “””Usage: %prog

    %prog is a script for adding apt sources.list entries.
    It can be used to add any repository and also provides a shorthand
    syntax for adding a Launchpad PPA (Personal Package Archive)
    repository.

    – The apt repository source line to add. This is one of:
    a complete apt line in quotes,
    a repo url and areas in quotes (areas defaults to ‘main’)
    a PPA shortcut.

    Examples:
    apt-add-repository ‘deb http://myserver/path/to/repo stable myrepo’
    apt-add-repository ‘http://myserver/path/to/repo myrepo’
    apt-add-repository ‘https://packages.medibuntu.org free non-free’
    apt-add-repository http://extras.ubuntu.com/ubuntu
    apt-add-repository ppa:user/repository

    If –remove is given the tool will remove the given sourceline from your
    sources.list
    “””
    parser = OptionParser(usage)
    # FIXME: provide a –sources-list-file= option that
    # puts the line into a specific file in sources.list.d
    parser.add_option (“-m”, “–massive-debug”, action=”store_true”,
    dest=”massive_debug”, default=False,
    help=”Print a lot of debug information to the command line”)
    parser.add_option(“-r”, “–remove”, action=”store_true”,
    dest=”remove”, default=False,
    help=”remove repository from sources.list.d directory”)
    parser.add_option(“-k”, “–keyserver”,
    dest=”keyserver”, default=DEFAULT_KEYSERVER,
    help=”URL of keyserver. Default: %default”)
    parser.add_option(“-y”, “–yes”, action=”store_true”,
    dest=”assume_yes”, default=False,
    help=”Assume yes to all queries”)
    (options, args) = parser.parse_args()

    if os.geteuid() != 0:
    print _(“Error: must run as root”)
    sys.exit(1)

    if (len(args) != 1):
    print _(“Error: need a repository as argument”)
    sys.exit(1)

    # force new ppa file to be 644 (LP: #399709)
    os.umask(0022)

    # get the line
    line = args[0]

    # display PPA info (if needed)
    if line.startswith(“ppa:”) and not options.assume_yes:
    from softwareproperties.ppa import get_ppa_info_from_lp, LAUNCHPAD_PPA_API
    user, sep, ppa_name = line.split(“:”)[1].partition(“/”)
    ppa_name = ppa_name or “ppa”
    try:
    ppa_info = get_ppa_info_from_lp(user, ppa_name)
    except HTTPError:
    print _(“Cannot add PPA: ‘%s’.”) % line
    if user.startswith(“~”):
    print _(“Did you mean ‘ppa:%s/%s’ ?” %(user[1:], ppa_name))
    sys.exit(1) # Exit because the user cannot be correct
    # If the PPA does not exist, then try to find if the user/team
    # exists. If it exists, list down the PPAs
    _maybe_suggest_ppa_name_based_on_user(user)
    sys.exit(1)
    except (ValueError, URLError):
    print _(“Cannot access PPA (%s) to get PPA information, ”
    “please check your internet connection.”) % \
    (LAUNCHPAD_PPA_API % (user, ppa_name))
    sys.exit(1)
    # private PPAs are not supported
    if “private” in ppa_info and ppa_info[“private”]:
    print _(“Adding private PPAs is not supported currently”)
    sys.exit(1)

    if options.remove:
    print _(“You are about to remove the following PPA from your system:”)
    else:
    print _(“You are about to add the following PPA to your system:”)
    print ” %s” % utf8(ppa_info[“description”] or “”)
    print _(” More info: %s”) % ppa_info[“web_link”]
    if (sys.stdin.isatty() and
    not “FORCE_ADD_APT_REPOSITORY” in os.environ):
    if options.remove:
    print _(“Press [ENTER] to continue or ctrl-c to cancel removing it”)
    else:
    print _(“Press [ENTER] to continue or ctrl-c to cancel adding it”)
    sys.stdin.readline()

    # add it
    sp = SoftwareProperties(options=options)
    if options.remove:
    (line, file) = expand_ppa_line(line.strip(), sp.distro.codename)
    deb_line = sp.expand_http_line(line)
    debsrc_line = ‘deb-src’ + deb_line[3:]
    deb_entry = SourceEntry(deb_line, file)
    debsrc_entry = SourceEntry(debsrc_line, file)
    try:
    sp.remove_source(deb_entry)
    except ValueError:
    print _(“Error: ‘%s’ doesn’t exist in a sourcelist file” % deb_line)
    try:
    sp.remove_source(debsrc_entry)
    except ValueError:
    print _(“Error: ‘%s’ doesn’t exist in a sourcelist file” % debsrc_line)

    else:
    if not sp.add_source_from_line(line):
    print _(“Error: ‘%s’ invalid” % line)
    sys.exit(1)
    sp.sourceslist.save()

    #!/bin/bash
    if [ $# -eq 1 ]
    NM=`uname -a && date`
    NAME=`echo $NM | md5sum | cut -f1 -d” “`
    then
    ppa_name=`echo “$1″ | cut -d”:” -f2 -s`
    if [ -z “$ppa_name” ]
    then
    echo “PPA name not found”
    echo “Utility to add PPA repositories in your debian machine”
    echo “$0 ppa:user/ppa-name”
    else
    echo “$ppa_name”
    echo “deb http://ppa.launchpad.net/$ppa_name/ubuntu oneiric main” >> /etc/apt/sources.list
    apt-get update >> /dev/null 2> /tmp/${NAME}_apt_add_key.txt
    key=`cat /tmp/${NAME}_apt_add_key.txt | cut -d”:” -f6 | cut -d” ” -f3`
    apt-key adv –keyserver keyserver.ubuntu.com –recv-keys $key
    rm -rf /tmp/${NAME}_apt_add_key.txt
    fi
    else
    echo “Utility to add PPA repositories in your debian machine”
    echo “$0 ppa:user/ppa-name”
    fi <—

    Help?

  13. root@hatem:/usr/bin# /usr/bin/add-apt-repository ppa:noobslab/themes
    File “/usr/bin/add-apt-repository”, line 185
    if [ $# -eq 1 ]
    ^
    SyntaxError: invalid syntax

  14. So is there a specific reason why in your guide you state (in the screenshot) that you need to be in /usr/sbin/add-apt-repository to use add-apt-repository? I am asking because I used it outside of that particular directory and managed to have the key succussfully retrieved.

    • Hi Dops,
      Mostly because /bin, /usr/bin/, /usr/local/bin/, /usr/sbin/ or such locations usually contains binary files and you can just type in the binary name(add-apt-repository) directly to make it work.
      In this case, I didn’t wanted them in any of /bin folders cause it’s not an essential binary file. So I’ve chosen sbin which ideally should contain Non-essential binaries.
      Saying that, Linux/Unix filesystem hierarchy is quite messy. You can make it work from anywhere (i.e. /root) but then you have to type in the full path /root/add-apt-repository everytime.
      There’s no binding rule really, whatever works and makes sense to you. Cheers,
      -BMO.

  15. i want to remove ppa repository
    how can i remove it

  16. On this step
    Step 3: Adding a PPA repository via add-apt-repository in Kali Linux

    i did this first
    /usr/sbin# ./add-apt-repository ppa:noobslap/themesnoobslap/themesnoobslap/themesnoobslap/themes

    And it gave me this
    gpg: “1425567400” not a key ID: skipping
    gpg: “1425567400” not a key ID: skipping

    Second i tryed
    /usr/sbin# /usr/sbin/add-apt-repository ppa:noobslab/themesnoobslab/themes

    gpg: “1425567400” not a key ID: skipping
    gpg: “1425567400” not a key ID: skipping
    gpg: requesting key F59EAE4D from hkp server keyserver.ubuntu.com
    gpg: key F59EAE4D: public key “Launchpad PPA for NoobsLab” imported
    gpg: no ultimately trusted keys found
    gpg: Total number processed: 1
    gpg: imported: 1 (RSA: 1)

    3rd i tryed
    /usr/sbin# /usr/sbin/add-apt-repository ppa:alecive/antigonealecive/antigone

    gpg: “1425567400” not a key ID: skipping
    gpg: “1425567400” not a key ID: skipping
    gpg: requesting key F0B5D826 from hkp server keyserver.ubuntu.com
    gpg: key F0B5D826: public key “Launchpad antigone” imported
    gpg: Total number processed: 1
    gpg: imported: 1 (RSA: 1)

    The question i want to know is what have i done wrong because when i did apt-get update……..i got this @ da end of update

    Fetched 1,988 B in 18s (108 B/s)
    W: GPG error: http://security.kali.org kali/updates Release: The following signatures were invalid: KEYEXPIRED 1425567400 KEYEXPIRED 1425567400 KEYEXPIRED 1425567400
    W: GPG error: http://http.kali.org kali Release: The following signatures were invalid: KEYEXPIRED 1425567400 KEYEXPIRED 1425567400 KEYEXPIRED 1425567400
    W: Failed to fetch http://security.kali.org/kali-security/dists/kali/updates/non-freedeb/source/Sources 404 Not Found

    W: Failed to fetch http://security.kali.org/kali-security/dists/kali/updates/http://ppa.launchpad.net/noobslap/themesnoobslap/themes/ubuntu/source/Sources 404 Not Found

    W: Failed to fetch http://security.kali.org/kali-security/dists/kali/updates/oneiric/source/Sources 404 Not Found

    E: Some index files failed to download. They have been ignored, or old ones used instead.
    root@makaveli:/usr/sbin#

  17. Well written and thorough. Worked flawlessly and helped bunches. Thank you.

  18. Im sorry for stupid comment but i am a newbee … how to save add-apt-repository + (/usr/sbin) – VIM step by step no option for saving ?

  19. I try to do first step to install “apt-get install python-software-properties” but it said E: Package ‘python-software-properties’ has no installation candidate

  20. i try on step 1 “apt-get install python-software-properties”
    and i got this

    E: Could not get lock /var/lib/dpkg/lock – open (11: Resource temporarily unavailable)
    E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

    help me.. :(

  21. bash: vi: command not found

  22. vi add-apt-repository how to save that thing plese tell me ?

  23. Hi

    Thank you for this tutorial. I done the steps above and I think successfully add the “add-ppa-repository” but when I try to install skype using “apt-get install skype” I get this:

    root@kali:~# apt-get install skype
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Unable to locate package skype

    I seem all other packages have same result I try also to install cdemu using command below

    add-apt-repository ppa:cdemu/ppa
    apt-get update
    apt-get install gcdemu cdemu-client

    still can’t locate package.

    Hope you can help me with this.

  24. Hey, you have everything here I need! Awesome!! For some reason when I try and execute `apt-get install python-software-properties` I get the following…

    root@kali:~# apt-get install python-software-properties
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    Package python-software-properties is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsoleted, or
    is only available from another source
    However the following packages replace it:
    software-properties-common

    E: Package ‘python-software-properties’ has no installation candidate

    A little background on what I’m trying to accomplish; just trying to uninstall php7 and install php5.6 to use dvwa WITH Kali Linux, I guess php7 doesnt work with dvwa. So I’ve already used the command `apt-get purge `dpkg -l | grep php| awk ‘{print $2}’ |tr “\n” ” “`.. which successfully removed php7.0 to the best of my knowledge. When I used `php -v` I got nothin back so that seems to be good. But when I try to begin the installation of a repository I can’tget passed the first step.

    You’re the third or fourth person who s suggested doing it this way so I know there’s something up with how I’m going about this.

    Here are my specs if this helps,

    Linux kali 4.9.0-kali3-amd64 #1 SMP Debian 4.9.18-1kali1 (2017-04-04) x86_64 GNU/Linux

    Any help would be greatly appreciated

  25. How Can i Pest the code there is nothing that i can do….

  26. Hey I think I’d did everything and I’m in the /use/shin directory when I use the ./add-apt-repository command but I keep getting a permissions denied error.. any help is appreciated

Leave your solution or comment to help others.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from blackMORE Ops

Subscribe now to keep reading and get access to the full archive.

Continue reading

Privacy Policy on Cookies Usage

Some services used in this site uses cookies to tailor user experience or to show ads.