File Permissions
File permissions are like house rules saying who may read, change or use something. Each file has one set of rules for its owner, one for their group and one for everybody else.
In this page:
Syntax
chmod mode file_name
# e.g. chmod 755 file_name or chmod u+x file_name
File Permissions
File permissions control read (r), write (w), and execute (x) access for the owner, group, and others, viewable with ls -l.
chmod changes them, either symbolically (chmod u+x file) or numerically (chmod 755 file). Understanding the numeric mode (owner/group/other as three digits) is essential for managing script and file access.
Note:
chmod 755 is the common mode for an executable script: owner can read/write/execute, everyone else can read/execute.Example: File Permissions
#!/bin/bash
touch demo.sh
chmod 755 demo.sh
ls -l demo.sh
chmod u-x demo.sh
ls -l demo.sh
Login to try C/C++/Java/PHP code in the editor
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. #}
Common Mistakes
- Using
chmod 777to fix problems, which makes files writable by everyone. - Mixing up the owner, group and others digits in
chmod 640. - Forgetting that directories need the execute bit to enter them.
🔒
Chapter Quiz — Complete all 13 topics to unlock
0/13 topics done
Complete these topics first: