check folder permission on linux 1

How to Check Folder Permission on Linux

Operating systems like Linux and Windows, use settings called permissions to identify which users can also modify and access certain files and folders or directories in their file systems. In this article, we will discuss how to check file and folder permission on Linux.

Overview

Operating systems may run on shared high-performance computers. There can be multiple users in a single operating system, and a single computer may host multiple operating systems with multiple users. File and folder permission is also a way for file systems in an operating system to determine which user can access and modify certain files and directories. In a file system, each file and directory is assigned attributes called “owner” and “group”.

Owner Attribute

Whoever creates a file or folder will be set as the owner of that file or folder. However, if needed, the root administrator has the capability of changing the user attribute for files and folders. Moreover, this capability is useful in situations like if someone from your team leaves and no one can access files and folders owned by this user.

Group Attibute

The group attribute may also be used to provide shared access to certain files or folders, which is convenient for granting access to multiple users. In Linux, users are also individually granted access to the system. Any authorized user can connect to the system remotely or locally and access any resource allocated to them.

Managing permissions individually is simply cumbersome if, let’s say, you have hundreds or, even worse, thousands of users to manage or provision. Moreover, this is where administrators benefit from the concept of user groups. Each user group may also consist of one or several users. Modifying permissions for a user group will also implement the change for all the members of the user group.

How to Check File and Folder Permission on Linux

Check File and Folder Permission via GUI

There are two ways to check for file and folder permission on Linux. One way to check is via GUI (Graphical User Interface). Your Linux distribution most likely would have a file manager already installed if it comes with a desktop environment. Using a file manager, you can also check for file and folder permissions on Linux.

Folder Permissions:

check folder permission on linux 2

As you can see in this screenshot, by using a file manager, you simply right-click on a folder, and you will see a menu of options. Now, go ahead and click on Properties.

check folder permission on linux 3

This is what you will see upon clicking on Properties. Next, you want to click on Permissions.

check folder permission on linux 4

Here you can see that the Owner of this folder is the currently logged-in user. From here, you have different options, like modifying the owner’s access to a folder or file.

check folder permission on linux 5

In this screenshot, you can also see the options for changing the owner’s access. Let’s say you want to add some extra protection from yourself not to delete this folder accidentally, you can also set the access permission to “List files only” or “Access files”.

check folder permission on linux 6

This is an example of what you will see if you click on the drop-down for “Group:”. You will be shown either the default user groups or the currently existing user groups in your system. You can also choose which group you would like to provide permissions to.

check folder permission on linux 7

Here you can also see the types of access available to groups for this certain folder.

check folder permission on linux 8

In this screenshot, you can see that the access options for Others are pretty much the same as for the Group. But then you may want to set this to None, if you don’t want everyone else to have access to this folder.

check folder permission on linux 9

Lastly, these are the options you get when you click on the “Change Permissions for Enclosed Files…”. Let’s check what we have for each drop-down on this window.

For the owner, under Files, the below screenshot shows you the options for its drop down.

check folder permission on linux 10

Next, under Folders for the owner, the screenshot below shows you its dropdown options.

check folder permission on linux 11

For the Group, under Files, these are the options for its dropdown. As you can see in the screenshot below, you have None, Read-only, and Read and write.

check folder permission on linux 12

Then, under Folders, for the Group, you get the options shown in the screenshot below. “None”, “List files only”, “Access files”, and “Create and delete files”.

check folder permission on linux 13

File Permissions:

Same as with folder permissions, just right-click on any file in a file manager, and you will have an option to check the file’s properties, and from there, you can check its permissions. The screenshot below shows you the options when right-clicking on a file from a file manager.

check folder permission on linux 14
check folder permission on linux 15

This is what you will see upon opening a file’s properties. You can see details about the file, like its size, type, and when it was last modified.

check folder permission on linux 16

Here you can see the options for changing access permissions for the owner, group, and for others. Just like what you see for folders, you will also have under the dropdowns access options like “None”, “Read-only”, and “Read and write”. You also have a tick box to set the file as executable.

Check File and Folder Permission via CLI

From the command line, you can also check for file and folder permissions on Linux.

Though it is a bit confusing compared to doing it from the GUI, checking from the command line is more recommended.

To check the permissions for all folders and files in a directory, use the command below with the options -la. As needed, you can add other options as well. For our example, we will run the ls command in the home directory of the user account dregs.

Syntax:

$ ls <options>

Example:

$ ls -lah
check folder permission on linux 17

In this screenshot, you can see that upon running the above command, it prints out the permissions for all files and folders in the home directory, including hidden files as well since we included the option -a.

For each line, the first character indicates whether it is a file or a folder. Folders are indicated by a “d” character, which means directory. The “-” character at the beginning means the object is a regular file.

The characters “r”, “w”, and “x” represents different permission levels:

Permission
Files
Directories

r

permission to read the file

permission to ls the directory

w

permission to write the file

permission to modify contents

x

permission to execute the file

permission to cd to the directory

Multiple instances of r, w, and x represent different ownership levels, which are grouped into three sets.

Owner or user permissions: 

  • After the first character, which indicates a directory or a file, the first set indicates the owner or user permission settings.
  • For the above example -rw-r--r--, the owner or user permissions are rw-, which indicates that the owner can read and write to the file but can’t execute it as a program.
  • For our next sample, if you see drwxr-xr-x, the user permissions are rwx, indicating that the owner or user can view, modify, and enter the directory.

Group permissions:

  • The next rwx set indicates the group permission settings. In the sample screenshot above, the fourth column shows that the group name is dregs, while the third column shows the user name.
  • For example, if you see -rw-r--r--, the group members can only read the file.
  • If you see drwxr-xr-x, group members can view and enter the directory.

Other Permissions:

  • The third set of rwx is for other users and groups. This is anyone else that is not a member of the group. For the examples above, you can see that the permission settings for others are exactly the same as the settings for the group permissions.

And that’s about it for this tutorial. We looked at how to check file and folder permission on Linux via GUI and via CLI. We also discussed the different sets of permission settings for files and folders on Linux.

If this guide helped you, please share it. ?

Leave a Reply
Related Posts