Continuing to take simple notes on Linux commands, why put chown and chmod in the same article? The main reason is that the words of these two commands are too close, which may cause confusion (good VPS often misremembers them at first). In fact, there is a big difference between these two commands. In layman's terms, chown It sets the owner, and chmod sets the permissions.
chmod is also a common Linux command . It is used to change the access permissions of files or directories. It also has many parameters.
The simplest use is as follows:
1 |
chmod 777 filename |
Directly give 777 permissions to the file. You can also add -R to the folder and all files under the folder to synchronize the specified permissions.
Here I record a command in particular. I always go to my notepad when I use it, and forget it after I finish it. . .
1. All folders in the current directory and subdirectories are given 755
1 |
find . -type d -exec chmod 755 {} + |
2. All files in the current directory and subdirectories are given 644
1 |
find . -type f -exec chmod 644 {} + |
The pictures are just for illustration. If you have other general or advanced usage of these commands, please feel free to add them.