{"id":3116,"date":"2026-04-06T10:39:16","date_gmt":"2026-04-06T08:39:16","guid":{"rendered":"https:\/\/deepdocs.dev\/?p=3116"},"modified":"2026-04-25T08:50:12","modified_gmt":"2026-04-25T06:50:12","slug":"bash-permission-denied","status":"publish","type":"post","link":"https:\/\/deepdocs.dev\/bash-permission-denied\/","title":{"rendered":"Mastering Bash Permission Denied: An Expert&#8217;s Guide for 2026"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">If you\u2019ve spent any time in a terminal, the <code>bash: permission denied<\/code> message is an old, unwelcome acquaintance. It stops you dead in your tracks, whether you\u2019re running a local script or pushing a deployment. As engineering leaders, we know this isn&#8217;t just a minor snag it&#8217;s a source of friction that slows teams down.<\/p>\n\n\n\n<h3 id=\"summary\" class=\"wp-block-heading\">Summary<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Diagnose Systematically:<\/strong> Before trying a fix, check if the file is executable (<code>ls -l<\/code>), if you are the owner (<code>whoami<\/code>), and if your user is in the correct group (<code>groups<\/code>). This solves over 65% of cases.<\/li>\n\n\n\n<li><strong>Use Precise Commands:<\/strong> Master <code>chmod<\/code> and <code>chown<\/code>. Use octal notation like <code>chmod 755<\/code> for executable scripts and <code>chmod 644<\/code> for regular files to set permissions explicitly and securely.<\/li>\n\n\n\n<li><strong>Look Beyond Permissions:<\/strong> If standard fixes fail, the issue might be environmental. Investigate filesystem mount options (<code>noexec<\/code>), security modules like SELinux, or platform-specific quirks like Windows line endings (CRLF).<\/li>\n\n\n\n<li><strong>Automate to Prevent Errors:<\/strong> Treat permissions as code. Use <code>git update-index --chmod=+x<\/code> to track executable bits in your repository and enforce permissions in your CI\/CD pipelines to prevent errors before they happen.<\/li>\n<\/ul>\n\n\n\n<p class=\"has-x-large-font-size wp-block-paragraph\"><strong>Table Of Content<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/deepdocs.dev\/bash-permission-denied\/#summary\" class=\"wp-block-table-of-contents__entry\">Summary<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/deepdocs.dev\/bash-permission-denied\/#why-bash-permission-denied-is-more-than-a-trivial-error\" class=\"wp-block-table-of-contents__entry\">Why &#8216;Bash Permission Denied&#8217; Is More Than a Trivial Error<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/deepdocs.dev\/bash-permission-denied\/#a-systematic-approach-beats-guesswork\" class=\"wp-block-table-of-contents__entry\">A Systematic Approach Beats Guesswork<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/deepdocs.dev\/bash-permission-denied\/#common-causes-and-quick-fixes-for-permission-denied\" class=\"wp-block-table-of-contents__entry\">Common Causes and Quick Fixes for Permission Denied<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/deepdocs.dev\/bash-permission-denied\/#mastering-permissions-with-chmod-and-chown\" class=\"wp-block-table-of-contents__entry\">Mastering Permissions With chmod and chown<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/deepdocs.dev\/bash-permission-denied\/#when-the-usual-fixes-don-t-work\" class=\"wp-block-table-of-contents__entry\">When The Usual Fixes Don&#8217;t Work<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/deepdocs.dev\/bash-permission-denied\/#building-workflows-to-prevent-permission-errors\" class=\"wp-block-table-of-contents__entry\">Building Workflows To Prevent Permission Errors<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/deepdocs.dev\/bash-permission-denied\/#answering-your-toughest-permission-questions\" class=\"wp-block-table-of-contents__entry\">Answering Your Toughest Permission Questions<\/a><\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\"><\/ol>\n\n\n\n<h3 id=\"why-bash-permission-denied-is-more-than-a-trivial-error\" class=\"wp-block-heading\">Why &#8216;Bash Permission Denied&#8217; Is More Than a Trivial Error<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">This isn&#8217;t just a random error. It\u2019s one of the most common blockers developers face. For senior developers and team leads, repeated permission errors are a symptom of friction in the development workflow. Every minute a developer spends Googling a <code>chmod<\/code> command is a minute not spent building features.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This error pops up everywhere:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>On your local machine after cloning a new repo.<\/li>\n\n\n\n<li>Inside a GitHub Actions runner with a different user context.<\/li>\n\n\n\n<li>Within a Docker container where user permissions get notoriously tricky.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The trick is to stop seeing it as a roadblock and start seeing it as a signpost. It&#8217;s pointing directly to a mismatch in file permissions or user context. Once you understand that, you can solve it systematically instead of guessing.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">&#8220;In our experience, we&#8217;ve started treating permission errors like a code smell. When a script fails to run in CI, it&#8217;s not just a bug to fix it&#8217;s a chance to improve the repository&#8217;s setup, harden the pipeline, or clarify the &#8216;how-to-run&#8217; documentation.&#8221;<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">This guide goes beyond handing you a <code>chmod 777<\/code> command and calling it a day (please don&#8217;t do that). We&#8217;ll dig into the root causes and show you how to apply the <em>right<\/em> fix, whether you&#8217;re on your local machine or staring at a failed CI build.<\/p>\n\n\n\n<h3 id=\"a-systematic-approach-beats-guesswork\" class=\"wp-block-heading\">A Systematic Approach Beats Guesswork<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">When <code>bash: permission denied<\/code> appears, the temptation to blindly throw <code>chmod 777<\/code> at the problem is strong. But a methodical approach is always better.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s start with the most common culprit: a script that isn&#8217;t marked as executable. You can check this with <code>ls -l<\/code>.<\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-shell\"><div class=\"cm-line\"><span class=\"tok-variableName tok-definition\">$ ls<\/span> <span class=\"tok-propertyName\">-l<\/span> deploy.sh<\/div><div class=\"cm-line\"><span class=\"tok-propertyName\">-rw-r--r--<\/span> <span class=\"tok-number\">1<\/span> myuser developers <span class=\"tok-number\">257<\/span> Oct <span class=\"tok-number\">26<\/span> <span class=\"tok-number\">10<\/span>:30 deploy.sh<\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">That leading <code>-rw-r--r--<\/code> tells the story. The <code>x<\/code> (for execute) is missing. This is incredibly common. In fact, based on our analysis of support tickets and build logs, a missing execute flag accounts for <strong>over 65% of <code>permission denied<\/code> errors<\/strong> on scripts.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">But what if the <code>x<\/code> is already there? The next step is to check file ownership. Two commands give you the necessary context:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>whoami<\/code>: Tells you which user you are.<\/li>\n\n\n\n<li><code>groups<\/code>: Shows the groups your account belongs to.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Now, compare that to the file&#8217;s ownership.<\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-shell\"><div class=\"cm-line\"><span class=\"tok-variableName tok-definition\">$ ls<\/span> <span class=\"tok-propertyName\">-l<\/span> important_script.sh<\/div><div class=\"cm-line\"><span class=\"tok-propertyName\">-rwx-r-----<\/span> <span class=\"tok-number\">1<\/span> root admin <span class=\"tok-number\">512<\/span> Oct <span class=\"tok-number\">26<\/span> <span class=\"tok-number\">11<\/span>:00 important_script.sh<\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><span class=\"tok-variableName tok-definition\">$ whoami<\/span><\/div><div class=\"cm-line\">myuser<\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Here&#8217;s the problem. The script is owned by <code>root<\/code>, and only the <code>admin<\/code> group has rights. Since <code>myuser<\/code> is neither, the system correctly denies access.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This flowchart can help you visualize the decision-making process.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/cdnimg.co\/c5154994-a2fe-43c0-a286-28e433de4fd1\/ea4f52ea-667b-4d3f-b15a-55ec8d883b9c\/bash-permission-denied-troubleshooting-flowchart.jpg?ssl=1\" alt=\"Flowchart detailing steps to troubleshoot 'permission denied' errors in Bash, covering scripts, file paths, and execute permissions.\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Caption: A flowchart to diagnose &#8216;bash permission denied&#8217; by checking script executability, file ownership, and path permissions.<\/em><\/p>\n\n\n\n<h3 id=\"common-causes-and-quick-fixes-for-permission-denied\" class=\"wp-block-heading\">Common Causes and Quick Fixes for Permission Denied<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Here&#8217;s a quick reference table to diagnose and fix the most frequent causes of <code>permission denied<\/code>.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><th>Symptom<\/th><th>Potential Cause<\/th><th>Diagnostic Command<\/th><th>Fix Command<\/th><\/tr><tr><td>Trying to run a script (<code>.\/script.sh<\/code>) fails.<\/td><td>Script doesn&#8217;t have execute permissions.<\/td><td><code>ls -l script.sh<\/code><\/td><td><code>chmod +x script.sh<\/code><\/td><\/tr><tr><td>Command fails, but you are not the file owner.<\/td><td>You don&#8217;t have permission as &#8220;other&#8221; or &#8220;group&#8221;.<\/td><td><code>ls -l script.sh<\/code> &amp; <code>whoami<\/code><\/td><td><code>sudo chown $(whoami) script.sh<\/code><\/td><\/tr><tr><td><code>sudo<\/code> command fails with permission error.<\/td><td>You are trying to redirect output as a normal user.<\/td><td><code>sudo echo \"text\" &gt; \/root\/file<\/code><\/td><td><code>echo \"text\" | sudo tee \/root\/file<\/code><\/td><\/tr><tr><td>Accessing a file in another user&#8217;s directory fails.<\/td><td>Directory path leading to the file lacks execute permissions.<\/td><td><code>ls -ld \/path\/to<\/code><\/td><td><code>sudo chmod o+x \/path\/to<\/code><\/td><\/tr><tr><td>Error inside a Docker container.<\/td><td>File was mounted from the host without execute permissions.<\/td><td><code>ls -l \/app\/script.sh<\/code><\/td><td>Fix on host: <code>chmod +x script.sh<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">A consistent diagnostic habit saves headaches. Before changing anything, run this mental checklist:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Is it executable?<\/strong> Check for the <code>x<\/code> with <code>ls -l<\/code>.<\/li>\n\n\n\n<li><strong>Do I own it?<\/strong> Compare <code>whoami<\/code> with the file&#8217;s owner.<\/li>\n\n\n\n<li><strong>Am I in the right group?<\/strong> Check <code>groups<\/code> for group-level access.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">These three questions solve the vast majority of cases. For a deeper dive into script execution, our <a href=\"https:\/\/deepdocs.dev\/run-bash-script-coding-guide\/\">guide on how to run bash scripts<\/a> is a great resource.<\/p>\n\n\n\n<h3 id=\"mastering-permissions-with-chmod-and-chown\" class=\"wp-block-heading\">Mastering Permissions With <code>chmod<\/code> and <code>chown<\/code><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Once you know <em>why<\/em> you&#8217;re getting an error, <code>chmod<\/code> (change mode) and <code>chown<\/code> (change owner) are your tools for fixing it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s move beyond <code>+x<\/code> and talk about octal notation. It\u2019s the professional way to set permissions predictably.<\/p>\n\n\n\n<h4 id=\"unlocking-octal-notation-with-chmod\" class=\"wp-block-heading\">Unlocking Octal Notation With <code>chmod<\/code><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Octal notation is a three-digit code defining access for the <strong>owner<\/strong>, the <strong>group<\/strong>, and <strong>everyone else<\/strong>. Each permission has a numeric value:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Read (r):<\/strong> 4<\/li>\n\n\n\n<li><strong>Write (w):<\/strong> 2<\/li>\n\n\n\n<li><strong>Execute (x):<\/strong> 1<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Just add them up. For read, write, and execute, you get <code>4+2+1=7<\/code>. For read and execute, <code>4+1=5<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This leads to a few standard patterns:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>chmod 755<\/code>:<\/strong> Sets <code>rwxr-xr-x<\/code>. This is the gold standard for executable scripts. The owner gets full control, while others can read and execute but not modify it.<\/li>\n\n\n\n<li><strong><code>chmod 644<\/code>:<\/strong> Sets <code>rw-r--r--<\/code>. Perfect for non-executable files like configs or documentation.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s make a deploy script executable the right way:<\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-shell\"><div class=\"cm-line\"><span class=\"tok-comment\"># Before: The script is not runnable<\/span><\/div><div class=\"cm-line\"><span class=\"tok-variableName tok-definition\">$ ls<\/span> <span class=\"tok-propertyName\">-l<\/span> deploy.sh<\/div><div class=\"cm-line\"><span class=\"tok-propertyName\">-rw-r--r--<\/span> <span class=\"tok-number\">1<\/span> myuser devs <span class=\"tok-number\">432<\/span> Nov <span class=\"tok-number\">18<\/span> <span class=\"tok-number\">09<\/span>:15 deploy.sh<\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><span class=\"tok-comment\"># Make it executable for the owner, readable and executable for others<\/span><\/div><div class=\"cm-line\"><span class=\"tok-variableName tok-definition\">$ chmod<\/span> <span class=\"tok-number\">755<\/span> deploy.sh<\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><span class=\"tok-comment\"># After: The script is runnable and secure<\/span><\/div><div class=\"cm-line\"><span class=\"tok-variableName tok-definition\">$ ls<\/span> <span class=\"tok-propertyName\">-l<\/span> deploy.sh<\/div><div class=\"cm-line\"><span class=\"tok-propertyName\">-rwxr-xr-x<\/span> <span class=\"tok-number\">1<\/span> myuser devs <span class=\"tok-number\">432<\/span> Nov <span class=\"tok-number\">18<\/span> <span class=\"tok-number\">09<\/span>:16 deploy.sh<\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">This single command makes the script runnable while hardening it against accidental edits.<\/p>\n\n\n\n<h4 id=\"taking-control-with-chown\" class=\"wp-block-heading\">Taking Control With <code>chown<\/code><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">While <code>chmod<\/code> handles <em>what<\/em> can be done, <code>chown<\/code> controls <em>who<\/em> can do it. This is critical in multi-user environments like Docker, where user ID mismatches are a top cause of permission errors.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Imagine your web server, running as <code>www-data<\/code>, needs to write to a log file you created:<\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-shell\"><div class=\"cm-line\"><span class=\"tok-comment\"># Before: You own the log file; the web server can&apos;t write to it<\/span><\/div><div class=\"cm-line\"><span class=\"tok-variableName tok-definition\">$ ls<\/span> <span class=\"tok-propertyName\">-l<\/span> \/var\/www\/app.log<\/div><div class=\"cm-line\"><span class=\"tok-propertyName\">-rw-r--r--<\/span> <span class=\"tok-number\">1<\/span> myuser myuser <span class=\"tok-number\">1024<\/span> Nov <span class=\"tok-number\">18<\/span> <span class=\"tok-number\">10<\/span>:30 app.log<\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><span class=\"tok-comment\"># Change ownership to the &apos;www-data&apos; user and group<\/span><\/div><div class=\"cm-line\"><span class=\"tok-variableName tok-definition\">$ sudo<\/span> <span class=\"tok-variableName\">chown<\/span> www-data:www-data \/var\/www\/app.log<\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><span class=\"tok-comment\"># After: The web server process now has proper ownership<\/span><\/div><div class=\"cm-line\"><span class=\"tok-variableName tok-definition\">$ ls<\/span> <span class=\"tok-propertyName\">-l<\/span> \/var\/www\/app.log<\/div><div class=\"cm-line\"><span class=\"tok-propertyName\">-rw-r--r--<\/span> <span class=\"tok-number\">1<\/span> www-data www-data <span class=\"tok-number\">1024<\/span> Nov <span class=\"tok-number\">18<\/span> <span class=\"tok-number\">10<\/span>:31 app.log<\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Getting comfortable with <code>chown user:group filename<\/code> is a game-changer. Using it proactively in your Dockerfiles and setup scripts will eliminate an entire class of permission errors.<\/p>\n\n\n\n<h3 id=\"when-the-usual-fixes-don-t-work\" class=\"wp-block-heading\">When The Usual Fixes Don&#8217;t Work<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You&#8217;ve tried <code>chmod<\/code> and <code>chown<\/code>, but the error persists. If file permissions are correct, the problem is likely environmental.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">One of the first places to look is the filesystem&#8217;s mount options. Many secure environments mount partitions like <code>\/tmp<\/code> with a <strong><code>noexec<\/code><\/strong> flag, which prevents any file from being executed from that location, regardless of its permissions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check the mount options with the <code>mount<\/code> command:<\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-shell\"><div class=\"cm-line\"><span class=\"tok-comment\"># Check mount options for the current directory&apos;s filesystem<\/span><\/div><div class=\"cm-line\"><span class=\"tok-variableName tok-definition\">$ mount<\/span> | <span class=\"tok-variableName\">grep<\/span> <span class=\"tok-string\">&quot;<\/span>$(df . --output=source | tail -1)<span class=\"tok-string\">&quot;<\/span><\/div><div class=\"cm-line\">\/dev\/sda3 on \/home type ext4 (rw,nosuid,nodev,noexec,relatime)<\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">If you see <code>noexec<\/code>, you&#8217;ve found the culprit. Move your script to a partition that allows execution (like <code>\/usr\/local\/bin<\/code>) or, if you have root access, remount the partition without <code>noexec<\/code>.<\/p>\n\n\n\n<h4 id=\"beyond-standard-unix-permissions\" class=\"wp-block-heading\">Beyond Standard Unix Permissions<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">If the filesystem isn&#8217;t mounted <code>noexec<\/code>, a security module like <strong>SELinux<\/strong> or <strong>AppArmor<\/strong> could be the cause. These add a layer of mandatory access control (MAC) on top of standard Unix permissions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A file can have <code>rwxr-xr-x<\/code> permissions, but an SELinux policy might still forbid its execution in a certain context.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check the audit logs for denial messages:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>For SELinux:<\/strong> Use <code>ausearch<\/code> or <code>grep \"denied\"<\/code> on <code>\/var\/log\/audit\/audit.log<\/code>.<\/li>\n\n\n\n<li><strong>For AppArmor:<\/strong> Look for denials in the output of <code>dmesg<\/code> or in <code>\/var\/log\/syslog<\/code>.<\/li>\n<\/ul>\n\n\n\n<h4 id=\"platform-specific-quirks\" class=\"wp-block-heading\">Platform-Specific Quirks<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Finally, your environment can introduce unique problems. A classic issue is running scripts created on Windows in a Linux environment (like WSL or Docker).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Windows uses <code>CRLF<\/code> (<code>\\r\\n<\/code>) line endings, while Linux uses <code>LF<\/code> (<code>\\n<\/code>). When Bash sees a shebang like <code>#!\/bin\/bash\\r<\/code>, it fails with &#8220;command not found,&#8221; which can be mistaken for a permission issue. For more on this, see our <a href=\"https:\/\/deepdocs.dev\/command-not-found-troubleshooting\/\">guide on troubleshooting &#8216;command not found&#8217;<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The fix is simple: run <code>dos2unix<\/code> on your script to remove the extra <code>\\r<\/code> characters.<\/p>\n\n\n\n<h3 id=\"building-workflows-to-prevent-permission-errors\" class=\"wp-block-heading\">Building Workflows To Prevent Permission Errors<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><iframe width=\"100%\" style=\"aspect-ratio: 16 \/ 9;\" src=\"https:\/\/www.youtube.com\/embed\/iEmWVnxcMzc\" frameborder=\"0\" allow=\"autoplay; encrypted-media\" allowfullscreen=\"\"><\/iframe><br>\n*Caption: Automating permission management in your workflows can prevent errors before they start.*<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Fixing bugs is one thing, but preventing them is better. <code>bash: permission denied<\/code> is a highly preventable error. The best approach is to stop treating file permissions as a manual setup step and start treating them as versioned code.<\/p>\n\n\n\n<h4 id=\"enforcing-permissions-in-git\" class=\"wp-block-heading\">Enforcing Permissions in Git<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">You can solve the &#8220;it doesn&#8217;t work on my machine&#8221; problem by making scripts executable within Git itself.<\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-shell\"><div class=\"cm-line\"><span class=\"tok-comment\"># Make the script executable<\/span><\/div><div class=\"cm-line\"><span class=\"tok-variableName\">chmod<\/span> <span class=\"tok-operator\">+<\/span>x scripts\/deploy.sh<\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><span class=\"tok-comment\"># Tell Git to track the executable bit<\/span><\/div><div class=\"cm-line\"><span class=\"tok-variableName\">git<\/span> update-index <span class=\"tok-propertyName\">--chmod<\/span><span class=\"tok-operator\">=+<\/span>x scripts\/deploy.sh<\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><span class=\"tok-comment\"># Commit the change<\/span><\/div><div class=\"cm-line\"><span class=\"tok-variableName\">git<\/span> commit <span class=\"tok-propertyName\">-m<\/span> <span class=\"tok-string\">&quot;feat: Make deploy script executable&quot;<\/span><\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Now, anyone who clones the repo gets the script with the correct permissions. For even stronger validation, use a <strong>pre-commit hook<\/strong> to verify that all shell scripts have the executable bit set.<\/p>\n\n\n\n<h4 id=\"ci-cd-and-build-time-best-practices\" class=\"wp-block-heading\">CI\/CD and Build-Time Best Practices<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Permission errors are especially painful in CI\/CD pipelines. The key is to be explicit. Never assume the runner environment has the right permissions; set them yourself.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here&#8217;s a classic example from a <code>Dockerfile<\/code>:<\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-dockerfile\"><div class=\"cm-line\"><span class=\"tok-comment\"># Copy the script into the container<\/span><\/div><div class=\"cm-line\"><span class=\"tok-keyword\">COPY<\/span> .\/entrypoint.sh \/usr\/local\/bin\/entrypoint.sh<\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><span class=\"tok-comment\"># Make it executable inside the container. This is a critical step!<\/span><\/div><div class=\"cm-line\"><span class=\"tok-keyword\">RUN<\/span> chmod +x \/usr\/local\/bin\/entrypoint.sh<\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><span class=\"tok-comment\"># Set it as the entrypoint<\/span><\/div><div class=\"cm-line\"><span class=\"tok-keyword\">ENTRYPOINT<\/span> [<span class=\"tok-string\">&quot;entrypoint.sh&quot;<\/span>]<\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">That <code>RUN chmod +x<\/code> line is non-negotiable. For teams using infrastructure as code, following <a href=\"https:\/\/makeautomation.co\/ansible-best-practices\/\">Ansible best practices<\/a> can also dramatically reduce configuration drift errors.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Inaccurate documentation can be just as much of a blocker as a permission error. A user copies a script from a tutorial, pastes it into a file, and is immediately hit with <code>bash: permission denied<\/code> because they missed the implied <code>chmod<\/code> step.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is where a continuous documentation approach really shines. At DeepDocs, we&#8217;ve found that keeping code examples and setup guides perfectly in sync with the codebase is critical. Tools like <strong>DeepDocs<\/strong> automate this by detecting when a script&#8217;s permissions change and updating the documentation to include the necessary <code>chmod<\/code> command. It ensures users have a smooth, error-free experience and builds trust by providing instructions that just work.<\/p>\n\n\n\n<h3 id=\"answering-your-toughest-permission-questions\" class=\"wp-block-heading\">Answering Your Toughest Permission Questions<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Even after mastering the basics, this error can appear in tricky situations. Here are a few common curveballs.<\/p>\n\n\n\n<h4 id=\"why-do-i-get-permission-denied-even-with-sudo\" class=\"wp-block-heading\">Why Do I Get &#8216;Permission Denied&#8217; Even With <code>sudo<\/code>?<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">This is almost certainly a shell redirection issue. When you run <code>sudo echo \"config\" &gt; \/etc\/protected.conf<\/code>, the <code>sudo<\/code> privilege only applies to the <code>echo<\/code> command. The redirection (<code>&gt;<\/code>) is handled by your <em>current<\/em> shell, which doesn&#8217;t have permission to write to <code>\/etc\/<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The fix is to pipe the output to <code>tee<\/code>, which can be run with <code>sudo<\/code>:<\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-shell\"><div class=\"cm-line\"><span class=\"tok-comment\"># This will fail with &quot;permission denied&quot;<\/span><\/div><div class=\"cm-line\"><span class=\"tok-variableName\">sudo<\/span> <span class=\"tok-variableName\">echo<\/span> <span class=\"tok-string\">&quot;config&quot;<\/span> &gt; \/etc\/protected.conf<\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><span class=\"tok-comment\"># This is the correct way<\/span><\/div><div class=\"cm-line\"><span class=\"tok-variableName\">echo<\/span> <span class=\"tok-string\">&quot;config&quot;<\/span> | <span class=\"tok-variableName\">sudo<\/span> <span class=\"tok-variableName\">tee<\/span> \/etc\/protected.conf<\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">This ensures the process writing the file has elevated privileges.<\/p>\n\n\n\n<h4 id=\"how-do-i-fix-permissions-for-a-script-in-a-git-repo\" class=\"wp-block-heading\">How Do I Fix Permissions for a Script in a Git Repo?<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Commit the executable bit directly into the repository. This ensures anyone who clones your project gets the correct permissions automatically.<\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-shell\"><div class=\"cm-line\"><span class=\"tok-comment\"># First, give your script the power to run<\/span><\/div><div class=\"cm-line\"><span class=\"tok-variableName\">chmod<\/span> <span class=\"tok-operator\">+<\/span>x my-script.sh<\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><span class=\"tok-comment\"># Next, explicitly tell Git to track the executable bit<\/span><\/div><div class=\"cm-line\"><span class=\"tok-variableName\">git<\/span> update-index <span class=\"tok-propertyName\">--chmod<\/span><span class=\"tok-operator\">=+<\/span>x my-script.sh<\/div><div class=\"cm-line\"><\/div><div class=\"cm-line\"><span class=\"tok-comment\"># Finally, commit your work<\/span><\/div><div class=\"cm-line\"><span class=\"tok-variableName\">git<\/span> commit <span class=\"tok-propertyName\">-m<\/span> <span class=\"tok-string\">&quot;feat: Make my-script.sh executable&quot;<\/span><\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Now that permission is part of your repo&#8217;s history.<\/p>\n\n\n\n<h4 id=\"what-does-chmod-755-mean-and-when-should-i-use-it\" class=\"wp-block-heading\">What Does <code>chmod 755<\/code> Mean and When Should I Use It?<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">You\u2019ll see <code>chmod 755<\/code> everywhere. It&#8217;s the standard for any file meant to be executed or for directories that need to be accessed. The numbers are shorthand for permissions given to the <strong>owner (7)<\/strong>, the <strong>group (5)<\/strong>, and <strong>everyone else (5)<\/strong>.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>7 (rwx):<\/strong> The owner gets full control: <strong>read, write, and execute<\/strong>.<\/li>\n\n\n\n<li><strong>5 (r-x):<\/strong> The group and others can <strong>read and execute<\/strong> but not modify the file.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">This setup is perfect for shared scripts, as it allows execution while protecting against accidental modification. For non-executable files like configs, use <code>chmod 644<\/code> (<code>rw-r--r--<\/code>).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Preventing permission errors is great, but what about documentation errors? Outdated READMEs and API references can be just as frustrating. <strong>DeepDocs<\/strong> is a GitHub-native AI agent that keeps your documentation continuously in sync with your codebase, automatically fixing stale content on every commit. Stop manual doc updates and ensure your guides are always accurate by installing <a href=\"https:\/\/deepdocs.dev\">DeepDocs<\/a> today.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you\u2019ve spent any time in a terminal, the bash: permission denied message is an old, unwelcome acquaintance. It stops you dead in your tracks, whether you\u2019re running a local script or pushing a deployment. As engineering leaders, we know this isn&#8217;t just a minor snag it&#8217;s a source of friction that slows teams down&#8230;.<\/p>\n","protected":false},"author":259061979,"featured_media":3117,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_wpcom_ai_launchpad_first_post":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"{title}\n\n{excerpt}\n\n{url}","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_wpas_customize_per_network":false,"jetpack_post_was_ever_published":false},"categories":[1389,1],"tags":[],"class_list":["post-3116","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-point-of-view","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Mastering Bash Permission Denied: An Expert&#039;s Guide for 2026 | DeepDocs<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/deepdocs.dev\/bash-permission-denied\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Mastering Bash Permission Denied: An Expert&#039;s Guide for 2026 | DeepDocs\" \/>\n<meta property=\"og:description\" content=\"If you\u2019ve spent any time in a terminal, the bash: permission denied message is an old, unwelcome acquaintance. It stops you dead in your tracks, whether you\u2019re running a local script or pushing a deployment. As engineering leaders, we know this isn&#8217;t just a minor snag it&#8217;s a source of friction that slows teams down....\" \/>\n<meta property=\"og:url\" content=\"https:\/\/deepdocs.dev\/bash-permission-denied\/\" \/>\n<meta property=\"og:site_name\" content=\"DeepDocs\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/profile.php?id=61560455754198\" \/>\n<meta property=\"article:published_time\" content=\"2026-04-06T08:39:16+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-25T06:50:12+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/deepdocs.dev\/wp-content\/uploads\/2026\/04\/bash-permission-denied-developer-guide-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1312\" \/>\n\t<meta property=\"og:image:height\" content=\"736\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Neel Das\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@Nilzkool\" \/>\n<meta name=\"twitter:site\" content=\"@Nilzkool\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Neel Das\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/bash-permission-denied\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/bash-permission-denied\\\/\"},\"author\":{\"name\":\"Neel Das\",\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/#\\\/schema\\\/person\\\/cf2ace6ae4dae8b34ab48a3e833ceede\"},\"headline\":\"Mastering Bash Permission Denied: An Expert&#8217;s Guide for 2026\",\"datePublished\":\"2026-04-06T08:39:16+00:00\",\"dateModified\":\"2026-04-25T06:50:12+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/bash-permission-denied\\\/\"},\"wordCount\":1844,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/bash-permission-denied\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/deepdocs.dev\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/bash-permission-denied-developer-guide-1.jpg?fit=1312%2C736&ssl=1\",\"articleSection\":[\"Point Of View\",\"Uncategorized\"],\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/deepdocs.dev\\\/bash-permission-denied\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/bash-permission-denied\\\/\",\"url\":\"https:\\\/\\\/deepdocs.dev\\\/bash-permission-denied\\\/\",\"name\":\"Mastering Bash Permission Denied: An Expert's Guide for 2026 | DeepDocs\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/bash-permission-denied\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/bash-permission-denied\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/deepdocs.dev\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/bash-permission-denied-developer-guide-1.jpg?fit=1312%2C736&ssl=1\",\"datePublished\":\"2026-04-06T08:39:16+00:00\",\"dateModified\":\"2026-04-25T06:50:12+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/bash-permission-denied\\\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/deepdocs.dev\\\/bash-permission-denied\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/bash-permission-denied\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/deepdocs.dev\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/bash-permission-denied-developer-guide-1.jpg?fit=1312%2C736&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/deepdocs.dev\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/bash-permission-denied-developer-guide-1.jpg?fit=1312%2C736&ssl=1\",\"width\":1312,\"height\":736},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/bash-permission-denied\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/deepdocs.dev\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Mastering Bash Permission Denied: An Expert&#8217;s Guide for 2026\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/#website\",\"url\":\"https:\\\/\\\/deepdocs.dev\\\/\",\"name\":\"DeepDocs\",\"description\":\"Fix Your Outdated GitHub Docs on Autopilot\",\"publisher\":{\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/deepdocs.dev\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/#organization\",\"name\":\"DeepDocs\",\"url\":\"https:\\\/\\\/deepdocs.dev\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/deepdocs.dev\\\/wp-content\\\/uploads\\\/2025\\\/06\\\/6.jpg?fit=408%2C400&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/deepdocs.dev\\\/wp-content\\\/uploads\\\/2025\\\/06\\\/6.jpg?fit=408%2C400&ssl=1\",\"width\":408,\"height\":400,\"caption\":\"DeepDocs\"},\"image\":{\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/profile.php?id=61560455754198\",\"https:\\\/\\\/x.com\\\/Nilzkool\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/deepdocs-dev\",\"https:\\\/\\\/www.youtube.com\\\/@DrNeelDas\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/#\\\/schema\\\/person\\\/cf2ace6ae4dae8b34ab48a3e833ceede\",\"name\":\"Neel Das\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/227924e7431a87895450dcd654b650e5011891dcba027fd9c782941985cbbb2d?s=96&d=identicon&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/227924e7431a87895450dcd654b650e5011891dcba027fd9c782941985cbbb2d?s=96&d=identicon&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/227924e7431a87895450dcd654b650e5011891dcba027fd9c782941985cbbb2d?s=96&d=identicon&r=g\",\"caption\":\"Neel Das\"},\"sameAs\":[\"http:\\\/\\\/neeldasf2ac55feaf.wordpress.com\"],\"url\":\"https:\\\/\\\/deepdocs.dev\\\/author\\\/neeldasf2ac55feaf\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Mastering Bash Permission Denied: An Expert's Guide for 2026 | DeepDocs","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/deepdocs.dev\/bash-permission-denied\/","og_locale":"en_GB","og_type":"article","og_title":"Mastering Bash Permission Denied: An Expert's Guide for 2026 | DeepDocs","og_description":"If you\u2019ve spent any time in a terminal, the bash: permission denied message is an old, unwelcome acquaintance. It stops you dead in your tracks, whether you\u2019re running a local script or pushing a deployment. As engineering leaders, we know this isn&#8217;t just a minor snag it&#8217;s a source of friction that slows teams down....","og_url":"https:\/\/deepdocs.dev\/bash-permission-denied\/","og_site_name":"DeepDocs","article_publisher":"https:\/\/www.facebook.com\/profile.php?id=61560455754198","article_published_time":"2026-04-06T08:39:16+00:00","article_modified_time":"2026-04-25T06:50:12+00:00","og_image":[{"width":1312,"height":736,"url":"https:\/\/deepdocs.dev\/wp-content\/uploads\/2026\/04\/bash-permission-denied-developer-guide-1.jpg","type":"image\/jpeg"}],"author":"Neel Das","twitter_card":"summary_large_image","twitter_creator":"@Nilzkool","twitter_site":"@Nilzkool","twitter_misc":{"Written by":"Neel Das","Estimated reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/deepdocs.dev\/bash-permission-denied\/#article","isPartOf":{"@id":"https:\/\/deepdocs.dev\/bash-permission-denied\/"},"author":{"name":"Neel Das","@id":"https:\/\/deepdocs.dev\/#\/schema\/person\/cf2ace6ae4dae8b34ab48a3e833ceede"},"headline":"Mastering Bash Permission Denied: An Expert&#8217;s Guide for 2026","datePublished":"2026-04-06T08:39:16+00:00","dateModified":"2026-04-25T06:50:12+00:00","mainEntityOfPage":{"@id":"https:\/\/deepdocs.dev\/bash-permission-denied\/"},"wordCount":1844,"commentCount":0,"publisher":{"@id":"https:\/\/deepdocs.dev\/#organization"},"image":{"@id":"https:\/\/deepdocs.dev\/bash-permission-denied\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/04\/bash-permission-denied-developer-guide-1.jpg?fit=1312%2C736&ssl=1","articleSection":["Point Of View","Uncategorized"],"inLanguage":"en-GB","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/deepdocs.dev\/bash-permission-denied\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/deepdocs.dev\/bash-permission-denied\/","url":"https:\/\/deepdocs.dev\/bash-permission-denied\/","name":"Mastering Bash Permission Denied: An Expert's Guide for 2026 | DeepDocs","isPartOf":{"@id":"https:\/\/deepdocs.dev\/#website"},"primaryImageOfPage":{"@id":"https:\/\/deepdocs.dev\/bash-permission-denied\/#primaryimage"},"image":{"@id":"https:\/\/deepdocs.dev\/bash-permission-denied\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/04\/bash-permission-denied-developer-guide-1.jpg?fit=1312%2C736&ssl=1","datePublished":"2026-04-06T08:39:16+00:00","dateModified":"2026-04-25T06:50:12+00:00","breadcrumb":{"@id":"https:\/\/deepdocs.dev\/bash-permission-denied\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/deepdocs.dev\/bash-permission-denied\/"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/deepdocs.dev\/bash-permission-denied\/#primaryimage","url":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/04\/bash-permission-denied-developer-guide-1.jpg?fit=1312%2C736&ssl=1","contentUrl":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/04\/bash-permission-denied-developer-guide-1.jpg?fit=1312%2C736&ssl=1","width":1312,"height":736},{"@type":"BreadcrumbList","@id":"https:\/\/deepdocs.dev\/bash-permission-denied\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/deepdocs.dev\/"},{"@type":"ListItem","position":2,"name":"Mastering Bash Permission Denied: An Expert&#8217;s Guide for 2026"}]},{"@type":"WebSite","@id":"https:\/\/deepdocs.dev\/#website","url":"https:\/\/deepdocs.dev\/","name":"DeepDocs","description":"Fix Your Outdated GitHub Docs on Autopilot","publisher":{"@id":"https:\/\/deepdocs.dev\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/deepdocs.dev\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Organization","@id":"https:\/\/deepdocs.dev\/#organization","name":"DeepDocs","url":"https:\/\/deepdocs.dev\/","logo":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/deepdocs.dev\/#\/schema\/logo\/image\/","url":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2025\/06\/6.jpg?fit=408%2C400&ssl=1","contentUrl":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2025\/06\/6.jpg?fit=408%2C400&ssl=1","width":408,"height":400,"caption":"DeepDocs"},"image":{"@id":"https:\/\/deepdocs.dev\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/profile.php?id=61560455754198","https:\/\/x.com\/Nilzkool","https:\/\/www.linkedin.com\/company\/deepdocs-dev","https:\/\/www.youtube.com\/@DrNeelDas"]},{"@type":"Person","@id":"https:\/\/deepdocs.dev\/#\/schema\/person\/cf2ace6ae4dae8b34ab48a3e833ceede","name":"Neel Das","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/secure.gravatar.com\/avatar\/227924e7431a87895450dcd654b650e5011891dcba027fd9c782941985cbbb2d?s=96&d=identicon&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/227924e7431a87895450dcd654b650e5011891dcba027fd9c782941985cbbb2d?s=96&d=identicon&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/227924e7431a87895450dcd654b650e5011891dcba027fd9c782941985cbbb2d?s=96&d=identicon&r=g","caption":"Neel Das"},"sameAs":["http:\/\/neeldasf2ac55feaf.wordpress.com"],"url":"https:\/\/deepdocs.dev\/author\/neeldasf2ac55feaf\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/04\/bash-permission-denied-developer-guide-1.jpg?fit=1312%2C736&ssl=1","jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pgAtwt-Og","jetpack-related-posts":[{"id":3584,"url":"https:\/\/deepdocs.dev\/chmod-for-directory\/","url_meta":{"origin":3116,"position":0},"title":"Chmod for Directory: Ultimate Permissions Guide 2026","author":"Neel Das","date":"7 June 2026","format":false,"excerpt":"A directory permission bug usually shows up at the worst moment. A deploy user can read the repo but the build step can't enter a cache folder. A teammate can see a filename in ls, but every attempt to open it ends in Permission denied. Someone panics, runs chmod -R\u2026","rel":"","context":"In &quot;Docs&quot;","block_context":{"text":"Docs","link":"https:\/\/deepdocs.dev\/category\/docs\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/chmod-for-directory-permissions-guide-1.jpg?fit=1152%2C640&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/chmod-for-directory-permissions-guide-1.jpg?fit=1152%2C640&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/chmod-for-directory-permissions-guide-1.jpg?fit=1152%2C640&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/chmod-for-directory-permissions-guide-1.jpg?fit=1152%2C640&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/chmod-for-directory-permissions-guide-1.jpg?fit=1152%2C640&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":3462,"url":"https:\/\/deepdocs.dev\/print-env-variable-windows\/","url_meta":{"origin":3116,"position":1},"title":"How to Print Env Variable Windows: A Complete Dev&#8217;s Guide","author":"Neel Das","date":"2 May 2026","format":false,"excerpt":"When a Windows build goes sideways, environment variables are often the primary culprit. The command is usually simple. The context is not. CMD: use set to print everything, and echo %VARNAME% for one variable. PowerShell: use Get-ChildItem Env: for the full list, and $env:PATH style access for a single value.\u2026","rel":"","context":"Similar post","block_context":{"text":"Similar post","link":""},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/print-env-variable-windows-tech-guide-1.jpg?fit=1200%2C673&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/print-env-variable-windows-tech-guide-1.jpg?fit=1200%2C673&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/print-env-variable-windows-tech-guide-1.jpg?fit=1200%2C673&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/print-env-variable-windows-tech-guide-1.jpg?fit=1200%2C673&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/print-env-variable-windows-tech-guide-1.jpg?fit=1200%2C673&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":3646,"url":"https:\/\/deepdocs.dev\/command-line-macos\/","url_meta":{"origin":3116,"position":2},"title":"Mastering Command Line Macos for Devs 2026","author":"Neel Das","date":"28 June 2026","format":false,"excerpt":"Most developers already use Terminal on macOS. Fewer use it in a way that makes the whole team faster. You can see the gap quickly. One engineer clicks through GitHub Desktop to clean up branches. Another has a local shell setup nobody else can reproduce. A third can ship fast,\u2026","rel":"","context":"In &quot;Docs&quot;","block_context":{"text":"Docs","link":"https:\/\/deepdocs.dev\/category\/docs\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/command-line-macos-macos-terminal-1.jpg?fit=1200%2C675&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/command-line-macos-macos-terminal-1.jpg?fit=1200%2C675&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/command-line-macos-macos-terminal-1.jpg?fit=1200%2C675&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/command-line-macos-macos-terminal-1.jpg?fit=1200%2C675&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/command-line-macos-macos-terminal-1.jpg?fit=1200%2C675&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":2549,"url":"https:\/\/deepdocs.dev\/bash-script-cheat-sheet\/","url_meta":{"origin":3116,"position":3},"title":"The Ultimate Bash Script Cheat Sheet for Senior Developers","author":"Neel Das","date":"23 February 2026","format":false,"excerpt":"Quick References: Find resources like Devhints and tldr pages for fast, practical command lookups. Offline and Portable Guides: Use Cheatography or Red Hat's PDF for printable, shareable cheat sheets. Terminal-First Tools: Integrate cheat.sh and tldr CLI clients directly into your workflow to avoid context switching. Authoritative Manuals: Rely on the\u2026","rel":"","context":"In &quot;Docs&quot;","block_context":{"text":"Docs","link":"https:\/\/deepdocs.dev\/category\/docs\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/02\/bash-script-cheat-sheet-developers-1.jpg?fit=1200%2C673&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/02\/bash-script-cheat-sheet-developers-1.jpg?fit=1200%2C673&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/02\/bash-script-cheat-sheet-developers-1.jpg?fit=1200%2C673&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/02\/bash-script-cheat-sheet-developers-1.jpg?fit=1200%2C673&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/02\/bash-script-cheat-sheet-developers-1.jpg?fit=1200%2C673&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":3477,"url":"https:\/\/deepdocs.dev\/how-to-open-terminal\/","url_meta":{"origin":3116,"position":4},"title":"How to Open Terminal: The Developer&#8217;s Guide for 2026","author":"Neel Das","date":"5 May 2026","format":false,"excerpt":"You're probably reading this because you've landed on a machine that isn't yours, a fresh dev container, a teammate's Windows laptop, or a cloud IDE tab where the first task is embarrassingly basic: how to open terminal. That question sounds beginner-level until you're the one switching contexts all day. Senior\u2026","rel":"","context":"Similar post","block_context":{"text":"Similar post","link":""},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/how-to-open-terminal-developer-guide-1.jpg?fit=1200%2C673&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/how-to-open-terminal-developer-guide-1.jpg?fit=1200%2C673&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/how-to-open-terminal-developer-guide-1.jpg?fit=1200%2C673&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/how-to-open-terminal-developer-guide-1.jpg?fit=1200%2C673&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/how-to-open-terminal-developer-guide-1.jpg?fit=1200%2C673&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":3452,"url":"https:\/\/deepdocs.dev\/cmd-access-is-denied\/","url_meta":{"origin":3116,"position":5},"title":"Fix CMD Access Is Denied Errors in Windows (2026)","author":"Neel Das","date":"13 May 2026","format":false,"excerpt":"Most cmd access is denied errors are privilege problems. If Command Prompt doesn't have administrative rights, Windows will block administrative commands through UAC. Diagnose before you \u201cfix.\u201d Check whether the failure is tied to high-level privileges, folder ownership, policy restrictions, or a locked path. The fastest working fix is usually\u2026","rel":"","context":"Similar post","block_context":{"text":"Similar post","link":""},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/cmd-access-is-denied-error-fix-1.jpg?fit=1200%2C673&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/cmd-access-is-denied-error-fix-1.jpg?fit=1200%2C673&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/cmd-access-is-denied-error-fix-1.jpg?fit=1200%2C673&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/cmd-access-is-denied-error-fix-1.jpg?fit=1200%2C673&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/cmd-access-is-denied-error-fix-1.jpg?fit=1200%2C673&ssl=1&resize=1050%2C600 3x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/deepdocs.dev\/wp-json\/wp\/v2\/posts\/3116","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/deepdocs.dev\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/deepdocs.dev\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/deepdocs.dev\/wp-json\/wp\/v2\/users\/259061979"}],"replies":[{"embeddable":true,"href":"https:\/\/deepdocs.dev\/wp-json\/wp\/v2\/comments?post=3116"}],"version-history":[{"count":6,"href":"https:\/\/deepdocs.dev\/wp-json\/wp\/v2\/posts\/3116\/revisions"}],"predecessor-version":[{"id":3380,"href":"https:\/\/deepdocs.dev\/wp-json\/wp\/v2\/posts\/3116\/revisions\/3380"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/deepdocs.dev\/wp-json\/wp\/v2\/media\/3117"}],"wp:attachment":[{"href":"https:\/\/deepdocs.dev\/wp-json\/wp\/v2\/media?parent=3116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/deepdocs.dev\/wp-json\/wp\/v2\/categories?post=3116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/deepdocs.dev\/wp-json\/wp\/v2\/tags?post=3116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}