How to Add Read Permission to a File in Linux

How to Add Read Permission to a File in Linux?

To add read permission to a file in Linux, you can use the chmod (change mode) command. For example, if you want to grant read permission to the file owner, you run chmod u+r filename. To allow all users to read the file, you use chmod a+r filename. This simple command adjusts the file’s permission bits so that the specified users can view the file contents without altering its contents or executing it.

Now, let’s dive deeper into understanding Linux file permissions, why read access matters, and step-by-step methods to manage file permissions effectively.

Understanding Linux File Permissions

Linux is a multi-user operating system, and one of its strongest features is its robust file permission system. Every file and directory has three types of permissions that define what actions can be performed:

  1. Read (r) – Permits seeing the contents of a file or listing the contents of a directory.
  2. Write (w) – Allows modifying or deleting a file, or adding/removing files in a directory.
  3. Execute (x) – Allows executing a file as a program, or accessing a directory and its subdirectories.

Permissions are assigned to three categories of users:

  • Owner (u) – The user who created or owns the file.
  • Group (g) – A set of traffic who share the same group.
  • Others (o) – All other users on the method.

There’s also a shortcut category all (a), which applies to everyone (owner, group, and others).

Viewing File Permissions

Before modifying permissions, it’s important to know the current status. Use the ls -l command:

ls -l filename

Example output:

-rw-r----- 1 user group 1200 Sep 14 10:30 report.txt

Breaking this down:

  • -rw-r—– → Permission string
  • rw- → Owner can read and write
  • r– → Group can read only
  • — → Others have no access

Here, the owner can read and write, the group can only read, and others have no permission.

Adding Read Permission Using chmod

The chmod command is the standard tool for changing file permissions. There are two main ways to use it: symbolic mode & numeric mode.

1. Symbolic Mode

In symbolic mode, you specify who gets the permission (u, g, o, a) and what action to take (+, -, =).

  • Add read permission to owner:
    chmod u+r filename
  • Add read permission to group:
    chmod g+r filename
  • Add read permission to others:
    chmod o+r filename
  • Add read permission for everyone:
    chmod a+r filename

After this, check the updated permissions with ls -l filename.

2. Numeric Mode

In numeric mode, permissions are represented by numbers:

  • 4 = read
  • 2 = write
  • 1 = execute

Add the values together to set permissions:

  • 6 = read + write
  • 7 = read + write + execute

Example:

  • Give owner read-only access, and no permissions for others:
    chmod 400 filename
  • Give everyone read access:
    chmod 444 filename

Practical Examples

Example 1: Share a Report with a Team

If you have report.txt and want all users to read it but not edit it:

chmod a=r report.txt

This sets read-only for owner, group, and others.

Example 2: Secure a File but Allow Read for Group

Suppose you want only your team members (group) to read the file, but no one else:

chmod 640 project.txt
  • Owner: read + write
  • Group: read
  • Others: none

Example 3: Add Read Permission Without Changing Others

If you only want to add read permission for the group, without affecting other permissions:

chmod g+r notes.txt

Permissions on Directories

Read permission behaves slightly differently on directories:

  • Read (r) → Allows listing the directory contents.
  • Write (w) → Allows creating or deleting files inside.
  • Execute (x) → Allows accessing and navigating into the directory.

If you want users to list files in a directory but not modify them:

chmod a+r directoryname

To make it more usable, you’ll often combine it with execute:

chmod a+rx directoryname

This ensures users can both view and enter the directory.

Best Practices for File Permissions

  1. Grant minimum necessary permissions – Avoid giving unnecessary read access to sensitive files.
  2. Use groups effectively – Instead of giving access to all users, assign read permission to specific groups.
  3. Avoid 777 – While chmod 777 (full access for everyone) works, it’s insecure and should be avoided on shared systems.
  4. Automate with scripts – If you manage many files, use shell scripts to apply consistent permissions.
  5. Check umask – The default umask value defines permissions for new files. Adjust if needed.

Troubleshooting Permission Issues

  • “Permission denied” when opening a file:
    Make sure you have r permission for the file and x for the directory containing it.
  • Still can’t open even with read permission?
    If the file is in a restricted directory without execute permission, you won’t be able to access it. Add execute (chmod +x) to the directory.
  • Permission changes not working?
    Ensure you’re the file owner or a superuser (root). Otherwise, use sudo chmod ….

Conclusion

Adding read permission to a file in Linux is simple once you understand how the permission system works. The chmod command lets you grant access either symbolically (u+r, g+r, o+r, a+r) or numerically (444, 640). Whether you’re sharing documents, securing sensitive files, or managing directories, fine-tuning permissions ensures the right people have access while keeping your system safe.

By mastering these techniques, you’ll not only fix “permission denied” errors but also maintain a secure and organized Linux environment.

Scroll to Top