Linux File Permissions


Linux file permissions are a critical aspect of the operating system's security model. They determine who can access files and directories, what actions can be performed on them, and by whom. Linux uses a combination of permission bits and ownership to control access to files and directories.

Linux file permissions:

Permission Bits: In Linux, each file and directory has three sets of permission bits, each consisting of three characters:

  1. Owner Permissions:

    • The first set of three permission bits applies to the owner of the file or directory.
    • The three characters represent read (r), write (w), and execute (x) permissions.
    • Example: -rwxr--r-- means the owner has read, write, and execute permissions, while others have only read permissions.
  2. Group Permissions:

    • The second set of permission bits applies to the group that owns the file or directory.
    • Like owner permissions, it consists of three characters (r, w, x).
    • Example: -rwxr--r-- means the group has read permissions but no write or execute permissions.
  3. Other (or World) Permissions:

    • The third set of permission bits applies to all other users who are not the owner or part of the group.
    • It also consists of three characters (r, w, x).
    • Example: -rwxr--r-- means others have read permissions but no write or execute permissions.

Permission Actions:

  • Read (r): Allows viewing the contents of a file or listing the contents of a directory.
  • Write (w): Permits modifying the file's content, deleting the file, or creating new files within a directory.
  • Execute (x): Enables running or executing a file (e.g., running a script or executing a program). For directories, it allows traversal into the directory.

Numeric Representation: Linux also represents permissions using numeric values, such as:

  • 4 for read (r)
  • 2 for write (w)
  • 1 for execute (x)
  • 0 for no permission

These values are added together to create a three-digit number. For example, read and write permissions are represented as 6 (4 + 2), while all permissions are represented as 7 (4 + 2 + 1).

Changing Permissions: Permissions can be changed using the "chmod" command in Linux. The "chmod" command accepts either symbolic representation (e.g., "u+rwx") or numeric representation (e.g., "chmod 755 file").

Ownership: Every file and directory in Linux also has an owner and group associated with it. The owner is typically the user who created the file, while the group is the group associated with that user. Ownership can be changed using the "chown" and "chgrp" commands.

Here are some common commands for changing permissions and ownership:

  • chmod: Change file permissions.
  • chown: Change file owner.
  • chgrp: Change file group.
  • ls -l: List files with their permissions and ownership.

Properly configuring file permissions is crucial for maintaining system security and controlling access to sensitive data and system resources in a Linux environment. Misconfiguring permissions can lead to unauthorized access or unintentional data loss, so it's essential to understand and manage file permissions effectively.


File management in Linux involves performing various tasks related to organizing, creating, modifying, and deleting files and directories. Linux provides a powerful set of command-line tools for file management, and graphical file managers are also available for those who prefer a graphical interface. Here are some common file management tasks and the corresponding commands in Linux:

  1. Navigating the File System:

    • pwd: Print the current working directory.
    • cd: Change the current directory.
    • ls: List files and directories in the current directory.
    • ls -l: List files and directories in long format (provides detailed information).
  2. Creating Files and Directories:

    • touch filename: Create an empty file.
    • mkdir directoryname: Create a new directory.
    • mkdir -p directory/subdirectory: Create nested directories (if they don't exist).
  3. Copying, Moving, and Renaming Files:

    • cp source destination: Copy files or directories.
    • mv source destination: Move or rename files or directories.
    • mv oldname newname: Rename a file or directory.
  4. Viewing File Contents:

    • cat filename: Display the entire contents of a file.
    • more filename or less filename: Display the contents of a file one page at a time.
    • head filename and tail filename: Display the beginning or end of a file, respectively.
  5. Editing Files:

    • nano filename or vim filename or emacs filename: Open a text editor to edit a file.
    • Use these editors to create, modify, and save files.
  6. Deleting Files and Directories:

    • rm filename: Remove a file (be careful, as it's irreversible).
    • rm -r directory: Remove a directory and its contents recursively.
    • rmdir directory: Remove an empty directory.
  7. Searching for Files:

    • find directory -name filename: Search for files by name in a specific directory.
    • grep pattern filename: Search for text within files.
  8. Changing File Permissions:

    • chmod permissions filename: Change the permissions of a file.
    • chown user:group filename: Change the owner and group of a file.
  9. Archiving and Compressing Files:

    • tar -cvf archive.tar files: Create a tar archive of files.
    • tar -xvf archive.tar: Extract files from a tar archive.
    • gzip filename: Compress a file with gzip (creates a .gz file).
    • gunzip filename.gz: Decompress a gzip-compressed file.
    • zip filename.zip files: Create a zip archive of files.
    • unzip filename.zip: Extract files from a zip archive.
  10. Disk Space Usage:

    • df -h: Display disk space usage on all mounted file systems.
    • du -h directory: Show disk usage of a directory.

These are some fundamental file management commands in Linux. Learning and mastering these commands will help you efficiently manage files and directories in a Linux-based system.



Linux and Unix file permissions are a way to control who can access and modify files and directories. Every file and directory has three types of permissions:

  • Owner: The owner of the file is the user who created it.
  • Group: The group of the file is a group of users who are allowed to access and modify the file.
  • Other: All other users on the system.

Each permission can be set to one of three values:

  • Read: The ability to read the contents of the file.
  • Write: The ability to modify the contents of the file.
  • Execute: The ability to execute the file, if it is an executable program.

File permissions are represented by a string of nine characters, each of which represents one of the three permissions for the owner, group, and other. The first three characters represent the owner's permissions, the next three characters represent the group's permissions, and the last three characters represent the other permissions.

For example, the following string represents a file with read and write permissions for the owner and group, and read-only permissions for other:

rw-r--r--

You can use the ls -l command to view the permissions of a file or directory. For example, the following output shows the permissions of the file myfile.txt:

-rw-r--r-- 1 user user 1024 Sep 24 16:16 myfile.txt

The first character, -, indicates that the file is a regular file. The next nine characters represent the permissions. The first three characters, rw-, indicate that the owner has read and write permissions. The next three characters, r--, indicate that the group has read-only permissions. The last three characters, r--, indicate that other users have read-only permissions.

You can use the chmod command to change the permissions of a file or directory. For example, the following command would change the permissions of the file myfile.txt to give the group write permissions:

chmod g+w myfile.txt

You can also use the chown and chgrp commands to change the ownership and group of a file or directory.

It is important to set file permissions correctly to protect your files and directories from unauthorized access and modification. For example, you should not set write permissions for other users on files that contain sensitive data.

Here are some general tips for setting file permissions:

  • Set the owner of a file or directory to the user who needs to access and modify it.
  • Set the group of a file or directory to the group of users who need to access and modify it.
  • Only give other users read-only permissions to files and directories that they need to access.
  • Be careful about giving write permissions to other users, especially on files that contain sensitive data.

If you are unsure about how to set file permissions, you can consult with a system administrator.


Enroll Now

  • Networking
  • Linux Tutorial