0

Sorry for the newb question. I'm trying to add a repository to my ubuntu machine:

 $ sudo curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
 <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOFE: This command can only be used by root.
(23) Failed writing body
$ cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
> deb https://apt.kubernetes.io/ kubernetes-xenial main
> EOF^C

But the command is 'breaking' in half when I try to run it by pasting it into the terminal. I'm having trouble with the cat EOF part of the command.

This is the command that I want to run:

sudo curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF

This is on Ubuntu 20.04 LTS (Focal Fossa).

cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.1 LTS"

How can I get this working?

Tim Dunphy
  • 103
  • 3
  • Not available for releases over xenial https://packages.cloud.google.com/apt/dists there is no folder for focal there. – nobody Jan 31 '21 at 08:42
  • 4
    Does this answer your question? [This command can only be used by root](https://askubuntu.com/questions/845534/this-command-can-only-be-used-by-root) You don't need `sudo` with `curl` but with `apt-key`. – Kulfy Jan 31 '21 at 09:27

1 Answers1

0

It looks like you should be using 2 distinct commands. cat and apt-key commands are distinct.

Further, the cat command serves only to automatically create the proper sources.list file. You can just copy-paste the text into the specified file if you have access to any sort of text editor.

Just run the cat command separately from the apt-key command and you'll be golden.

Kulfy
  • 17,416
  • 26
  • 64
  • 103
Calum McConnell
  • 429
  • 3
  • 6