Image

Knowledge base → Setting permissions for files and folders in Linux

[Virtual servers] [Shared hosting]
Date of publication: 08.10.2023

To restrict access to files and folders, there are commands that allow you to change the owner and access attributes (read, write, execute)

1. To change the owner of a file or folder, use the command

chown user:group /home/user/temp

1.1 To change the owner of subfolders and files, add the R key, then the change will occur recursively for all

chown -R user:group /home/user/temp

2. To change file access rights, use the command

chmod 640 /home/user/temp

2.1 To recursively change rights, use the R key

chmod -R 640 /home/user/temp

2.2 For example, to change the rights of only all files in subfolders, use the following configuration, where d is the directory

chmod -R 775 $(find . -type d)

2.3 To change the rights of all files including nested ones, where f - files

chmod -R 775 $(find . -type f)




No Comments Yet