If you come across a rather cryptic word “lrwxrwxrwx” when listing files and directories, here’s how you can interpret it.
As you know, file permissions in Unix are traditionally provided using 3 levels:
lrwxrwxrwx follows a permissions structure:
tUUUGGGOOO, where t is the file type indicator, UUU are the three characters specifying user (file owner) permissions, GGG are the group permissions and OOO are the others permissions.
So in the lrwxrwxrwx case, l stands for symbolic link – a special kind of pointer allowing you to have multiple filenames pointing to the same Unix file.
rwxrwxrwx is a repeated set of permissions, rwx meaning the maximum permissions allowable within basic settings.
rwx permissions mean the following access is permitted:
Interestingly, lrwxrwxrwx is a permission that’s rather uncommon: usually symlinks get a different (less forgiving) file permissions. Since symlinks are just pointers to other files, it doesn’t matter much if you provide w (write) permissions or not – they would not allow you to control write access to the destination file.
Example: we use the touch command to create a simple file called “file”. We specifically remove write permissions and this means we can’t write anything into the file as you can see:
If we create a symlink file2 pointing to file, it will actually show first group of permission block (user permissions) to be rwx, so it may see you have write access to the file it’s pointing to:
But if we try to write the same word “test” into file2 symlink, we’ll still get an error cause it’s pointing to the file which only has read permissions.
Finally, if we allow write permissions on the file again, we can write into file2 symlink and it will work just fine this time: