{"id":25208205,"url":"https://github.com/1010code/remove-shell","last_synced_at":"2026-02-09T02:01:54.251Z","repository":{"id":118676621,"uuid":"281336165","full_name":"1010code/remove-shell","owner":"1010code","description":"Permission denied when running shell scripts. 執行sh檔案提示Permission denied","archived":false,"fork":false,"pushed_at":"2020-07-21T08:44:43.000Z","size":2,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-02T22:29:32.140Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://andy6804tw.github.io/2020/07/21/linux-shell-script/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/1010code.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-07-21T08:08:54.000Z","updated_at":"2020-07-21T08:47:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"3785031c-96a4-4ad2-8def-65ff30207bda","html_url":"https://github.com/1010code/remove-shell","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/1010code/remove-shell","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1010code%2Fremove-shell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1010code%2Fremove-shell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1010code%2Fremove-shell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1010code%2Fremove-shell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/1010code","download_url":"https://codeload.github.com/1010code/remove-shell/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1010code%2Fremove-shell/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29254303,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-09T01:52:29.835Z","status":"online","status_checked_at":"2026-02-09T02:00:09.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-10T12:19:05.368Z","updated_at":"2026-02-09T02:01:54.246Z","avatar_url":"https://github.com/1010code.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# remove-shell\n[Article](https://andy6804tw.github.io/2020/07/21/linux-shell-script/)\n\n## 前言\nShell Script 主要是使用在 Linux 和 MacOS 等 Unix-like 作業系統的自動化操作指令的程式語言。一般我們會使用 `.sh` 副檔名來命名 Shell Script 檔案。然後將該檔案設定為可執行的腳本。這一篇所主要講的內容是當你寫好一個腳本檔案時要執行時去跑出`Permission denied`錯誤訊息。\n\n![](https://i.imgur.com/72ifkYw.png)\n## 解決方法\n其原因是因為當前目錄下沒有執行`.sh`檔案的權限，導致無法執行該指令腳本。在該目錄下執行，輸入以下指令就可以解決囉！\n\n\n```sh\nchmod u+x *.sh\n```\n\nchmod是權限管理命令change the permissions mode of a file的縮寫。 `chmod u+x *.sh` 就表示對當前目錄下的所有副檔名為sh文件的所有者增加可執行權限。\n\n- u代表所有者\n- x代表執行權限\n- +表示增加權限\n\n## 簡單範例\n因為寫程式每次編譯新專案時要把舊的檔案刪除，手動去刪又很麻煩。因此可以寫一個腳本來專門刪除指定資料夾。建立一個 `run_remove.sh` 來執行 `rm` 指令。\n\n![](https://i.imgur.com/D0zJQmP.png)\n\n```\n#!/bin/bash\n\nrm -rf build\n```\n\n接著第二步給予資料夾權限執行 `.sh` 腳本。\n\n```sh\nchmod u+x *.sh\n```\n\n最後執行 `.sh` 檔僅需要在終端機輸入檔案名稱+檔名即可(記得加上相對位置)，例如:\n\n```\n./run_remove.sh      \n```\n\n![](https://i.imgur.com/SmeBl2R.png)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1010code%2Fremove-shell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F1010code%2Fremove-shell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1010code%2Fremove-shell/lists"}