{"id":24212,"date":"2024-01-31T14:05:33","date_gmt":"2024-01-31T14:05:33","guid":{"rendered":"https:\/\/linuxways.net\/?p=24212"},"modified":"2024-01-31T14:05:33","modified_gmt":"2024-01-31T14:05:33","slug":"fix-zsh-permission-denied-etc-apt-sources-list-error-kali-linux","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/kali-linux\/fix-zsh-permission-denied-etc-apt-sources-list-error-kali-linux\/","title":{"rendered":"How to Fix zsh: permission denied: \/etc\/apt\/sources.list Error on Kali Linux"},"content":{"rendered":"<p><strong>Zsh <\/strong>is a default shell on the <strong>Kali Linux <\/strong>system that allows you to run commands and perform your required tasks with ease. However, while working on <strong>Zsh <\/strong>in <strong>Kali Linux<\/strong>, you may encounter <strong>\u201czsh: permission denied: \/etc\/apt\/sources.list\u201d <\/strong>error while adding a repository to the system repository list. This type of error occurs when you try to modify the system <strong>sources.list<\/strong> file without sufficient privileges. It prevents you from adding the required repository, thus you won\u2019t be able to install the required application or package on your system.<\/p>\n<p>Worry not, read this guide for finding how to fix the <strong>\u201czsh: permission denied: \/etc\/apt\/sources.list\u201d <\/strong>error on <strong>Kali Linux <\/strong>system.<\/p>\n<h2><strong>Quick Outline<\/strong><\/h2>\n<ul>\n<li><a href=\"#post-24212-2tp086d90426\"><strong>Why \u201czsh: permission denied: \/etc\/apt\/sources.list\u201d Error Occurs <\/strong><\/a><\/li>\n<li><a href=\"#post-24212-1bgnrueek6nk\"><strong>How to Fix \u201czsh: permission denied: \/etc\/apt\/sources.list\u201d Error on Kali Linux<\/strong><\/a><\/li>\n<li><a href=\"#post-24212-aca9qv8we568\"><strong>Conclusion <\/strong><\/a><\/li>\n<\/ul>\n<h2><a id=\"post-24212-2tp086d90426\"><\/a><strong>Why \u201czsh: permission denied: \/etc\/apt\/sources.list\u201d Error Occurs <\/strong><\/h2>\n<p>When you add a repository with <strong>echo<\/strong> command followed by repository URL into the source repository with sudo privileges, you will encounter the following error:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw3\">echo<\/span> <span class=\"st_h\">'deb http:\/\/www.duinsoft.nl\/pkg debs all'<\/span> <span class=\"sy0\">&gt;&gt;<\/span> <span class=\"sy0\">\/<\/span>etc<span class=\"sy0\">\/<\/span>apt<span class=\"sy0\">\/<\/span>sources.list<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"664\" height=\"158\" class=\"wp-image-24280\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-1.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-1.png 664w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-1-300x71.png 300w\" sizes=\"auto, (max-width: 664px) 100vw, 664px\" \/><\/p>\n<p>This error occurs because users don&#8217;t have required permission to add the repository even with the sudo privileges. It is because the <strong>sources.list <\/strong>file can be modified only by the root user. You can use the <strong>ls <\/strong>command provide below to check for the necessary permission for<strong> sources.list<\/strong> file:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">ls<\/span> <span class=\"re5\">-l<\/span> <span class=\"sy0\">\/<\/span>etc<span class=\"sy0\">\/<\/span>apt<span class=\"sy0\">\/<\/span>sources.list<\/div><\/div>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"658\" height=\"130\" class=\"wp-image-24287\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-2.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-2.png 658w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-2-300x59.png 300w\" sizes=\"auto, (max-width: 658px) 100vw, 658px\" \/><\/p>\n<p>When you run the <strong>sudo<\/strong> command with <strong>echo<\/strong> mode, the echo command will run as a root but the command to append the repository to <strong>sources.list<\/strong> file is run as a normal user. Thus, due to conflict and requiring permission issues, you will experience that kind of error.<\/p>\n<h2><a id=\"post-24212-1bgnrueek6nk\"><\/a><strong>How to Fix \u201czsh: permission denied: \/etc\/apt\/sources.list\u201d Error on Kali Linux<\/strong><\/h2>\n<p>To fix the <strong>\u201czsh: permission denied: \/etc\/apt\/sources.list\u201d <\/strong>error on <strong>Kali Linux<\/strong>, you can:<\/p>\n<ul>\n<li><a href=\"#post-24212-8pkheue19tp0\"><strong>Run tee Command with sudo Privileges<\/strong><\/a><\/li>\n<li><a href=\"#post-24212-bqoo3k6asqu\"><strong>Manually Add Repository Inside the sources.list File<\/strong><\/a><\/li>\n<li><a href=\"#post-24212-kdzskmsw0os\"><strong>Create a Separate File<\/strong><\/a><\/li>\n<li><a href=\"#post-24212-8ihoud2257cr\"><strong>Add a Repository as a Root User<\/strong><\/a><\/li>\n<li><a href=\"#post-24212-ocp46zm5c5rw\"><strong>Create a Script<\/strong><\/a><\/li>\n<\/ul>\n<h3><a id=\"post-24212-8pkheue19tp0\"><\/a><strong>1: Run tee Command with sudo Privileges <\/strong><\/h3>\n<p>The most straightforward approach to fix \u201c<strong>zsh: permission denied: \/etc\/apt\/sources.list<\/strong>\u201d error is to run the echo command as a root user, and giving the sudo privileges to <strong>tee<\/strong> command, as shown below:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw3\">echo<\/span> <span class=\"st_h\">'deb http:\/\/www.duinsoft.nl\/pkg debs all'<\/span> <span class=\"sy0\">|<\/span> <span class=\"kw2\">sudo<\/span> <span class=\"kw2\">tee<\/span> <span class=\"re5\">-a<\/span> <span class=\"sy0\">\/<\/span>etc<span class=\"sy0\">\/<\/span>apt<span class=\"sy0\">\/<\/span>sources.list<\/div><\/div>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"667\" height=\"148\" class=\"wp-image-24295\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-3.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-3.png 667w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-3-300x67.png 300w\" sizes=\"auto, (max-width: 667px) 100vw, 667px\" \/><\/strong><\/p>\n<h3><a id=\"post-24212-bqoo3k6asqu\"><\/a><strong>2: Manually Add Repository Inside the sources.list File<\/strong><\/h3>\n<p>Another approach to fix the \u201c<strong>zsh: permission denied: \/etc\/apt\/sources.list<\/strong>\u201d error is to open the <strong>sources.list <\/strong>file with root privileges. This allows you to edit the <strong>sources.list <\/strong>file, such as adding a repository according to your choice. You can open <strong>sources.list <\/strong>file on <strong>Kali Linux <\/strong>via nano editor from the provided command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">nano<\/span> <span class=\"sy0\">\/<\/span>etc<span class=\"sy0\">\/<\/span>apt<span class=\"sy0\">\/<\/span>sources.list<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"655\" height=\"456\" class=\"wp-image-24306\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-4.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-4.png 655w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-4-300x209.png 300w\" sizes=\"auto, (max-width: 655px) 100vw, 655px\" \/><\/p>\n<p>After the changes, you can save the file using <strong>CTRL+X<\/strong>, approve the changes using <strong>Y <\/strong>and close the file using the <strong>Enter <\/strong>button<strong>. <\/strong>Once done, update the repository on <strong>Kali Linux<\/strong> using the following command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> apt update<\/div><\/div>\n<h3><a id=\"post-24212-kdzskmsw0os\"><\/a><strong>3: Create a Separate File<\/strong><\/h3>\n<p>Besides editing the main source file, you can also fix the \u201c<strong>zsh: permission denied: \/etc\/apt\/sources.list<\/strong>\u201d error by creating a separate file on <strong>Kali Linux<\/strong>. It can be done from the below-given <strong>touch <\/strong>command that creates a <strong>repository.list<\/strong> file inside the<strong> sources.list.d<\/strong> location:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">touch<\/span> <span class=\"sy0\">\/<\/span>etc<span class=\"sy0\">\/<\/span>apt<span class=\"sy0\">\/<\/span>sources.list.d<span class=\"sy0\">\/<\/span>duinsoft.list<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"663\" height=\"66\" class=\"wp-image-24313\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-5.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-5.png 663w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-5-300x30.png 300w\" sizes=\"auto, (max-width: 663px) 100vw, 663px\" \/><\/p>\n<p>Then adding the repository to <strong>Kali Linux<\/strong> source repository location by running echo as a root user and tee command with the sudo privileges:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw3\">echo<\/span> <span class=\"st_h\">'deb http:\/\/www.duinsoft.nl\/pkg debs all'<\/span> <span class=\"sy0\">|<\/span> <span class=\"kw2\">sudo<\/span> <span class=\"kw2\">tee<\/span> <span class=\"re5\">-a<\/span> <span class=\"sy0\">\/<\/span>etc<span class=\"sy0\">\/<\/span>apt<span class=\"sy0\">\/<\/span>sources.list.d<span class=\"sy0\">\/<\/span>duinsoft.list<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"666\" height=\"102\" class=\"wp-image-24318\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-6.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-6.png 666w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-6-300x46.png 300w\" sizes=\"auto, (max-width: 666px) 100vw, 666px\" \/><\/p>\n<p>By doing this process, you are leaving the main <strong>sources.list <\/strong>file alone, however, it will add the sources through an included file that will handle the added repository.<\/p>\n<h3><a id=\"post-24212-8ihoud2257cr\"><\/a><strong>4: Add a Repository as a Root User<\/strong><\/h3>\n<p>Besides adding the repository inside the <strong>sources.list<\/strong> file with root privileges, you can manually enter the system as a root user using the following command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">su<\/span><\/div><\/div>\n<p>Then add the required repository using the echo command without giving sudo privileges:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw3\">echo<\/span> <span class=\"st_h\">'deb http:\/\/www.duinsoft.nl\/pkg debs all'<\/span> <span class=\"sy0\">&gt;&gt;<\/span> <span class=\"sy0\">\/<\/span>etc<span class=\"sy0\">\/<\/span>apt<span class=\"sy0\">\/<\/span>sources.list<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"662\" height=\"185\" class=\"wp-image-24327\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-7.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-7.png 662w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-7-300x84.png 300w\" sizes=\"auto, (max-width: 662px) 100vw, 662px\" \/><\/p>\n<p>Further, you can also manually add the repository as root user by using the sudo<strong> su<\/strong> command followed by the<strong> -c<\/strong> argument:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">su<\/span> <span class=\"re5\">-c<\/span> <span class=\"st0\">&quot;echo 'deb http:\/\/www.duinsoft.nl\/pkg debs all' &gt;&gt; \/etc\/apt\/sources.list&quot;<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"665\" height=\"144\" class=\"wp-image-24333\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-8.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-8.png 665w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-8-300x65.png 300w\" sizes=\"auto, (max-width: 665px) 100vw, 665px\" \/><\/p>\n<h3><a id=\"post-24212-ocp46zm5c5rw\"><\/a><strong>5: Create a Script File<\/strong><\/h3>\n<p>You can also create a script file in <strong>Kali Linux<\/strong>, add the repository command, and then run the script to add the required repository to the source repository location. The complete process can be followed using the following steps:<\/p>\n<p><strong>Step 1:<\/strong> First, create a script file in Kali Linux with <strong>.sh<\/strong> extension using nano editor from the below command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">nano<\/span> script.sh<\/div><\/div>\n<p>Inside the script file, first add the bash line:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"co0\">#!\/bin\/bash<\/span><\/div><\/div>\n<p>Then add the repository with the echo command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw3\">echo<\/span> <span class=\"st_h\">'deb http:\/\/www.duinsoft.nl\/pkg debs all'<\/span> <span class=\"sy0\">&gt;&gt;<\/span> <span class=\"sy0\">\/<\/span>etc<span class=\"sy0\">\/<\/span>apt<span class=\"sy0\">\/<\/span>sources.list<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"652\" height=\"456\" class=\"wp-image-24340\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-9.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-9.png 652w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-9-300x210.png 300w\" sizes=\"auto, (max-width: 652px) 100vw, 652px\" \/><\/p>\n<p>Once done, save the script file using <strong>CTRL+X<\/strong>, then add <strong>Y<\/strong> for approving the changes and press <strong>Enter<\/strong> to close the file:<\/p>\n<p><strong>Step 2: <\/strong>Then give execute permission to the script file you created in the previous steps, it can be done using the <strong>chmod <\/strong>command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">chmod<\/span> +x script.sh<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"663\" height=\"117\" class=\"wp-image-24347\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-10.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-10.png 663w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-10-300x53.png 300w\" sizes=\"auto, (max-width: 663px) 100vw, 663px\" \/><\/p>\n<p><strong>Step 3: <\/strong>Now, run the script file with sudo privileges to successfully add the repository to the system:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> .<span class=\"sy0\">\/<\/span>script.sh<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"663\" height=\"137\" class=\"wp-image-24356\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-11.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-11.png 663w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24212-11-300x62.png 300w\" sizes=\"auto, (max-width: 663px) 100vw, 663px\" \/><\/p>\n<p>In this way, you can fix the \u201c<strong>zsh: permission denied: \/etc\/apt\/sources.list<\/strong>\u201d error on Kali Linux system.<\/p>\n<h2><a id=\"post-24212-aca9qv8we568\"><\/a><strong>Conclusion<\/strong><\/h2>\n<p><strong>\u201czsh: permission denied: \/etc\/apt\/sources.list\u201d <\/strong>error occurs in a system because a normal user doesn\u2019t have permission to make changes to the source repository file. If you are using the <strong>Kali Linux <\/strong>system and encounter this error, you can fix it by running the tee command with sudo privileges. Besides that, you can manually add a repository or consider a separate file for adding repository. Alternatively, you can also add the repository by login as a root user or create a script, add the repository and execute the script to successfully add the repository to the <strong>Kali Linux<\/strong> system. A detailed description of all five methods are presented in the above-section of this guide.<\/p>","protected":false},"excerpt":{"rendered":"<p>The zsh: permission denied: \/etc\/apt\/sources.list occurs on Kali Linux because of permission issue to the source repository file. Read this guide to fix it.<\/p>","protected":false},"author":116,"featured_media":24463,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1054],"tags":[],"class_list":["post-24212","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-kali-linux"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/24212","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/116"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=24212"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/24212\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/24463"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=24212"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=24212"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=24212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}