Background: When our virtual machines and Windows systems share a directory on Windows (Note: a), the directory under the directory (b) moved (MV) to any directory under Linux, this directory B and the following subdirectory or file permissions are rwx (777), This is their permissions under Windows. So with ll command to list these files, you will find that the obvious difference, because the permissions are different.
So I wrote a bash script that recursively modifies the permissions of these moved files to the default values . The code is as follows:
#!/bin/bash
# Modify the subdirectory or file of the specified directory to the default permissions
# The following function is the right to recursively modify subdirectories and files, but there is another way to copy the entire directory, and the permissions will naturally be set to the default
function Chmoddefault ()
{
If [-d ' $]; then
chmod 755 ' $ ' for I-in-
$1/* do
if [-f ' $i]; then
chmod 644 "$i"
elif [D "$i"]; then
chmod 755 "$i"
chmoddefault "$i"
fi
done
}
if ["$" = "]; Then
echo "Usage:sh $ <dir>"
else
chmoddefault "$"
fi
After testing, the script was found to be correct. But also found another way to change the permissions of the directory to move over, is to use the Copy command (CP), which is equivalent to the current user's identity to create a new directory, so the permissions are naturally the default value!
such as: cp/mnt/hgfs/a/aa/home/zcm/download/