chown is not changing symbolic link
I'm trying to change the user/group of a symbolic link with the command:
$ chown -h myuser:mygroup mysymbolic/
But it's not changing. I'm logged in as root. The current user/group is set to root:root. What went wrong?
I was putting a slash in the end of target:
chown -h myuser:mygroup mysymbolic/
just removed the slash in the end and works. Here's the correct way:
chown -h myuser:mygroup mysymbolic
I've tried this myself and it works for me. If you have the -h it changes the owner of the symbolic link, but if you dont then it changes the owner of the file itself and not the link.
But it doesnt seem to work of the symbolic link is linked to a directory
I was unable to chown
a directory even with -h
but using the full path worked.
# ls -al
drwxr-xr-x 2 deploy deploy 4096 Dec 30 10:29 .
drwxr-xr-x 3 deploy deploy 4096 Dec 30 08:59 ..
lrwxrwxrwx 1 root root 32 Dec 30 09:02 apps -> /u/apps/
# chown -h deploy:deploy apps
# ls -al
drwxr-xr-x 2 deploy deploy 4096 Dec 30 10:29 .
drwxr-xr-x 3 deploy deploy 4096 Dec 30 08:59 ..
lrwxrwxrwx 1 root root 32 Dec 30 09:02 apps -> /u/apps/
# chown -h deploy:deploy apps/
# ls -al
drwxr-xr-x 2 deploy deploy 4096 Dec 30 10:29 .
drwxr-xr-x 3 deploy deploy 4096 Dec 30 08:59 ..
lrwxrwxrwx 1 root root 32 Dec 30 09:02 apps -> /u/apps/
# pwd
/var/www/html
# chown -h deploy:deploy /var/www/html/apps
# ls -al
drwxr-xr-x 2 deploy deploy 4096 Dec 30 10:29 .
drwxr-xr-x 3 deploy deploy 4096 Dec 30 08:59 ..
lrwxrwxrwx 1 deploy deploy 32 Dec 30 09:02 apps -> /u/apps/