If you have a Clouding.io Linux VPS Server running the Linux operating system, you may at some point need to modify permissions, change the owner/group or, in short, make changes to Linux files and directories.
We explain how to do this easily. To do so, you must access your server via SSH:
Note
You can find more information about accessing your server via SSH in the article:
The commands used to modify permissions or change the owner of a file/directory are chmod and chown.
chmod
The use of chmod can be described as follows:
There are 3 basic permissions in Linux:
- r – read
- w – write
- x – execute
These three permissions can be assigned to the following four categories:
- u – Owner: owner of the file or directory.
- g – Group: group to which the file or directory belongs.
- o – Others: all other users who are not the owner and do not belong to the group.
- a – All: includes the owner, the group and others.
You can check the permissions set using ls -lh or the command stat by running them on the following files:
File
# ls -lh archivo.txt # stat archivo.txt
If you want to set write permissions for the file's group, do so as follows:
File
# chmod g+w archivo.txt
And to remove them, use the following:
File
# chmod g-w archivo.txt
With these guidelines, you can add or remove permissions for the four groups mentioned above.
In addition, it is also possible to modify permissions using Octal mode.
chown
To change the owner and group of a file, simply use chown as follows:
File
# chown usuario:grupo archivo.txt
This command will set usuario as the owner and grupo as the group.
You can use regular expressions such as:
# chown usuario:grupo * to modify the owner and group of all files and folders in your current location, or
# chown -R usuario:grupo *to do so for a specific directory or file.