1. Use mkdir ("test", 777) to correct the error when programming
Try this:
mkdir ("Test", 0777);
Written as mkdir ("test", 777) may not be able to execute. But vaguely remember, used to be 777 without errors, specifically forgotten, anyway, according to the specification is absolutely right.
2, umask command to use
In addition to assuming that your program directory is under/root/abc/, if your program executes to create a directory under/var/www, it is possible that you always create a 0777 directory always create a 0755 directory, then you can try to use the umask (0) command.
Umask is only valid for the current directory, and the default Umask value is 0022, so you cannot create a 0777 directory directly from another location.
But 0777-0022=0755.
3. How to create a folder for a user group
/etc/passwd and/etc/group find UID and GID
Mkdir/var/ugroup
We can use Chown directly to change the file owner.
Chown Root:newuser/var/ugroup
Modify Permissions
chmod 740/var/ugroup/*
4, see the creation of directory permissions after the command:
Navigate to the user group directory and execute:
Ls-all
will display a similar:
Drwxrwxr-x
Such a result (0775).
chmod----Change the access mode of one or more files (mode)
chmod [options] mode files
Only file owners or privileged users can use this feature to change file access mode. Mode can be a digital form or expressed in the form of who opcode permission. Who is optional, by default is a (all users). Only one opcode (opcode) can be selected. Multiple mode can be specified, separated by commas.
Options
-c,--changes
Only the information of the changed file is exported
-f,--silent,--quiet
The user who does not notify the file when chmod cannot change the file mode
--help
Output help information.
-r,--recursive
Recursively traverse subdirectories and modify all files and subdirectories in the directory
--reference=filename
To set permissions by referencing the permissions of filename
-v,--verbose
Output information for each file, regardless of whether the modification was successful
--version
Output version information.
W.H.O.
U
User
G
Group
O
Other
A
All Users (default)
OpCode
+
Increase permissions
-
Delete permissions
=
Reassign permissions
Permission
R
Read
W
Write
X
Perform
S
Set the ID number of a user (or group)
T
Set sticky bit (sticky bit) to prevent files or directories from being deleted by non-owner
U
User's current permissions
G
Current permissions for Group
O
Current permissions for other users
As a choice, most of us use the form of three-digit octal numbers to represent permissions, the first specifies the owner's permissions, the second specifies the group permissions, the third specifies the permissions of the other user, and each digit determines the permissions by 4 (read), 2 (write), 1 (execute) three numeric values. If 6 (4+2) Representative has the right to read and write, 7 (4+2+1) has read, writes and executes the permission.
The
can also set the fourth bit, which precedes the three-bit permission sequence, and the fourth digit value is 4,2,1, which means the following:
4, set the user ID at execution time to authorize the file-based process, rather than to the user who created the process.
2, set the user group ID at execution time to authorize the process based on the group of files, rather than the user who created the process.
1, setting the sticky bit.