Linux change apt sources

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

echo "new line of text" | sudo tee -a /etc/apt/sources.list 
sudo gedit /etc/apt/sources.list 

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

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

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.

@hudolejev how do you specify a file in the /etc/apt/sources.list.d/ using the command add-apt-repository ? From the man page I can not figure it out it seems like it happens magically, however when using that command I keep seeing lines added to the file /etc/apt/sources.list instead

@TPPZ my previous comment is 6 years old, I don’t quite remember the context. Maybe it was and answer to some other comment that is now deleted :/ Anyways, seems that add-apt-repository will only create separate files in sources.list.d for PPA repos, for others it will update sources.list : manpages.ubuntu.com/manpages/bionic/man1/…

Читайте также:  Zipping directory in linux

Go to Ubuntu Software Centre > Edit > Software Sources > Add

Paste the line from the Tor website into the APT line box.

You could also manually edit /etc/apt/sources.list , but probably simplest to go through the Software Centre.

Make sure to input the line correctly as well, e.g.

deb http://deb.torproject.org/torproject.org precise main 

if you’re using 12.04. If something goes wrong edit /etc/apt/sources.list to fix it.

First, make a backup. You can do so with:

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

in the Terminal. Give your password and press Enter. It will not be shown, not even asterisks. Then run:

gksudo gedit /etc/apt/sources.list 
 deb http://deb.torproject.org/torproject.org main 

to the bottom of the file and use File->Save to save it.

Then, go back to the terminal and run:

and then continue following the instructions. This command and the one starting in sudo apt-get install may take a while. Additionally, the install command may give a:

Do you want to continue[y/n]? 

prompt, where you must type y and press Enter to continue.

You need not to edit default /etc/apt/sources.list , you better upgrade your Ubuntu to Saucy. Here Tor is in the official repository.

deb http://us-west-2.ec2.archive.ubuntu.com/ubuntu/ saucy main restricted universe multiverse deb http://us-west-2.ec2.archive.ubuntu.com/ubuntu/ saucy-updates main restricted universe multiverse deb http://us-west-2.ec2.archive.ubuntu.com/ubuntu/ saucy-backports main restricted universe multiverse deb http://us-west-2.ec2.archive.ubuntu.com/ubuntu/ saucy-security main restricted universe multiverse 

I’m able to download and install the Tor package:

# aptitude download tor Get: 1 http://us-west-2.ec2.archive.ubuntu.com/ubuntu/ saucy/universe tor amd64 0.2.3.25-1 [953 kB] 84% [1 tor 799 kB/953 kB 84%]201 URI Done: http://us-west-2.ec2.archive.ubuntu.com/ubuntu/pool/universe/t/tor/tor_0.2.3.25-1_amd64.deb RecivedHash: MD5Sum:1cb3ed029c169c3a5e528dd7d28cc60f ExpectedHash: MD5Sum:1cb3ed029c169c3a5e528dd7d28cc60f Fetched 953 kB in 4s (198 kB/s) 

Источник

How To Change Ubuntu Repository Mirror Sources

If you find your download is slow from a certain Ubuntu mirror, you can change your download source to another mirror. This change is usually necessary if your place is too far to the download source (or, if the network latency is too high). This article discusses how to do it with example from original server (in United States) to a mirror (in Indonesia). You may choose either one of two ways explained below. This is applicable for all Ubuntu versions including 18.04.

Читайте также:  Установка iso образа linux

1. Automatic Way

The automatic way eases you by using click and run rather than command lines. In this example we will change the mirror from originally United States archive.ubuntu.com to Indonesia kartolo.sby.datautama.net.id.

Open up your menu and run Software & Updates.

Change the selection of «Download from:» into Other.

From the small dialog appears, select kartolo.sby.datautama.net.id from the mirrors of Indonesia.

Press Reload button and let it say «Updating cache» meaning re-downloading the new mirror addresses.

2. Manual Way

In this example, we want to change the mirror from originally archive.ubuntu.com to Indonesia kambing.ui.ac.id (by University of Indonesia).

List of Ubuntu mirrors available to you to use is available in https://launchpad.net/ubuntu/+archivemirrors.

Change URL Addresses

Change original URL addresses in /etc/apt/sources.list into the desired ones. The easiest way to do this is by using nano. Remember, in nano, Ctrl+O = save as, Ctrl+X = exit, and Ctrl+\ = find and replace.

  • $ sudo nano /etc/apt/sources.list
  • Copy the http URL from University of Indonesia above
  • Change all URL from archive.ubuntu.com/ubuntu into the copied URL
  • See example below:

Reload

This article is licensed under CC BY-SA 3.0.

Источник

How to change download source for apt

Ubuntu, by default, will use the apt repository local to the country you set when installing your Ubuntu system. There are repositories set up for each country, where the URL are differentiated based on the 2 characters (Alpha-2) country code. Some repositories are not country-specific that you can also use, and it’s possible even to set one up on your own.

Multiple apt repositories ensure the main repository is not overwhelmed by global requests and for a more seamless user experience, as local repositories are generally faster than those in foreign countries due to network latency.

Читайте также:  Install github linux mint

You might want to change the source for your apt repository for any technical (bandwidth issues) or non-technical (corporate policy) reasons. You can do that by updating the apt repository source file from the terminal.

Steps to change apt source in Ubuntu:

$ sudo cp -a /etc/apt/source.list /etc/apt/source.list.bak [sudo] password for user:
$ sudo sed -i "s/\/jp\./\/us\./g" /etc/apt/sources.list
$ sudo apt update Hit:1 http://ports.ubuntu.com/ubuntu-ports kinetic-security InRelease Get:2 http://us.ports.ubuntu.com/ubuntu-ports kinetic InRelease [267 kB] Get:3 http://us.ports.ubuntu.com/ubuntu-ports kinetic-updates InRelease [90.7 kB] Get:4 http://us.ports.ubuntu.com/ubuntu-ports kinetic-backports InRelease [90.7 kB] Get:5 http://us.ports.ubuntu.com/ubuntu-ports kinetic/main arm64 Packages [1,363 kB] ##### snipped
$ sudo apt dist-upgrade --assume-yes

Источник

oezeb / linux-change-apt-repository.md

Edit /etc/apt/sources.list and change the current source host with the desired mirror host.

deb http://deb.debian.org/debian/ bullseye main deb-src http://deb.debian.org/debian/ bullseye main deb http://security.debian.org/debian-security bullseye-security main contrib deb-src http://security.debian.org/debian-security bullseye-security main contrib deb http://deb.debian.org/debian/ bullseye-updates main contrib deb-src http://deb.debian.org/debian/ bullseye-updates main contrib 

replacing deb.debian.org with mirrors.ustc.edu.cn

deb http://mirrors.ustc.edu.cn/debian/ bullseye main deb-src http://mirrors.ustc.edu.cn/debian/ bullseye main deb http://mirrors.ustc.edu.cn/debian-security bullseye-security main contrib deb-src http://mirrors.ustc.edu.cn/debian-security bullseye-security main contrib deb http://mirrors.ustc.edu.cn/debian/ bullseye-updates main contrib deb-src http://mirrors.ustc.edu.cn/debian/ bullseye-updates main contrib 
# Edit following mirror hostname and run MIRROR="mirrors.ustc.edu.cn" SOURCES="/etc/apt/sources.list" URL_REGEX=r'(?:https?:\/\/)?([(www\.)?a-zA-Z0-9@:%._\+~#=]\.[a-z])\b(?:[-a-zA-Z0-9@:%_\+.~#?&//=]*)' REPL=lambda match: match.group(0).replace(match.group(1), MIRROR) import re with open(SOURCES) as f: data, _ = re.subn(URL_REGEX, REPL, f.read(), flags=re.I) with open(SOURCES, 'w') as f: f.write(data)

Источник

Оцените статью
Adblock
detector