I don't know the reasoning behind it, but sudo just doesn't work for this case. This used to trip me up - as it did you - when adding repos. I can't find any other "limitations" of sudo so I'm not sure if this is an unintentional bug or a misunderstanding on my part as to a feature of sudo.
Anyways, there are two other ways you can accomplish the same thing:
1. Switch user to root (don't stay as root any longer than you have to - in this case, only long enough to add the repo)
Code: Select all
sudo su
echo 'what i want to right in the file' > /etc/apt/sources.list.d/my_file_name
2. Run the original code through sh
Code: Select all
sudo sh -c "echo 'what i want to right in the file' > /etc/apt/sources.list.d/my_file_name"
Now you mention wanting to learn, so a couple of things to point out here:
Most importantly, don't just run random code in your terminal, especially as root (with sudo or su, or any variants like gksudo). The terminal is one of, if not the, most powerful tools in desktop Linux. With it you can make clean, surgical incisions and stitch your system back together elegantly, or you can bludgeon it beyond all recognition. Be careful, know what you type, and always think twice!
Close behind it - don't add random repositories to Mint/LMDE. You have a nice clean system, free of malware and nasties. By adding a repo, you add the
potential for abuse. So think carefully and don't add the repository if you don't trust the provider!
Also, even if you know the code you are typing in your terminal, don't do it as root (with sudo/su/gksudo/gksu/kdesudo...) unless absolutely necessary! If you are not running as super user, then you can't damage your system nearly as badly if you do slip up and make a serious mistake in terminal. Example: running
rm -rf /*
will only erase everything in your home directory and a few other places, but
sudo rm -rf /*
will wreck your system beyond any hope of recovery.
Note: do not try these commands! I mention them only as an example of the dangers of using "sudo" unthinkingly. They will delete your files irrevocably!
Make sure when you add a real repository in /etc/apt/sources.list.d/, that the file name ends in ".list". So not "my_file_name" but "my_file_name.list".
Cheers and happy learning!
Fred
EDIT: corrected "source.list.d" to "sources.list.d". Thanks Flemur!