What does the '-m' option do in the '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

Using the -m option allows you to define the access rights for the directory immediately upon its creation. If you have any further questions or need more clarification, feel free to ask!

0 Comments

no data
Be the first to share your comment!