How can you set permissions using the -m option in mkdir command?

The -m option in the mkdir command allows you to set the permissions for the new directory at the time of its creation. You specify the permissions in numeric (octal) format.

Syntax:

mkdir -m permissions directory_name

Example:

To create a directory named new_folder with permissions set to 755 (read, write, and execute for the owner; read and execute for the group and others), you would use:

mkdir -m 755 new_folder

Explanation of Permissions:

  • 7 (owner): Read (4) + Write (2) + Execute (1) = 7
  • 5 (group): Read (4) + Execute (1) = 5
  • 5 (others): Read (4) + Execute (1) = 5

This command creates new_folder with the specified permissions immediately upon creation. If you have more questions or need further clarification, feel free to ask!

0 Comments

no data
Be the first to share your comment!