Example 1 — Change the Group of a Link
Create a symbolic link and give the link a new group. Run this as a user who is allowed to do so, such as root.
<?php
$link = __DIR__ . '/current';
symlink('releases/v1', $link);
if (lchgrp($link, 'www-data')) {
echo "Group of the link changed", PHP_EOL;
} else {
echo "Could not change the group", PHP_EOL;
} How It Works
- symlink() creates a link named current that points to releases/v1.
- lchgrp() sends the new group name to the operating system.
- Only the link is changed, not the folder releases/v1.
- A true result prints the success message.

