Yes, you can change the permissions of a directory while creating it using the mkdir command with the -m option. This allows you to set the desired permissions at the time of creation.
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) = 75(group): Read (4) + Execute (1) = 55(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!
