How to grant permission to edit files in Windows Subsystem Linux using Visual Code
You got an Error: EACCES: permission denied
error message because you tried to edit files owned by root in a GUI app (Visual Studio Code). Editing files owned by root in a GUI app can cause file corruption.
Open the terminal, change directories with cd /etc/apt/
and run the following command:
sudoedit sources.list
sudoedit opens nano editor in the terminal by default in Kali Linux. The instructions for using nano editor are always found at the bottom of every page. The only two nano keyboard shortcuts that you need to know are for WriteOut and Exit. Press the keyboard combination Ctrl+O and after that press Enter to save the file being edited. Press the keyboard combination Ctrl+X to exit nano.
Related videos on Youtube
Vedansh Agrawal
Updated on September 18, 2022Comments
-
Vedansh Agrawal over 1 year
I want to edit the \etc\apt\sources.list file in my Kali distro. I have the windows insider update and I am running WSL version 2. I have installed the vscode remote extension. When I try to save the file I edited, it shows me-
Failed to save 'sources.list'. Unable to write file (NoPermissions (FileSystemError): Error: EACCES: permission denied, open 'etc\apt\sources.list')
-
Vedansh Agrawal over 4 yearsThanks a ton for your help.
-
Blaizz over 4 yearsFor example to change the default editor from nano to vi run
sudo update-alternatives --config editor
and choose vi. After this,sudoedit
should open usingvi
. Please note that it should be a editor that runs in the terminal like nano or vi or you will get error messages. Also note that vi has so many keyboard shortcuts that new users get stuck because they can't remember them.