← Back to Bash Course | Chapter 1: Setup & Basics | Lesson 3 of 12

chmod +x का उपयोग

एक नई script file एक locked toy box जैसी है, इसलिए computer इसके साथ नहीं खेलेगा जब तक आप permission न दें। chmod +x वह key है जो कहती है 'हां, इस file को run करने की अनुमति है'।

In this page:

  1. chmod +x
Syntax
bash
chmod +x file_name
./file_name

chmod +x

chmod +x file एक file में execute permission जोड़ता है, जो ./script.sh से एक script run करने से पहले ज़रूरी है। इसके बिना, shell एक "permission denied" error के साथ refuse करता है। यह एक नई script file बनाने के बाद एक one-time step है।

Warning: chmod +x भूल जाना सबसे आम कारण है जिस वजह से एक नई script सीधे run नहीं होती।

उदाहरण: chmod +x

bash
# Check current permissions
ls -l script.sh

# Add execute permission for the owner
chmod +x script.sh

# Now it can be run directly
./script.sh

⚠️ Run this in your own terminal or Node.js environment.

Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. chmod +x को गलत path पर run करना, इसलिए script अब भी Permission denied देती है।
  2. chmod 777 उपयोग करना जब chmod +x (या chmod 755) काफी हो, जो file को everyone के लिए writable बना देता है।
  3. यह भूल जाना कि कुछ file systems से copy की गई files execute bit खो देती हैं, इसलिए इसे फिर से set करना पड़ता है।

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.