How do I add a line to my /etc/apt/sources.list?

Make a backup copy of your current sources.list file

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

Append new line of text to current sources.list file

  • CLI

    echo "new line of text" | sudo tee -a /etc/apt/sources.list
    
  • GUI (Text Editor)

    sudo gedit /etc/apt/sources.list
    
  • Paste new line of text on new line at end of current sources.list text file in Text Editor.

  • Save and close sources.list

Don't forget to update in order to use the new repository

sudo apt-get update

In order to add a third-party repository, you first need the public keys for this repository which in this case you can grab from the Ubuntu key server:

sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 886DDD89

Now you can add the repository in /etc/apt/sources.list.d/ with add-apt-repository:

sudo add-apt-repository "deb http://deb.torproject.org/torproject.org $(lsb_release -s -c) main"

After adding any repository it is always needed to execute

sudo apt-get update

Now you can install the package for Tor itself. For complete instructions on how to install Tor correctly, see How to install Tor?

This procedure can also be reversed.