Manage Default File Permissions

Red Hat Enterprise LinuxBeginner
Practice Now

Introduction

In this challenge, you will learn how to manage default file permissions in a Linux system. Understanding and controlling default permissions is a crucial aspect of system administration, as it helps ensure the security and accessibility of newly created files and directories. You will use the umask command to set the default permission mask and observe its effect.

Manage Default Permissions with umask

Your task is to set a specific umask for your shell session and then create a new file and directory to verify that the default permissions are applied correctly.

Tasks

  • Set the umask value to 0022 for your current shell session.
  • In the ~/project directory, create an empty file named test_file.
  • In the ~/project directory, create a new directory named test_dir.

Requirements

  • All operations must be performed in the ~/project directory.
  • Use the umask command to set the permission mask.
  • Use the touch command to create the file.
  • Use the mkdir command to create the directory.

Example

After correctly setting the umask and creating the file and directory, checking their permissions with ls -l should produce an output similar to this:

$ ls -l ~/project
total 0
drwxr-xr-x 2 labex labex 6 Aug 19 07:43 test_dir
-rw-r--r-- 1 labex labex 0 Aug 19 07:43 test_file
✨ Check Solution and Practice

Summary

In this challenge, you have learned how to manage default permissions for new files and directories in a Linux system. You used the umask command to set a permission mask and observed how it affects the permissions of a newly created file and directory. This skill is fundamental for system administrators to ensure that files are created with appropriate security settings by default, protecting data and maintaining a well-structured system.