Linux File Permissions Interview Questions for Beginners

Linux File Permissions Interview Questions for Beginners

Linux file permissions are one of the most common topics in beginner level Linux interviews. They are also something you will use regularly when working with servers, applications, users, scripts and shared directories.

Linux uses permissions to control who can read, modify or access files and directories. Understanding permissions also help to troubleshoot common errors such as Permission denied. This is especially important for Linux administration, server management, cybersecurity, cloud and DevOps roles.

Below are 26 practical Linux file permissions interview questions and answers designed around the type of questions a beginner may face actually in an interview.

1. How would you explain Linux file permissions to someone new to Linux?
Linux file permissions control who is allowed to access a file or directory and what they are allowed to do with it. Linux normally separates access into three categories:

·     Owner: The specific user who owns the file
·     Group: users belonging to the file's assigned group
·     Others: everyone else on the system

For each category, Linux can grant read, write and execute permissions. For example:

-rwxr-xr--

This means the owner can read, write and execute the file, the group can read and execute it and others can only read it.

If you are new to Linux, start with our guide on What Is Linux? to understand the operating system before learning file permissions and administration.

2. What are the three basic types of permission in Linux?

The three basic permissions are:

·  Read (r): allows a user to view the contents of a file
·  Write (w): allows a user  modify or delete a file
·  Execute (x): allows executing a file as a program or script

For directories, these permissions have a slightly different meaning. Read allows listing the files in the directory, write allows creating, deleting or renaming entries and execute allows entering or traversing the directory.

3. How are permissions different for a file and a directory?

The meaning of permissions depends on whether the object is a regular file or a directory.

 For a regular file:

·  r allows you to read its contents
·  w allows you to modify its contents
·  x allows you to execute it if it is an executable program or script

For a directory:

·  r allows you to list the names inside it
·  w allows you to create, delete or rename entries, subject to the required directory access
·  x allows you to enter or traverse the directory and access entries within it when other permissions also allow access

4. What do the owner, group and others fields represent?

Every file has a designated owner and an associated group. For example:

-rw-r--r-- 1 david developers 1250 test.txt

Here:

·  david is the owner
·  developers is the group
·  rw- represents the owner's permissions
·  r-- represents the group's permissions
·  r-- represents permissions for others

The others category means users who are neither the file owner nor members of the file's group.

5. How would you check the permissions and ownership of a file?

The most common command is ls -l filename

For example running ls -l report.txt might return:

-rw-r----- 1 alice developers 2048 report.txt

This tells you the file's permissions, owner, group, size and other basic information. To check the directory itself rather than its contents use the -d flag: ls -ld directory_name.

6. A user can read a file but cannot modify it. What would you check?

First, check the file's permissions and ownership using ls -l file.txt.

If the output is -rw-r--r-- 1 alice developers file.txt and the user experiencing the issue is neither the owner nor in the appropriate group member because they fall under others. Because others only have the r-- permission and cannot modify the file.

To confirm I would verify the user’s actual group memberships using id username command. Finally I would check if an Access Control List (ACL) or any other advance security mechanism is restricting access.

7. A user gets Permission denied when entering a directory. How would you investigate it?

I will first check the specific directory's permissions:

ls -ld /path/to/directory

The user must have the appropriate execute (x) permission on that specific directory to traverse or enter it.

Additionally, I will verify the entire parent directory chain. Access to a subdirectory will fail if the user lacks in execute permissions on any parent folder earlier in the path. I would run:

ls -ld /home
ls -ld /home/user
ls -ld /home/user/project

This is more useful than simply changing the permissions on the final directory.

8. Why a user can access a file by its exact path but unable to list the directory's contents?

This happens when a directory has (x) execute permission enabled but lacks read (r) permissions.

Suppose a directory named /reports is configured with chmod 711 /reports and its permission string becomes drwx--x--x. A user with proper file level permissions can successfully read a known file directly using cat /reports/sales.txt.

However, running ls /reports

will throw an error because a user lacks read permission required to list the structural content of the directory.

The key difference: Read (r) permission on a directory allows listing its filenames while execute (x) permission allows traversing the directory and accessing a known filename, provided the file and path permissions allow it.

9. How would you change the owner of a file?

The chown command is used to change file ownership. Because this is an administrative action, it usually required elevated privileges:

sudo chown alice report.txt

This changes the owner of report.txt to alice. To change both the owner and  the group at the same time, use a colon:

sudo chown alice:developers report.txt

Changing ownership normally requires appropriate privileges.

10. How would you change the group associated with a file?

You can use chgrp command to change the group:

sudo chgrp developers report.txt

Alternatively You can achieve the same result using the chown command with a leading colon:

sudo chown :developers report.txt

After changing the group, check the result with ls -l report.txt.

11. When would you use chmod instead of chown?

Use chmod when you want to change read/write/execute permissions of a file or directory e.g., chmod 640 report.txt.

Use chown when you want to change owner or group ownership of a file or directory e.g., chown alice report.txt.

If the wrong user owns a file then fix ownership. If the owner and group is correct but cannot write to the file, change the permissions.

12. What does mean by chmod 644?

The numeric values are calculated by adding the bitmasks: 4 (read),  2 (write) and 1 (execute).

Owner: (6) 4+2 = read + write (rw-)
Group:  (4) 4 = read-only (r--)
Others: (4) 4 = read-only (r--)

Running chmod 644 file.txt allows the owner to read and modify the file, while the group member and everyone else can only read it.

13. What does chmod 755 mean when it applied to a directory?

Applying chmod 755 mydir sets the following permissions:

Owner (7): Read + Write + Execute (rwx). The owner can list files, create/delete entries and enter the directory.

Group (5): Read + Execute (r-x). Group members can list and enter the directory but cannot modify entries.

Others (5): Read + Execute (r-x). Everyone else can list and enter the directory.

These are the standard permissions for public and shared directories that should not be modified by standard users.

14. How would you give a group read and write access to a shared file?

First, ensure the file belongs to the target group:

sudo chgrp developers shared.txt

Next, apply symbolic notation to add read (r) and write (w) permissions for the group (g):

chmod g+rw shared.txt

Verify with ls -l shared.txt and it should show –rw-rw-r-- confirming that any user added to the developers group can now modify the file.

The important part is that the users who need access must actually belong to the developers group.

15. Why chmod 777 is generally not the first solution to a permission problem?

chmod 777 grants read, write and execute permissions to the owner, the group and everyone else.

chmod 777 file

or

chmod 777 directory

Using this to quickly bypass a permission problem creates severe security vulnerabilities. The correct engineering approach is to identify exactly why the access path is failing and grants only the absolute minimum permissions required (the principle of least privileges).

16. What does mean by execute permission when applied to a directory?

Execute permission on a directory means the user can traverse, search or enter it (e.g., using the cd command). Without execute permissions, a directory set to read-only (r--) will let a user see the name of files inside in it but they will completely blocked from reading the file contents, checking file sizes or modifying items within that path.

17. What is the difference between symbolic and numeric permission notation?

Numeric notation uses absolute octal values to overwrite permissions completely:

chmod 755 script.sh

Symbolic notation uses letters (u for user, g for group, o for others, a for all) and operators (+, -, =) to modify specific fields without altering the remaining permissions:

chmod u+x script.sh

Numeric notation uses values:
r = 4
w = 2
x = 1

Symbolic notation uses letters such as:
·   u - owner
·   g - group
·   o - others
·   a - all

18. What is the difference between Linux file permissions and Access Control Lists (ACLs)?

Linux file permissions control access with three categories: the file owner, the group and others. ACLs give more granular security by letting you assign custom permissions to multiple individual users or groups on a single file.

For example, you can check a file's basic permissions using ls -l report.txt command

To view its ACLs, use:

getfacl report.txt

If you want to grant a specific user read access without changing the file's owner, you can use:

setfacl -m u:rob:r report.txt

This grants the user `rob` read permission on the file subject to the ACL mask and other applicable access controls.

ACLs are useful when multiple users need different levels of access to the same file or directory and the standard owner/group/others permissions are not sufficient.

19. What happens when a user belongs to several groups that have different access to a resource?

For a normal file, the Linux kernel determines access permissions sequentially based on the process’s effective user ID and group list.

1. If a user running the process matches the file owner then the owner permissions apply immediately and check stops.

2. If a user does not match the owner but belongs to file’s assigned group then the group permissions apply.

3. If neither matches then other permissions are used.

Linux does not combine group permissions additively, it evaluates the matching tier and stops.

20. Why might changing a file's permissions not solve an application's access problem?

File permissions are only one possible cause. An application can still fail to access a file because of:

·   Incorrect ownership
·   Missing permissions on a parent directory
·   An incorrect service account
·   Access Control Lists (ACLs)
·   SELinux or another security mechanism
·   A filesystem mounted with restrictive options
·   An incorrect application path
·   The application running under a different user than expected

For example, if a web application runs as www-data, giving permissions to your own user does not automatically give access to the application. The correct approach is to identify which user or service account is actually accessing the resource and then investigate the complete access path.

Understanding Linux processes and services can also help when troubleshooting application access issues. Read our guide on Linux Process Management for Beginners to learn more.

21. A user still gets Permission denied even though the file permissions are correct. How would you troubleshoot it?

I would systematically run through the following pipeline:

1. Verify the exact file state: ls -l /path/to/file command

2. Check the user active identity and groups: id username command

3. Trace permissions across the entire absolute path: namei -l /path/to/file command

4. Inspect the file for hidden ACL restrictions: getfacl /path/to/file command

5. Audit system logs for SELinux denials: /var/log/audit/audit.log

This pinpoints the root cause before safely making any configuration changes.

22. A script exists and has read permission but it is not running. What will you check?

Read permission only allows you to view the code inside script but it does not allow execution.

1. Check the bits: ls -l script.sh. If missing then add execute permissions: chmod u+x script.sh

2. Check the shebang line (e.g., #! /bin/bash) at the absolute top of the file and verify that specified interpreter path actually exists on the system

3. Verify that the file does not contain hidden windows carriage return character (\r) which breaks Linux interpreter

4. Check if the partition is mounted with the noexec flag

23. How can you configure a shared Linux directory so that team members can access it and new files inherit the group's ownership?

When multiple team members need to work in the same directory, you can assign the directory to a shared group and enable the setgid bit. This helps ensure that new files and subdirectories inherit the directory's group instead of the creating user's usual primary group.

For example the team uses a group named developers and a shared directory named as /shared.

First assign the directory to the correct group:

sudo chgrp developers /shared

Then set the directory permissions and enable setgid:

sudo chmod 2770 /shared

The leading `2` enables the setgid bit on the directory. The `770` permissions give the owner and group full directory access while others have no access.

Verify the result:

ls -ld /shared

You should see permissions similar to:

drwxrws--- 2 root developers 4096 Oct 9 10:00 /shared

Make sure the intended team members belong to the `developers` group. Also remember that setgid controls group inheritance and it does not assure that every new file will be group-writable. The resulting permissions depend on the creating application's requested permissions and its umask.

24. What is a "umask" and how does it affect new files?

A umask (user mask) is a system setting that acts as a permissions filter when new files or directories are created. It automatically strips away specific permissions for security.

For example, the default system base permission for a new regular file is 666 (rw-rw-rw-). If a user's active umask is set to 022, Linux subtracts these bits from the base, resulting in a default file permission of 644 (rw-r--r--) whenever they save a new document.

25. What should you consider before making a recursive chmod or chown change?

Running a recursive change (-R) alters massive amounts of data instantly and can break system stability if done blindly. Before executing chmod -R or chown -R verify:

·  The accuracy of the target directory path
·  Files and subdirectories need different permissions ( folders require x, files generally do not)
·  Internal system application processes depend heavily on the existing explicit owner accounts
·  The path contains symbolic links which could cause the command to follow paths outside the target directory

For important systems, a small mistake in a recursive ownership or permission change can prevent applications from working correctly.

Once you understand Linux file permissions, expand your system administration knowledge with our guides on What Is LVM in Linux? and the Linux Boot Process and Linux Working.

26. When should you use sudo for a permissions related task and why?

Use sudo when the operation requires elevated privileges and your current user does not have the required authority.

For example:

sudo chown alice:developers report.txt

Changing ownership of a file you do not own normally requires elevated privileges.

However, sudo should not automatically be used to solve every permission problem. If a user receives Permission denied, the correct response is to identify the cause first.

Using sudo may allow you to perform an administrative operation, but it does not fix an incorrectly configured application's user, directory permissions, ACL, or security policy.
 

📚 Related Articles

🌐 What Is Linux?
Understand Linux fundamentals, how the operating system works, and why it is widely used.
⚙️ Linux Process Management for Beginners
Learn how to inspect processes, understand system activity, and troubleshoot Linux services.
🌐 Linux Basic Networking for Beginners
Learn essential Linux networking concepts, including IP addresses, interfaces, gateways, and DNS.
📁 Linux Directory Structure and File System
Explore Linux directories, file locations, and the structure used to organize system files.
Aqeel Anwar - SeekLinux Author
Aqeel Anwar
Linux Administrator & IT Professional

Aqeel Anwar is a Linux Administrator and IT professional with 12+ years of experience in Linux server installation, configuration, troubleshooting and management. He is the founder and author of SeekLinux, where he shares practical Linux tutorials, commands, troubleshooting guides and system administration resources.

Learn more about the author →

Post a Comment

Previous Post Next Post