fopen(log.txt) failed to open stream permission denied in code example Example: ubuntu fopen failed to open stream: Permission denied $ sudo chmod -R 777 /path/to/directory