{"id":29337,"date":"2021-02-22T18:42:57","date_gmt":"2021-02-23T02:42:57","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=29337"},"modified":"2023-12-01T04:08:58","modified_gmt":"2023-12-01T12:08:58","slug":"bash-permission-denied-solution","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/bash-permission-denied-solution\/","title":{"rendered":"Bash permission denied Explanation and Solution"},"content":{"rendered":"\n<p>Files on an operating system usually have permissions, making the file accessible to a limited range of people. For instance, some files on a computer are accessible only to administrators; other files are only accessible to a particular user.<br><\/p>\n\n\n\n<p>If you try to run a file to which you have no access on a Linux computer, you will see a <code>permission denied<\/code> error. In this guide, we\u2019re going to talk about the cause of this error and how you can solve the error. Let\u2019s begin.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Bash permission denied<\/h2>\n\n\n\n<p>The Bash <code>permission denied<\/code> error happens when you try to run a file which you do not have permission to run. This may happen if a file can only be executed by a particular user or a group of which you are not a member.<br><\/p>\n\n\n\n<p>On a Linux operating system, there are three types of permissions:<br><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Read<\/li><li>Write<\/li><li>Execute<\/li><\/ul>\n\n\n\n<p>You can have permission to read and write a file without having execution privileges. Thus, if you encounter a <code>Bash permission denied<\/code> be sure to check whether you are allowed to run the file. You can check if you have permissions over a file by using the following command:<br><\/p>\n\n\n\n<p><em>ls -la<\/em><br><\/p>\n\n\n\n<p>This command will give you information about file permissions. We discuss the output of this command in our <code>The Solution<\/code> section later in the article. Let\u2019s look at an example scenario featuring the <code>permission denied<\/code> error, with a corresponding solution.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">An Example Scenario<\/h2>\n\n\n\n<p>We have a file called example.sh. We can see this file by running the ls command. The ls command returns the following:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>example.sh\nexample2.sh<\/pre><\/div>\n\n\n\n<p>We want to run our example.sh file. To do so, we can use the .\/ notation:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>.\/example.sh<\/pre><\/div>\n\n\n\n<p>This command lets us run the example.sh file which is present in our .\/ directory (the directory we are presently viewing). Let\u2019s see what happens when we try to run the file:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>bash: .\/test.sh: Permission denied<\/pre><\/div>\n\n\n\n<p>Our command returns an error.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The Solution<\/h2>\n\n\n\n<p>Our Bash shell is telling us that we do not have permissions to run our file. We can check what permissions we have by running the ls -la command:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>-rw-r----- 1 james james 13 Feb 16 12:48 example.sh\n-rw-r----- 1 james james 13 Feb 16 12:48 example1.sh<\/pre><\/div>\n\n\n\n<p>We do not have execution privileges over any of our files. If there were an <code>x<\/code> after the <code>rw<\/code> in the first entry of the output above, we would know we can execute our file. The three characters after the first one represent read, write, and execute privileges for a user. Our group also does not have write or execute permissions.<br><\/p>\n\n\n\n<p>To solve this issue, we need to give ourselves execution privileges:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>chmod u+x example.sh<\/pre><\/div>\n\n\n\n<p>This command gives our user execution (\u201cx\u201d) privileges over the example.sh file.<br><\/p>\n\n\n\n<p>We can only run this command if we are allowed to change the privileges of the file. If this file was protected (owned by root, for example), then we would not be able to change this file.<br><\/p>\n\n\n\n<p>The file is owned by the <code>james<\/code> system user so I can alter the file permissions on my <code>james<\/code> account. I could also use <code>sudo<\/code> to alter the file privileges, although this is not necessary because my user account has the necessary access.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>The Bash <code>permission denied<\/code> error indicates you are trying to execute a file which you do not have permission to run. To fix this issue, use the chmod u+x command to give yourself permissions. If you cannot use this command, you may need to contact your system administrator to get access to a file.<br><\/p>\n\n\n\n<p>Do you want to learn more about Bash? Check out our <a href=\"https:\/\/careerkarma.com\/blog\/how-to-learn-command-line\/\">How to Learn the Command Line guide<\/a>. This guide comes with top tips on how to learn Bash. You will also find a list of resources to help you accelerate your learning journey.<\/p>\n","protected":false},"excerpt":{"rendered":"Files on an operating system usually have permissions, making the file accessible to a limited range of people. For instance, some files on a computer are accessible only to administrators; other files are only accessible to a particular user. If you try to run a file to which you have no access on a Linux&hellip;","protected":false},"author":240,"featured_media":12811,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[18070],"tags":[],"class_list":{"0":"post-29337","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-software-engineering-skills"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"Coding","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":null,"is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.4 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Bash permission denied Explanation and Solution<\/title>\n<meta name=\"description\" content=\"Learn the causes of and the solution to the Bash permission denied error on Career Karma.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/bash-permission-denied-solution\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Bash permission denied Explanation and Solution\" \/>\n<meta property=\"og:description\" content=\"Learn the causes of and the solution to the Bash permission denied error on Career Karma.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/bash-permission-denied-solution\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2021-02-23T02:42:57+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T12:08:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/code-coding-computer-developer-574080.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"663\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"James Gallagher\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"James Gallagher\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/bash-permission-denied-solution\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/bash-permission-denied-solution\\\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"Bash permission denied Explanation and Solution\",\"datePublished\":\"2021-02-23T02:42:57+00:00\",\"dateModified\":\"2023-12-01T12:08:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/bash-permission-denied-solution\\\/\"},\"wordCount\":605,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/bash-permission-denied-solution\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/code-coding-computer-developer-574080.jpg\",\"articleSection\":[\"Software Engineering\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/bash-permission-denied-solution\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/bash-permission-denied-solution\\\/\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/bash-permission-denied-solution\\\/\",\"name\":\"Bash permission denied Explanation and Solution\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/bash-permission-denied-solution\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/bash-permission-denied-solution\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/code-coding-computer-developer-574080.jpg\",\"datePublished\":\"2021-02-23T02:42:57+00:00\",\"dateModified\":\"2023-12-01T12:08:58+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"Learn the causes of and the solution to the Bash permission denied error on Career Karma.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/bash-permission-denied-solution\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/bash-permission-denied-solution\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/bash-permission-denied-solution\\\/#primaryimage\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/code-coding-computer-developer-574080.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/code-coding-computer-developer-574080.jpg\",\"width\":1000,\"height\":663},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/bash-permission-denied-solution\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Coding\",\"item\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/code\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Bash permission denied Explanation and Solution\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\",\"name\":\"James Gallagher\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"caption\":\"James Gallagher\"},\"description\":\"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/author\\\/jamesgallagher\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Bash permission denied Explanation and Solution","description":"Learn the causes of and the solution to the Bash permission denied error on Career Karma.","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:\/\/careerkarma.com\/blog\/bash-permission-denied-solution\/","og_locale":"en_US","og_type":"article","og_title":"Bash permission denied Explanation and Solution","og_description":"Learn the causes of and the solution to the Bash permission denied error on Career Karma.","og_url":"https:\/\/careerkarma.com\/blog\/bash-permission-denied-solution\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2021-02-23T02:42:57+00:00","article_modified_time":"2023-12-01T12:08:58+00:00","og_image":[{"width":1000,"height":663,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/code-coding-computer-developer-574080.jpg","type":"image\/jpeg"}],"author":"James Gallagher","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"James Gallagher","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/bash-permission-denied-solution\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/bash-permission-denied-solution\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"Bash permission denied Explanation and Solution","datePublished":"2021-02-23T02:42:57+00:00","dateModified":"2023-12-01T12:08:58+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/bash-permission-denied-solution\/"},"wordCount":605,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/bash-permission-denied-solution\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/code-coding-computer-developer-574080.jpg","articleSection":["Software Engineering"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/bash-permission-denied-solution\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/bash-permission-denied-solution\/","url":"https:\/\/careerkarma.com\/blog\/bash-permission-denied-solution\/","name":"Bash permission denied Explanation and Solution","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/bash-permission-denied-solution\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/bash-permission-denied-solution\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/code-coding-computer-developer-574080.jpg","datePublished":"2021-02-23T02:42:57+00:00","dateModified":"2023-12-01T12:08:58+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"Learn the causes of and the solution to the Bash permission denied error on Career Karma.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/bash-permission-denied-solution\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/bash-permission-denied-solution\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/bash-permission-denied-solution\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/code-coding-computer-developer-574080.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/code-coding-computer-developer-574080.jpg","width":1000,"height":663},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/bash-permission-denied-solution\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Coding","item":"https:\/\/careerkarma.com\/blog\/code\/"},{"@type":"ListItem","position":3,"name":"Bash permission denied Explanation and Solution"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94","name":"James Gallagher","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","caption":"James Gallagher"},"description":"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.","url":"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/29337","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/240"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=29337"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/29337\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/12811"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=29337"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=29337"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=29337"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}