Menu
×
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING BASH

Bash File Permissions and Ownership

Understanding File Permissions and Ownership

In Unix-like operating systems, file permissions and ownership are crucial for managing access to files and directories.

Each file has an owner, a group, and a set of permissions that determine who can read, write, or execute the file.


File Permissions

File permissions are represented by a series of characters that indicate the permissions for the owner, the group, and others. The permissions are:

  • r: Read permission
  • w: Write permission
  • x: Execute permission

For example, the permission rwxr-xr-- means the owner can read, write, and execute the file, the group can read and execute, and others can only read.


Numeric Representation of Permissions

File permissions can also be represented numerically, which is often used in scripts and command-line operations:

  • 0: No permission
  • 1: Execute permission
  • 2: Write permission
  • 3: Write and execute permissions
  • 4: Read permission
  • 5: Read and execute permissions
  • 6: Read and write permissions
  • 7: Read, write, and execute permissions

For example, the numeric permission 755 means the owner can read, write, and execute (7), and the group and others can read and execute (5).


File Ownership

Each file has an owner and a group associated with it. The owner is typically the user who created the file, and the group is a collection of users who share access to the file.

Commands like chown and chgrp are used to change the ownership and group of a file, respectively.


Common Commands

Here are some common commands for managing file permissions and ownership:

  • chmod: Change file permissions
  • chown: Change file ownership
  • chgrp: Change group ownership


×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2025 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.