Set permissions for all users linux

How to Change Folder Permissions in Linux? [2 Methods]

While running commands in Linux have you ever come across an error message saying the “folder: permission denied”? This is because the Linux operating system by default sets access permissions to the folders which are not accessible to all the available users. This is done by the operating system to ensure optimum security. But we often need to change such restrictions for performing necessary tasks. Therefore, in this article, I will discuss different ways of how to change folder permissions in Linux.

Key Takeaways

  • Two different ways to change folder permissions in Linux.
  • Getting familiar with the sudo, chmod, ls commands in Linux.
  • Running commands as root user.

Requirements

Process Flow Chart

Flow chart of ways to change folder permissions in Linux.

Distro Used Throughout the Tutorial: Ubuntu 22.04.1 LTS

Permission Modes

From the Linux CLI, changes in folder permissions are achieved by using the chmod command. The altered permissions can be represented either in symbolic mode or in absolute mode. Applying Symbolic mode you can change permissions for any desired user class. Whereas with Absolute mode you have to set permissions for all types of user class separately.

Below you will find detailed information on each of the modes.

A. Symbolic Mode

Using symbolic mode, you can add, remove or set access permissions for a particular user class with logical operators. Since chmod takes multiple sets of symbols as arguments, changing permissions of multiple user classes requires comma (,) separated logical expressions.

User Class Operator Access Type
u (user) + (add access) r (read)
g (group) – (remove access) w (write)
o (other) = (set exact access) x (execute)
a (all classes: u, g, and o)

B. Absolute Mode

On the other hand, in absolute mode, to remove all permissions you can assign a “0” (zero) or, to give permissions you must assign one of the following octal values for each user class.

Watch to Change Folder Permissions in Linux

2 Methods to Change Folder Permissions in Linux

In Ubuntu, you can change folder permissions either from the CLI(Command Line Interface) or from the GUI(Graphical User Interface). In this article, I will demonstrate both of the main approaches of changing folder permission Linux.

Читайте также:  Изменение даты линукс терминал

You can read our Comparative Analysis of Methods to distinguish between these two methods and best pick one for your needs.

Method 01: Using CLI to Change Folder Permissions in Linux

Case A: Changing User’s Own Folder Permissions

You can change your own folder’s permissions by simply running the chmod command. You may use either the symbolic mode or the absolute mode of permissions to achieve this task.

Current Permissions of a folder owned by another user.

In this example, I will change the permissions of the “Documents” folder in my home directory. You can see in the following image, the “Documents” folder does not have write and execute access to other users. I will change this permission to give read, write, and execute access to everyone. In this case, using the symbolic mode of the chmod command, I will be adding only write access to the group user class. For the other user class, I will need to add both write and execute access. If you want to use the absolute mode, you have to set permissions to octal value 7 for all the available users.

Steps to follow:

➊ At first, press CTRL+ALT+T to open the Ubuntu Terminal.

➋ After that, copy any of the following commands:

➌ Then, press the ENTER button.

➍ Now, to check the updated permissions run the command below:

➎ Then, hit ENTER.

Changing User’s Own Folder Permissions.

As a result of the given steps, in the above image, you can see that I have given permission to read, write and execute the “Documents” folder to every user class. Moreover, you can view the current permission status by typing the ls command with -l option.

Case B: Changing Other User’s Folder Permissions

When you are a root user or you possess sudo privileges as the root user, you will be able to change the permissions of folders owned by other users as well. In this case, using the sudo keyword you can run the chmod command on these file paths even if the group and other permissions are omitted.

Current Folder Permissions.

Here, I will change the permissions of the “docs” folder owned by another user named “other_user”. You can see in the image below, that the desired directory resides in the path “/home/other_user” and it has read, write and execute permissions only for the owner.

Follow the given instructions to change the permissions of the folder.

Steps to follow:

➊ At first, press CTRL+ALT+T to open the Ubuntu Terminal.

➋ After that, copy the following command:

sudo chmod 777 /home/other_user/docs
sudo chmod a+rwx /home/other_user/docs
  • sudo: Grants administrative privileges.
  • chmod: Changes folder permissions.
  • 777: Sets read, write and execute permissions to all user classes.
  • a+rwx: Adds read, write, and execute permissions for all user classes.
  • /home/other_user/docs: Path to the desired folder.
Читайте также:  Astra linux установка принтера samsung

➌ Then, press the ENTER button.

➍ Now, to check the updated permissions run the command below:

Changing Other User’s Folder Permissions.

➎ Then, hit ENTER.

In the above image, you can see that I have changed the “docs” folder permission owned by another user the “other_user”. Furthermore, by typing the ls command with sudo and the absolute path of the folder, you can view the updated permissions.

Method 02: Using GUI to Change Folder Permissions in Linux

You can also change a folder’s permissions from GUI( Graphical User Interface). But with this approach, you will not be able to apply every combination of the read, write and execute access. To clarify, the folder permissions available to set from the GUI are listed below.

Permission Options Access Type
List files only Read-only (r)
Access files Read & Execute (r+x)
Create and delete files ALL ( r+w+x)
None No access

Steps to follow:

Opening properties of the desired folder.

➊ At first, select your desired folder you want to change permissions of and Click the Right Mouse Button. At this time, Click on “Properties” from the available options.

Moving to the permissions section of the folder from GUI.

➋ Subsequently, go to the “Permissions” section of the Folder Properties.

❸ There are individual options to change permissions of owner, group, and other user classes. For instance, I will leave the owner’s access permissions as it is and SELECT the group access to change it.Selecting group permissions of the folder to change.❹ Furthermore, I will change the group permissions to Access files.Changing the group permissions to Access files.❺ Now, you can see that the other user class does not have any access to the folder. Therefore, to change it I will SELECT the other access option.Selecting other permissions of the folder to change.❻ Moreover, I will set the other access to List files only.Changing the group permissions to List files only.❼ Then, I will close the Documents Properties tab.

Updated folder permissions from GUI.

Finally, upon completion of the mentioned steps, you will find the permissions of the folder changed as shown in the image above.

Comparative Analysis of Methods

Since this article introduces multiple methods for a single task, you might get confused about which one to pick. Therefore, in this section, I am presenting a comparative analysis of the two different approaches for your convenience. You can learn the advantages and disadvantages of the available methods and choose which is the best for you.

Summing up it can be said that both methods come with their own pros and cons. To emphasize, the suitable method varies from user to user. If you want to apply a variety of permission changes and feel comfortable with the CLI you can go for Method 1. On the other hand, If you do not have any idea about the Linux commands and the limited permission options work for you, then you can use the approach through GUI.

Читайте также:  Драйвер dualshock 4 linux

Conclusion

To conclude, I have presented you with the possible ways of changing folder permissions in this article. It includes feasible approaches from both CLI and GUI. Furthermore, I have also illustrated the method of changing folder permissions that are owned by another user. I hope following this guide will help you through your journey with the command line and make you a power user of Linux.

People Also Ask

How do I chmod to a specific user?

To use the chmod command for a specified user, switch to that specific user account by typing the su – USER_NAME command and then change permissions only for the user class.

How to change folder permissions from root to user in Linux

Use the chown command To change ownership. Once group ownership is modified, all members of the group can access this file.

How to change permissions for all files in a directory linux?

To apply permission change for the files inside a directory, you will need to use the -R option with the chmod command . Because this option recursively runs the command on the subfolders and files.

How to change file permissions in Linux?

Changing file permissions in Linux is the same as changing folder permissions in Linux. In this case, you will need to replace the folder name with a file name.

What is Linux permissions 777?

The chmod command with 777 permissions indicates that all types of available users are allowed to have every type of permission. That is all users will have read, write and execute permissions.

What is chmod R 777?

The chmod command with -R option and 777 permissions assigns every user all types of permissions for the specified folder/file. To demonstrate, the permissions are as follows: read, write, and execute access.

How do user permissions work in Linux?

By default, any file/folder created in Linux belongs only to an owner and a group. However, the owner or any user from the group can change file/folder permissions using the chmod command. Users having sudo privileges can also change the permissions of files/folders belonging to any other users in the system.

How do I switch to a specific user in Linux?

You can switch to a specific user in Linux by using the su command. In this case, the command format for switching users is as follows: su – USER_NAME.

Related Articles

  • How to Change Permissions of All Files in a Folder in Linux?
  • Manage File Permissions in Ubuntu Using Command?
  • How to Change File Permissions in Linux with 6 Examples
  • 2 Cases to Give User Permission to Folder and Subfolders in Ubuntu
  • How to Change Directories and Files Recursively with “chmod”
  • Change Permissions on Mounted Drive in Linux

Источник

Оцените статью
Adblock
detector