Wednesday, June 5, 2013

Change ownership of symbolic link

To change ownership of a symbolic link, use flag -h:
chown -h {USER_NAME}:{GROUP_NAME} {SYMLINK_NAME}

NFS mount problem - permission denied

One of common problem with NFS mounts is "permission denied" error while trying to modify existing files and folders, even if your user and group names are matching content creator's user and group. 
If you're sure that you gave "rw" permission on this NFS share to the client's host, check each user ID and group ID. File access permissions are being verified based on UID and GID, not on names. 

Run these commands on both machines, and check that UID and GID are matching:
/usr/sbin/vipw -s
/usr/sbin/vigr -s

If UID or GID is different, change it on one of servers using following commands:


/usr/sbin/usermod -u {NEW_USER_ID} {USER_NAME}
/usr/sbin/groupmod -g {NEW_GROUP_ID} {GROUP_NAME}
/usr/sbin/usermod -g {NEW_GROUP_ID} {USER_NAME}

For example, you need to update UID of user "test" to 345, GID of group "testgrp" to 999:

/usr/sbin/usermod -u 345 test
/usr/sbin/groupmod -g 999 testgrp
/usr/sbin/usermod -g 999 test

First command will update UID, second will update GID, third will update GID in user record.

NOTE: all these commands should be executed as root
NOTE 2: if you have any folders owned by this user (except home folder), you'll need to change ownership to same user and group again, because it also uses UID and GID.

Tuesday, June 4, 2013

JavaScript - download a file

If you need to download a file from JavaScript, add this code:
$("<iframe>")
.hide()
.prop("src", $myFileURL)
.appendTo("body");