chmod -R versus chmod *

What is the difference in outcomes when using chmod -R /dir/subdir and chmod /dir/subdir/* ?
Let's say we have /dir/subdir/file1. And we are assigning read and write perms to subdir and its file(s) for user and group owner, nothing for Others but it seems implied since permissions for Others aren't even mentioned. I am saying:
Let's say we have /dir/subdir/file1. And we are assigning read and write perms to subdir and its file(s) for user and group owner, nothing for Others but it seems implied since permissions for Others aren't even mentioned. I am saying:
chmod -R 660 /dir/subdirbut the solution given in the guide says it should be:
chmod 660 /dir/subdir/*What's with the asterisk?
Comments
The asterick is a glob/wildcard and is essentially like doing a "for loop" on the results of $I(ls).
The -R stands for "recursive." It essentially keeps going until it can't anymore.
Certs: RHCSA, LFCS: Ubuntu, CNCF CKA, CNCF CKAD | AWS Certified DevOps Engineer, AWS Solutions Architect Pro, AWS Certified Security Specialist, GCP Professional Cloud Architect
Learn: Terraform, Kubernetes, Prometheus & Golang | Improve: Docker, Python Programming
To-do | In Progress | Completed
asterisk is a wildcard processed by your shell, like bash or whatever you have, not by cp command;
so your command chmod 660 /dir/subdir/* eventually expands to : and it doesn't effect files and subfolders in "anothersubdirs", for this you must explicitly specify -r key for cp command, so it would go recursively, i.e. for all the subfolders and files it contains.
Besides,if you have any folders in that subdir of yours, changing permission bits to 660 for these folders won't make you any good , because you need an executive bit set for them so it would be possible to change current working to one of these.
I bet you got the idea.
The wording of the exercise was: existing files should be set rw for user and group owner. Meaning, existing files of /level0/level1. So when reading this, would it be more logical to use -R? What wording would trigger anyone into using asterisk instead of -R?
What I believe you need to understand is the difference between absolute and relative access permissions (I made up the 'absolute/relative' but it makes sense here). Absolute permission would be 660, and this is dangerous if you are going to use the '-R' option since certain directories would need the execution bit on all (users, groups, and others) so that anyone with appropriate permissions can at least traverse the directories with the 'ls' command to troubleshoot the system if necessary.
The only directories that I can think of that have different permission set is the users' home directories including the /root. This is obviously done to prevent other users from snooping in the home directories that are not theirs.
I prefer the idempotent approach with the relative permission. If I were you, I'd just do this just to be safe: 'chmod -R ug+rw'. This won't affect the existing permission. Let's say the permission was r-xr-xr--. With the command I just mentioned, the new permission would be rwxrwxr--. With the 660, the permission would be rw-rw----.
The only directories that I can think of that have different permissions set is the users' home directories including the /root.
UPDATE: Sorry. I just reread your post. I may be missing the content of the exercise you were going through, but if you're certain it's just 'existing files' in the said directory, then you may can change only the files in that directories. Keep in mind, the asterisk would also change the permission on the directories that's sitting in the same location as those files. So either way with -R or octal mode, you'd not complete the task correctly, and would have to make sure only those files have their permissions changed.