Applying Default Permissions

Default Permissions

  • Overview of Default Permissions

    • Understanding default permissions and their significance in a computing environment.

UMask: Definition and Functionality

  • UMask

    • UMask is a shell setting that subtracts the UMask from the default permissions.

    • Default permissions for files are set to 666666 and for directories to 777777.

    • The UMask can limit the permissions of newly created files and directories, enhancing system security.

Setting UMask

  • Location of UMask Settings

    • Default UMask is set in:

    • ETC bash RC

      • Accessed through /etc/bash.rc.

      • This setting applies to everything executed within that specific shell.

    • User-specific overrides can be made in:

    • User-specific bashrc:

      • Found as .bashrc in the user's home directory.

Calculating Default Permissions with UMask

  • Default Permissions and UMask Calculations

    • Example UMask: 022022

    • Calculation:

      • For files: 666−022=644666 - 022 = 644

      • For directories: 777−022=755777 - 022 = 755

    • Example UMask: 027027

    • Calculation:

      • For files: 666−027=640666 - 027 = 640

      • For directories: 777−027=750777 - 027 = 750

    • Important to note that a negative value (like −1-1) is not valid in this context.

Caution in Adjusting UMask

  • Risks of Tweaking UMask

    • Changing the UMask can have unintended consequences.

    • Example:

    • Setting UMask to restrict permissions could inadvertently prevent necessary access to critical files or directories, particularly those owned by ‘Root’.

    • Advise exercising caution before altering the UMask settings.

Practical Demonstration

  • Usage Example

    • Command to check current UMask:

    • Type uMask in the shell.

    • Observation of leading zero (e.g., 022022).

    • The leading zero indicates special permissions, typically disregarded in practical usage.

    • How to set a new UMask:

    • Example command: uMask 027

    • Confirmation: Type uMask again to verify the new setting (output: 0027).

    • Using touch to create a file (command: touch file3) and then running:

    • ls -l file3 to display file permissions (output: default permissions are 640640).

Viewing Current Settings

  • Checking UMask Settings in Configuration Files

    • Command to check current UMask in user-specific bashrc: grab on UMask .bashrc

    • Result indicates no default UMask set.

    • Checking default UMask in main configuration: grab on uMask /etc/bash.rc

    • Output should indicate default setting like uMask - = 0 and uMask 022.

    • This means if UMask is not currently established, it defaults to 022022.

Conclusion

  • Final Note

    • Caution is critical when modifying UMask settings due to the potential risks involved.

    • Ensure understanding before any changes to maintain the integrity and security of file permissions in the system.