permission denied: /etc/apt/sources.list
This is a known issue, when you use sudo
in this fashion, it won't work right. That is because while the echo
command is run as sudo
, the >>
for append tries to open the file target as a non-sudo
user. That is where the permission issue is.
However, please read my multi-part answer, which gives you a separate solution that can be considered more 'safe' than the others I provide:
1:
Use a separate file in /etc/apt/sources.list.d/
which contains the deb instruction you're saying now. You'd still need to use sudo
, though, to edit / create the file.
2:
A solution would be to do sudo su -c "echo 'deb http://www.duinsoft.nl/pkg debs all' >> /etc/apt/sources.list"
, which tells the system to run that as superuser, which you get access to by using 'sudo' in front of the 'su' command.
PLEASE NOTE that the su
command used outside of the command I stated here is dangerous, so you should only use this method if you absolutely need it. Therefore, consider using Solution #3 here instead.
Safest Solution (#3): Use echo | sudo tee
AND a separate .list
You can achieve the same as the above, however, without ever dropping to a superuser prompt though. With this command:
echo 'deb http://www.duinsoft.nl/pkg debs all' | sudo tee -a /etc/apt/sources.list
However, let's also take into account #1 above, and instead use a new file for it:
sudo touch /etc/apt/sources.list.d/duinsoft.list
echo 'deb http://www.duinsoft.nl/pkg debs all' | sudo tee -a /etc/apt/sources.list.d/duinsoft.list
This way, we leave the main sources.list
alone, but the sources will be added via an included file that specifically handles this repository. (This is how PPAs get added, by the way!)
What happens with the command is that echo
is run as root, but not >>
. Try the following instead:
echo 'deb http://www.duinsoft.nl/pkg debs all' | sudo tee -a /etc/apt/sources.list
alternatively, you could do it in two steps:
sudo -i
echo 'deb http://www.duinsoft.nl/pkg debs all' >> /etc/apt/sources.list
exit
What this command does is appending deb http://www.duinsoft.nl/pkg debs all
to /etc/apt/sources.list
. Let's do it in an other method! Just open that file and append it manually!
sudo nano /etc/apt/sources.list
Then add deb http://www.duinsoft.nl/pkg debs all
to end of it and press Ctrl + O
and then ENTER to save the changes and finally Ctrl + X
to quit nano
.
You can jump to the next command now...