Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
Which operating system do you use?Acoording to the manaul page,-h option takes affect only on systems that can change the ownership of symbolic link. –  Jichao Nov 9 '09 at 13:09
add comment

migrated from stackoverflow.com Nov 10 '09 at 21:50

This question came from our site for professional and enthusiast programmers.

5 Answers

I was putting a slash in the end of target:

chown -h myuser:mygroup mysymbolic/

just removed the slash in the end and works.

share|improve this answer
4  
doesn't work for me on ubuntu –  Radek Sep 25 '10 at 1:07
1  
Wow, this took me hours to find. –  defines Apr 19 '11 at 11:36
5  
@Radek It worked for me on Ubuntu so long as I remembered the -h flag. –  IQAndreas Jun 11 '13 at 15:04
    
Works for me on Ubuntu with -h and without the trailing slash. –  friederbluemle Feb 12 at 2:44
add comment

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

share|improve this answer
add comment

Is the target a file or a directory?

If it is a directory then try -H (upper case H)

share|improve this answer
    
the target is a directory –  rizidoro Nov 9 '09 at 13:09
    
see my edited reply about directory –  Michael Nov 9 '09 at 13:13
3  
Sorry for the thread necromancy, but I'd like to point out that the correct syntax is with the lowercase 'h'. –  user40379 Jun 18 '10 at 14:07
    
This is really a comment, not an answer to the question. You can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post. –  Diogo Aug 9 '12 at 16:46
add comment

Recreate that link by myuser at myuser's home, and mv this link to the target location by sudo.

For example: (as myuser), ln -s somedir/ linkname (will be a broken link if somedir/ doesn't exist in user's directory)

Then, sudo mv linkname targetlocation (will become a valid link provided targetlocation/somedir/ exists)

share|improve this answer
    
Your answer is without detail and hard to fully understand. Please consider revising your answer to provide more detail. –  KronoS Jul 13 '12 at 4:20
add comment

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/
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.