I want to install Go-Servre on my Ubuntu 14.04and I'm following this doc http://www.go.cd/documentation/user/current/installation/install/server/linux.html#debian-based-distributions-ie-ubuntu

According to the doc this is the procedure:

$ echo "deb http://dl.bintray.com/gocd/gocd-deb/ /" > /etc/apt/sources.list.d/gocd.list
$ wget --quiet -O - "https://bintray.com/user/downloadSubjectPublicKey?username=gocd" | sudo apt-key add -
$ apt-get update
$ apt-get install go-server

However, I have problem in first line when I run the command and I get following reply:

$ echo "deb http://dl.bintray.com/gocd/gocd-deb/ /" > /etc/apt/sources.list.d/gocd.list
bash: /etc/apt/sources.list.d/gocd.list: Permission denied

I even tried to change the permission but still I'm getting error:

$ sudo chmod +x  /etc/apt/sources.list.d/gocd.list
[sudo] password for hesam: 
chmod: cannot access ‘/etc/apt/sources.list.d/gocd.list’: No such file or directory

Any idea would be appreciated. Thanks.

  • @muru Thanks, I found the solution based on your link.
    – Hesam
    Nov 27, 2015 at 6:49

2 Answers 2


You should run the first (echo ...) command as a privileged user. So first switch to root by sudo su, then run the echo command.

Doing sudo echo ... will not work, as the > redirection will be done before sudo is executed.

  • Thanks for "...the > redirection will be done before sudo is executed." didn't know that.
    – Hesam
    Nov 27, 2015 at 16:48

Permission is denied because you are trying to create a file in a privileged location. And sudo echo doesn't work. However, there is a way to work around this problem.

You can use either of the following commands to accomplish the first step:

echo "deb http://dl.bintray.com/gocd/gocd-deb/ /" | sudo tee /etc/apt/sources.list.d/gocd.list


sudo sh -c 'echo "deb http://dl.bintray.com/gocd/gocd-deb/ /" > /etc/apt/sources.list.d/gocd.list'

Not the answer you're looking for? Browse other questions tagged or ask your own question.