I'm attempting to add a file to my /etc/apt/sources.list.d folder and for some reason despite using sudo it still says permission denied. Here's the code I'm trying to run.
$ sudo cat >> /etc/apt/sources.listI've also tried simply using gedit but that doesn't work either.
11 Answer
You are running the cat command as root, but the output redirection takes place in your current shell which runs as your normal user account.
You have at least three options to achieve your goal of adding lines to your apt sources:
Running the whole command including output redirection in a separate Bash root shell:
sudo bash -c 'cat >> /etc/apt/sources.list'Using the
teecommand that copies output to a file (-aoption to append to instead of overwrite existing files) and running that as root:cat | sudo tee -a /etc/apt/sources.listUsing a terminal editor application like
nanoas root to modify the file:sudo nano /etc/apt/sources.list
However, it is recommended to leave your /etc/apt/sources.list file as it is and add additional sources by creating new *.list files inside /etc/apt/sources.list.d/.