Creating symbolic links in Linux allows you to access a file or directory from several places at the same time. In some cases, it allows you to specify a folder with files that are located in a completely different location.
1. Create a link to the file
Where the path to index.html is a file existing at this path, and the path to root.html is a link leading to the file index.html
ln -sf /var/www/html/index.html /home/user/root.html
1.2 Creating a link to a folder
Existing folder domain1.tld, created link at /home/user/domain1.tld
This way we get a link leading to a folder in another location.
ln -s /var/www/html/domain1.tld /home/user/domain1.tld
2. Changing permissions for symbolic links
When using symbolic links for various web services, it is very important that the rights to them match the same as for other files and folders. For example, if you created a symbolic link from the root user and placed it in the web server directory, for access to work correctly and without errors, you need to specify the correct owner.
To change user and group for symbolic links, use the -h switch, example:
chown -h user:group /home/user/domain1.tld
chown -h user:group /home/user/root.html
2.1 Checking owner and group
ls -la
The command will display information about assigned rights and owner for all files in the current directory.