I am trying to change the ownership of a symbolic link (jakarta
) which points to another directory, but when I run
$ chown user1 jakarta
it changes the ownership of the directory that jakarta
is pointing to instead. Why?
$ chown -h user1 jakarta
ownership of `jakarta' retained as user1
You are attempting to change the ownership of a symbolic link, however, the permissions of the link itself don't matter - what mappers are the permissions of the target that the link points to. If you do, for whatever reason, want to change the ownership of the actual symlink you can use chown -h
:
$ ll
total 4.0K
lrwxrwxrwx 1 root root 3 Mar 25 08:18 bar -> foo/
drwxrwxr-x 2 root root 4.0K Mar 25 08:18 foo/
$ chown -v quux:quux bar
changed ownership of `bar' from root:root to quux:quux
Note how it actually changed the target (foo
):
$ ll
total 4.0K
lrwxrwxrwx 1 root root 3 Mar 25 08:18 bar -> foo/
drwxrwxr-x 2 quux quux 4.0K Mar 25 08:18 foo/
$ chown -vh quux:quux bar
changed ownership of `bar' from root:root to quux:quux
$ ll
total 4.0K
lrwxrwxrwx 1 quux quux 3 Mar 25 08:18 bar -> foo/
drwxrwxr-x 2 quux quux 4.0K Mar 25 08:18 foo/